// +---------------------------------------------------------------------- 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,'导出成功'); } }