123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195 |
- <?php
- // +----------------------------------------------------------------------
- // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
- // +----------------------------------------------------------------------
- // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
- // +----------------------------------------------------------------------
- // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
- // +----------------------------------------------------------------------
- // | Author: 萤火科技 <admin@yiovo.com>
- // +----------------------------------------------------------------------
- declare (strict_types = 1);
- namespace app\store\controller\statistics;
- use app\common\service\Export as ExportService;
- use app\store\controller\Controller;
- use app\store\model\User;
- use app\store\model\user\CommerCountTj;
- /**
- * 推荐官销售概览
- * Class Data
- * @package app\store\controller\statistics
- */
- class Commission extends Controller
- {
- /**
- *推荐官趋势
- * @return array
- */
- public function commerIncStat(){
- $param = $this->request->param();
- //$betweenTime = $this->request->param('betweenTime');
- if (isset($param['betweenTime'])){
- $times = between_time($param['betweenTime']);
- }else{
- $nowM = strtotime(date('Y-m-01 00:00:00'));
- $times['start_time'] =strtotime(date('Y-m-d ',strtotime('-1 month',$nowM)));
- $times['end_time'] = $nowM;
- if($param['ftype'] == 3){
- $times['end_time'] = $nowM - 86400;
- }
- }
- $model = new CommerCountTj();
- $volumes = $model->getList($param['ftype'],$times);
- $volumes = $volumes?$volumes->toArray():[];
- $xes = array_column($volumes,'remark');
- if ($param['ftype'] == 1){
- $xes = array_map(function($val){
- return substr($val,-2).'日';
- },$xes);
- }elseif($param['ftype'] == 3){
- $xes = array_map(function($val){
- return substr($val,-2).'月';
- },$xes);
- }
- $volumes = array_column($volumes,'counts');
- return $this->renderSuccess(compact('volumes','xes'));
- }
- /**
- * 推荐官趋势导出
- * @return array
- * @throws \PhpOffice\PhpSpreadsheet\Exception
- * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
- */
- public function exportZx(){
- $param = $this->request->param();
- if (isset($param['betweenTime'])){
- $times = between_time($param['betweenTime']);
- }else{
- $nowM = strtotime(date('Y-m-01 00:00:00'));
- $times['start_time'] =strtotime(date('Y-m-d ',strtotime('-1 month',$nowM)));
- $times['end_time'] = $nowM;
- if($param['ftype'] == 3){
- $times['end_time'] = $nowM - 86400;
- }
- }
- $model = new CommerCountTj();
- $data = $model->zxExport($param['ftype'],$times);
- if (!count($data['data'])){
- return $this->renderError('暂无数据');
- }
- $res = ExportService::export($data['data'],$data['header'],$data['filename'],'列表');
- return $this->renderSuccess($res,'导出成功');
- }
- /**
- * 推荐官基础数据
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function commerBaseStat()
- {
- $params = $this->request->param();
- //推荐官基本佣金
- $m = new User();
- $list = $m->CommerStat($params);
- return $this->renderSuccess(compact('list'));
- }
- /**
- * 推荐官基础数据导出
- * @return array
- * @throws \PhpOffice\PhpSpreadsheet\Exception
- * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
- */
- public function exportBaseStat(){
- $param = $this->request->param();
- $model = new User();
- $data = $model->exportCommerStat($param);
- if (!count($data['data'])){
- return $this->renderError('暂无数据');
- }
- $res = ExportService::export($data['data'],$data['header'],$data['filename'],'列表');
- return $this->renderSuccess($res,'导出成功');
- }
- /**
- * 推荐官达量奖励金数据
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function commerBonusStat(){
- $params = $this->request->param();
- $m = new User();
- $list = $m->financeCommerBonusStat($params,true);
- return $this->renderSuccess(compact('list'));
- }
- /**
- * 推荐官达量奖励金数据导出
- * @return array
- * @throws \PhpOffice\PhpSpreadsheet\Exception
- * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
- */
- public function exportBonusStat(){
- $param = $this->request->param();
- $model = new User();
- $data = $model->exportCommerBonusStat($param,true);
- if (!count($data['data'])){
- return $this->renderError('暂无数据');
- }
- $res = ExportService::export($data['data'],$data['header'],$data['filename'],'列表');
- return $this->renderSuccess($res,'导出成功');
- }
- /**
- * 推荐官业绩排名
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function commerVolumeRank(){
- $params = $this->request->param();
- $m = new User();
- $list = $m->commerVolumeRank($params);
- return $this->renderSuccess(compact('list'));
- }
- /**
- * 推荐官业绩排名导出
- * @return array
- * @throws \PhpOffice\PhpSpreadsheet\Exception
- * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
- */
- public function exportCommerRank(){
- $param = $this->request->param();
- $model = new User();
- $data = $model->exportCommerRank($param);
- if (!count($data['data'])){
- return $this->renderError('暂无数据');
- }
- $res = ExportService::export($data['data'],$data['header'],$data['filename'],'列表');
- return $this->renderSuccess($res,'导出成功');
- }
- }
|