Commission.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\store\controller\statistics;
  13. use app\common\service\Export as ExportService;
  14. use app\store\controller\Controller;
  15. use app\store\model\User;
  16. use app\store\model\user\CommerCountTj;
  17. /**
  18. * 推荐官销售概览
  19. * Class Data
  20. * @package app\store\controller\statistics
  21. */
  22. class Commission extends Controller
  23. {
  24. /**
  25. *推荐官趋势
  26. * @return array
  27. */
  28. public function commerIncStat(){
  29. $param = $this->request->param();
  30. //$betweenTime = $this->request->param('betweenTime');
  31. if (isset($param['betweenTime'])){
  32. $times = between_time($param['betweenTime']);
  33. }else{
  34. $nowM = strtotime(date('Y-m-01 00:00:00'));
  35. $times['start_time'] =strtotime(date('Y-m-d ',strtotime('-1 month',$nowM)));
  36. $times['end_time'] = $nowM;
  37. if($param['ftype'] == 3){
  38. $times['end_time'] = $nowM - 86400;
  39. }
  40. }
  41. $model = new CommerCountTj();
  42. $volumes = $model->getList($param['ftype'],$times);
  43. $volumes = $volumes?$volumes->toArray():[];
  44. $xes = array_column($volumes,'remark');
  45. if ($param['ftype'] == 1){
  46. $xes = array_map(function($val){
  47. return substr($val,-2).'日';
  48. },$xes);
  49. }elseif($param['ftype'] == 3){
  50. $xes = array_map(function($val){
  51. return substr($val,-2).'月';
  52. },$xes);
  53. }
  54. $volumes = array_column($volumes,'counts');
  55. return $this->renderSuccess(compact('volumes','xes'));
  56. }
  57. /**
  58. * 推荐官趋势导出
  59. * @return array
  60. * @throws \PhpOffice\PhpSpreadsheet\Exception
  61. * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
  62. */
  63. public function exportZx(){
  64. $param = $this->request->param();
  65. if (isset($param['betweenTime'])){
  66. $times = between_time($param['betweenTime']);
  67. }else{
  68. $nowM = strtotime(date('Y-m-01 00:00:00'));
  69. $times['start_time'] =strtotime(date('Y-m-d ',strtotime('-1 month',$nowM)));
  70. $times['end_time'] = $nowM;
  71. if($param['ftype'] == 3){
  72. $times['end_time'] = $nowM - 86400;
  73. }
  74. }
  75. $model = new CommerCountTj();
  76. $data = $model->zxExport($param['ftype'],$times);
  77. if (!count($data['data'])){
  78. return $this->renderError('暂无数据');
  79. }
  80. $res = ExportService::export($data['data'],$data['header'],$data['filename'],'列表');
  81. return $this->renderSuccess($res,'导出成功');
  82. }
  83. /**
  84. * 推荐官基础数据
  85. * @return array
  86. * @throws \think\db\exception\DataNotFoundException
  87. * @throws \think\db\exception\DbException
  88. * @throws \think\db\exception\ModelNotFoundException
  89. */
  90. public function commerBaseStat()
  91. {
  92. $params = $this->request->param();
  93. //推荐官基本佣金
  94. $m = new User();
  95. $list = $m->CommerStat($params);
  96. return $this->renderSuccess(compact('list'));
  97. }
  98. /**
  99. * 推荐官基础数据导出
  100. * @return array
  101. * @throws \PhpOffice\PhpSpreadsheet\Exception
  102. * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
  103. */
  104. public function exportBaseStat(){
  105. $param = $this->request->param();
  106. $model = new User();
  107. $data = $model->exportCommerStat($param);
  108. if (!count($data['data'])){
  109. return $this->renderError('暂无数据');
  110. }
  111. $res = ExportService::export($data['data'],$data['header'],$data['filename'],'列表');
  112. return $this->renderSuccess($res,'导出成功');
  113. }
  114. /**
  115. * 推荐官达量奖励金数据
  116. * @return array
  117. * @throws \think\db\exception\DataNotFoundException
  118. * @throws \think\db\exception\DbException
  119. * @throws \think\db\exception\ModelNotFoundException
  120. */
  121. public function commerBonusStat(){
  122. $params = $this->request->param();
  123. $m = new User();
  124. $list = $m->financeCommerBonusStat($params,true);
  125. return $this->renderSuccess(compact('list'));
  126. }
  127. /**
  128. * 推荐官达量奖励金数据导出
  129. * @return array
  130. * @throws \PhpOffice\PhpSpreadsheet\Exception
  131. * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
  132. */
  133. public function exportBonusStat(){
  134. $param = $this->request->param();
  135. $model = new User();
  136. $data = $model->exportCommerBonusStat($param,true);
  137. if (!count($data['data'])){
  138. return $this->renderError('暂无数据');
  139. }
  140. $res = ExportService::export($data['data'],$data['header'],$data['filename'],'列表');
  141. return $this->renderSuccess($res,'导出成功');
  142. }
  143. /**
  144. * 推荐官业绩排名
  145. * @return array
  146. * @throws \think\db\exception\DataNotFoundException
  147. * @throws \think\db\exception\DbException
  148. * @throws \think\db\exception\ModelNotFoundException
  149. */
  150. public function commerVolumeRank(){
  151. $params = $this->request->param();
  152. $m = new User();
  153. $list = $m->commerVolumeRank($params);
  154. return $this->renderSuccess(compact('list'));
  155. }
  156. /**
  157. * 推荐官业绩排名导出
  158. * @return array
  159. * @throws \PhpOffice\PhpSpreadsheet\Exception
  160. * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
  161. */
  162. public function exportCommerRank(){
  163. $param = $this->request->param();
  164. $model = new User();
  165. $data = $model->exportCommerRank($param);
  166. if (!count($data['data'])){
  167. return $this->renderError('暂无数据');
  168. }
  169. $res = ExportService::export($data['data'],$data['header'],$data['filename'],'列表');
  170. return $this->renderSuccess($res,'导出成功');
  171. }
  172. }