From 2658c50c3ab419cb712295de0a74a777f17fedc8 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 26 Jan 2021 17:11:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=B5=8B=E8=AF=95=E8=B5=84?= =?UTF-8?q?=E6=BA=90=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TestingResourceController.class.php | 89 ++++++ .../View/TestingResource/dailyCount.html | 302 ++++++++++++++++++ .../TestingResourceRepository.class.php | 45 ++- 3 files changed, 435 insertions(+), 1 deletion(-) create mode 100644 Application/Admin/View/TestingResource/dailyCount.html diff --git a/Application/Admin/Controller/TestingResourceController.class.php b/Application/Admin/Controller/TestingResourceController.class.php index 581ecf923..4a6bf577d 100644 --- a/Application/Admin/Controller/TestingResourceController.class.php +++ b/Application/Admin/Controller/TestingResourceController.class.php @@ -243,6 +243,95 @@ class TestingResourceController extends ThinkController $this->assign('records', $records); $this->display(); } + //每日统计 + public function dailyCount() + { + $page = I('p', 1); + $row = I('row', 10); + $params = I('get.'); + $where = $this->setDailyCountWhere($params); + $having = '1=1'; + isset($params['apply_amount_start']) && !empty($params['apply_amount_start']) && ( $having .= ' and apply_amount >=' . $params['apply_amount_start']); + isset($params['apply_amount_end']) && !empty($params['apply_amount_end']) && ( $having .= ' and apply_amount <=' . $params['apply_amount_end']); + + $isExport = $params['export'] ?? 0; + $query = M('testing_resource_batch','tab_') + ->where($where)->field("FROM_UNIXTIME(create_time,'%Y-%m-%d') as create_day_time,user_id,role_id,game_id,apply_promote_id,apply_admin_id,verify_admin_id,sum(apply_amount) apply_amount,sum(provide_amount) provide_amount") + ->group("role_id,game_id,create_day_time") + ->order("create_day_time desc") + ->having($having); + $countsql = clone $query; + if(empty($isExport)){ + $dbdata= $query->page($page,$row)->select(); + $count = M()->table('('.$countsql->select(false).') a')->count(); + }else{ + $dbdata= $query->select(); + } + $repository = new TestingResourceRepository(); + $records = $repository->makeDailyCountData($dbdata); + + $pagination = set_pagination($count, $row); + $gameRepository = new GameRepository(); + $gameId = $params['game_id'] ?? 0; + $this->assign('games', $gameRepository->getChoiceGames()); + $this->assign('count', $count); + $this->assign('_page', $pagination); + $this->assign('records', $records); + $this->display(); + } + protected function setDailyCountWhere($params) + { + $where['_string'] = '1 = 1'; + isset($params['game_id']) && !empty($params['game_id']) && ($where['game_id'] = $params['game_id']); + isset($params['server_id']) && !empty($params['server_id']) && ($where['server_id'] = $params['server_id']); + if (isset($params['account']) && !empty($params['account'])) { + $user = M('user', 'tab_')->field(['id'])->where('account like "' . $params['account'] . '%"')->getField('id',true); + if (!empty($user)) { + $where['user_id'] = ['in',$user]; + } else { + $where['_string'] .= ' and 1<>1'; + return $where; + } + } + isset($params['create_time_start']) && !empty($params['create_time_start']) && ( $where['_string'] .= ' and create_time >=' . strtotime($params['create_time_start'] . ' 00:00:00')); + isset($params['create_time_end']) && !empty($params['create_time_end']) && ( $where['_string'] .= ' and create_time <=' . strtotime($params['create_time_end'] . ' 23:59:59')); + if (isset($params['role_name']) && !empty($params['role_name']) ) { + $roles = M('user_play_info', 'tab_')->where(['role_name' => ['like', "%{$params['role_name']}%"]])->getField('role_id',true); + if(!empty($roles)){ + $where['role_id'] = ["in",$roles]; + }else{ + $where['_string'] .= ' and 1<>1'; + return $where; + } + } + if (isset($params['apply_name']) && !empty($params['apply_name'])) { + $promote = M('promote', 'tab_')->where(['account' => ['like', "%{$params['apply_name']}%"]])->getField('id',true); + $applyAdmins = M('ucenter_member', 'sys_')->where(['username' => ['like', "%{$params['apply_name']}%"]])->getField('id',true); + if(empty($promote) && empty($applyAdmins)){ + $where['_string'] .= ' and 1<>1'; + return $where; + } + if(!empty($promote)){ + $promote = implode(",",$promote); + if(empty($applyAdmins)){ + $where['_string'] .= " and apply_promote_id in ({$promote })"; + }else{ + $where['_string'] .= " and ( apply_promote_id in ({$promote })"; + } + } + if(!empty($applyAdmins)){ + $applyAdmins = implode(",",$applyAdmins); + if(empty($promote)){ + $where['_string'] .= " and apply_admin_id in ({$applyAdmins}) "; + }else{ + $where['_string'] .= " or apply_admin_id in ({$applyAdmins}) )"; + } + } + } + return $where; + } + + public function orders() { diff --git a/Application/Admin/View/TestingResource/dailyCount.html b/Application/Admin/View/TestingResource/dailyCount.html new file mode 100644 index 000000000..0ecce584b --- /dev/null +++ b/Application/Admin/View/TestingResource/dailyCount.html @@ -0,0 +1,302 @@ + + + + + + + + + + + + + + + + + + + +
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ + - +
+ + +
+
+ +
+   +
+ +
+   +
+ +
+ + - +
+ + +
+
+
+ 搜索 +
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
申请日期角色名称游戏名称区服名称测试账号申请人所属推广员总申请金额实发金额操作
aOh! 暂时还没有内容!
{$record.create_day_time}{$record.role_name}{$record.game_name}{$record.server_name}{$record.user_account}{$record.apply_username}{$record.promote_account}{$record.apply_amount}{$record.provide_amount} + 查看 +
+
+
+
+ + + + {$_page|default=''} +
+ +
+ + + + + + + + \ No newline at end of file diff --git a/Application/Base/Repository/TestingResourceRepository.class.php b/Application/Base/Repository/TestingResourceRepository.class.php index cdce1739b..755432e85 100644 --- a/Application/Base/Repository/TestingResourceRepository.class.php +++ b/Application/Base/Repository/TestingResourceRepository.class.php @@ -134,7 +134,7 @@ class TestingResourceRepository return M('testing_resource_batch', 'tab_')->where($conditions)->order('create_time desc'); } - private function getBatchesRelations($batches) + public function getBatchesRelations($batches) { $roles = []; $applyPromotes = []; @@ -226,6 +226,49 @@ class TestingResourceRepository } return $records; } + public function makeDailyCountData($items) + { + $result = $this->getBatchesRelations($items); + $roles = $result['roles']; + $applyPromotes = $result['applyPromotes']; + $users = $result['users']; + $promotes = $result['promotes']; + $verifyAdmins = $result['verifyAdmins']; + $applyAdmins = $result['applyAdmins']; + //获取申请人 + $records = []; + foreach ($items as $batch) { + $roleKey = $this->getGameRoleId($batch['game_id'], $batch['role_id']); + $role = isset($roles[$roleKey]) ? $roles[$roleKey] : null; + $user = $users[$batch['user_id']] ?? null; + $applyPromote = $applyPromotes[$batch['apply_promote_id']] ?? null; + $promote = $user && isset($promotes[$user['promote_id']]) ? $promotes[$user['promote_id']] : null; + $verifyAdmin = $verifyAdmins[$batch['verify_admin_id']] ?? null; + $applyAdmin = $applyAdmins[$batch['apply_admin_id']] ?? null; + $jumpParm = [ + 'game_id'=>$batch['game_id'], + 'server_id'=>$batch['server_id'], + 'account'=> $role ? $role['user_account'] : '', + 'create_time_start'=>$batch['create_day_time'], + 'create_time_end'=>$batch['create_day_time'] + ]; + $jumpUrl = U("TestingResource/batches",$jumpParm); + $records[] = [ + 'create_day_time' => $batch['create_day_time'], + 'role_name' => $role ? $role['role_name'] : '--', + 'game_name' => $role ? $role['game_name'] : '--', + 'server_name' => $role ? $role['server_name'] : '--', + 'user_account' => $role ?$role['user_account'] : '--', + 'apply_username' => $applyPromote ? $applyPromote['account'] . '[推广员]' : ($applyAdmin ? $applyAdmin['username'] . '[管理员]' : ''), + 'promote_account' => $promote['account'], + 'apply_amount' => $batch['apply_amount'], + 'provide_amount' => $batch['provide_amount'], + 'jump_url'=>$jumpUrl + ]; + } + return $records; + + } private function statByRoles($roles)