diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index 7c0d13d60..2f260fbc7 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -8,6 +8,7 @@ use Base\Repository\PromoteRepository; use Base\Repository\SpendRepository; use Base\Repository\UserRepository; use Base\Service\PromoteService; +use Base\Service\PromoteGradeService; use Base\Facade\Request; use Base\Service\ApplyService; use Base\Service\PromoteCoinRecordService; @@ -1888,6 +1889,66 @@ class DownloadController extends BaseController { $this->success('添加下载成功',U('listsIndex')); } + + public function promote_grade_export() + { + $month = I('month', date('Y-m')); + $loginPromote = $this->getLoginPromote(); + + $promoteGradeService = new PromoteGradeService(); + $setting = $promoteGradeService->getCurrentSetting($loginPromote); + if (is_null($setting)) { + return $this->error('未设置评级规则'); + } + + $parentId = I('parent_id', 0); + $promoteId = I('promote_id', 0); + $searchLevel = 0; + $searchLevelName = ''; + $currentDisplay = ''; + $prevParentId = 0; + + $promoteService = new PromoteService(); + + $parent = null; + if ($parentId > 0) { + $parent = M('promote', 'tab_')->where(['id' => $parentId])->find(); + $currentDisplay = $promoteService->getLevelName($parent['level']) . '推广'; + $prevParentId = $parent['parent_id'] == $loginPromote['parent_id'] ? 0 : $parent['parent_id']; + } else { + $parent = $loginPromote; + $currentDisplay = '自己'; + } + + // $subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'group_remark'])->where(['parent_id' => $parent['id']])->select(); + + $map = ['parent_id' => $parent['id']]; + if ($promoteId > 0) { + $map['id'] = $promoteId; + } + + $promotes = M('promote', 'tab_')->field(['id', 'account', 'real_name', 'level', 'chain'])->where($map)->select(); + array_unshift($promotes, $parent); + + $conditions = json_encode(['promotes' => $promotes, 'setting' => $setting, 'month' => $month], true); + $addtime = time(); + $data1 = [ + 'logid' => 'pg_'.time(), + 'promote_id' => PID, + 'type' => '/Home/PromoteGrade/index', + 'dataname' => '团队评级', + 'status' => 0, + 'addtime' => $addtime, + 'begintime' => 0, + 'content' => '', + 'conditions' => $conditions + ]; + $res = M('downloadlog','tab_')->add($data1); + if (!$res) { + $this->error('添加下载失败'); + } + $this->success('添加下载成功', U('listsIndex')); + } //玩家角色 public function userRoles_data_export() { $gameId = I('relation_game_id', 0); @@ -2158,6 +2219,9 @@ class DownloadController extends BaseController { case "推广员业绩": $this->achievementExcelInfo($id,$map); break; + case "团队评级": + $this->promoteGradeExcelInfo($id,$map); + break; case "渠道管理": $this->childrenExcelInfo($id,$map); break; @@ -3973,6 +4037,35 @@ public function iosDetailExcelInfo($id,$map) { } + public function promoteGradeExcelInfo($tid, $map) + { + $xlsName = "团队评级"; + $xlsCell = array( + array('account','账号'), + array('real_name','姓名'), + array('promote_group', '部门/小组'), + array('grade_name','等级'), + array('value','系数值'), + array('num','当月玩家达标个数'), + array('amount','当月注册充值总额'), + ); + + recordPromoteLogs('评级管理', '团队评级导出'); + + $map = json_decode(json_encode($map), true); + + $promoteGradeService = new PromoteGradeService(); + $records = $promoteGradeService->searchGradeByPromotes($map['promotes'], [ + 'month' => $map['month'], + ], $map['setting']); + + $xlsData = []; + foreach ($records as $key => $value) { + $xlsData[] = $value; + } + $this->exportExcel($xlsName, $xlsCell, $xlsData, $tid); + } + public function achievementExcelInfo($tid, $map) { $xlsName = "推广员业绩"; $xlsCell = array( diff --git a/Application/Home/Controller/PromoteGradeController.class.php b/Application/Home/Controller/PromoteGradeController.class.php index ae83a6a52..5245f1a41 100644 --- a/Application/Home/Controller/PromoteGradeController.class.php +++ b/Application/Home/Controller/PromoteGradeController.class.php @@ -67,7 +67,7 @@ class PromoteGradeController extends BaseController $this->assign('prevParentId', $prevParentId); $this->assign('searchLevelName', $searchLevelName); $this->assign('subPromotes', $subPromotes); - + $this->assign('parentId', $parentId); $this->assign('records', $records); $this->assign('pagination', $pagination); $this->display(); diff --git a/Application/Home/View/default/PromoteGrade/index.html b/Application/Home/View/default/PromoteGrade/index.html index 90cd6a7a6..7d619ae9c 100644 --- a/Application/Home/View/default/PromoteGrade/index.html +++ b/Application/Home/View/default/PromoteGrade/index.html @@ -93,7 +93,7 @@
- 导出 + 导出 {$pagination}