diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 243985f6b..6d8dabc7e 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -9,6 +9,7 @@ use Base\Repository\SpendRepository; use Base\Repository\UserRepository; use Base\Service\PromoteService; use GuzzleHttp\Client; +use Base\Repository\GameRepository; /** * 前台首页控制器 @@ -2818,7 +2819,10 @@ class QueryController extends BaseController $baseGameId = I('game_id', 0); $deviceType = I('device_type', ''); $timeRange = I('time_range', date('Y-m-d',strtotime('-7 day')) . ' 至 ' . date('Y-m-d')); - + $lastSortName = trim(I('last_sort_name', '')); + $sortName = trim(I('sort_name', '')); + $sort = intval(I('sort', 1)); + $start = ''; $end = ''; $timeRangeRow = explode(' 至 ', $timeRange); @@ -2834,13 +2838,11 @@ class QueryController extends BaseController $levelPromote = $this->getLevelPromote(); $queryPromote = $this->getQueryPromote($levelPromote); - $orderType = 'asc'; - $orderColumn = 'date'; - if ($dataOrder != '') - { - $dataOrder = explode(',', $dataOrder); - $orderType = $dataOrder[1]; - $orderColumn = $dataOrder[0]; + $orderColumn = $sortName; + $orderType = ($sort == 1) ? 'desc' : 'asc'; + if (!empty($sortName)) { + $orderColumn = $sortName; + $orderType = ($sort == 1) ? 'desc' : 'asc'; } $status = true; @@ -2918,8 +2920,8 @@ class QueryController extends BaseController $this->assign('baseGames', $baseGames); // $this->checkListOrCountAuthRestMap($map,[]); - $this->assign('order_type', $orderType); - $this->assign('order_column', $orderColumn); + $this->assign('sortName', $sortName); + $this->assign('sort', $sort); $this->assign('data', $data); $this->assign('start', $start); $this->assign('end', $end); @@ -2928,9 +2930,12 @@ class QueryController extends BaseController public function gameData() { - $baseGameId = I('game_id', 0); - $deviceType = I('device_type', ''); + $gameId = I('game_id', 0); + $serverId = I('server_id', ''); $timeRange = I('time_range', date('Y-m-d',strtotime('-7 day')) . ' 至 ' . date('Y-m-d')); + $lastSortName = trim(I('last_sort_name', '')); + $sortName = trim(I('sort_name', '')); + $sort = intval(I('sort', 1)); $start = ''; $end = ''; @@ -2942,12 +2947,66 @@ class QueryController extends BaseController $start = $timeRangeRow[0]; $end = $timeRangeRow[0]; } + + $spendMap = ['pay_status' => 1]; + $roleMap = []; + $map = []; + + $betweenTime = [strtotime($start . ' 00:00:00'), strtotime($start . ' 23:59:59')]; + $spendMap['pay_time'] = ['between', $betweenTime]; + $spendMap['create_time'] = ['between', $betweenTime]; + + if ($gameId > 0) { + $spendMap['game_id'] = $gameId; + $roleMap['game_id'] = $gameId; + $map['game_id'] = $gameId; + } + + if ($serverId == '') { + $spendMap['server_id'] = $serverId; + $roleMap['server_id'] = $serverId; + $map['server_id'] = $serverId; + } - $query = M('game', 'tab_')->where(); - list($games, $pagination, $count) = $this->paginate($query); + $spendSubSql = M('spend', 'tab_')->field(['game_id', 'server_id', 'sum(pay_amount) amount'])->where($spendMap)->groupBy('game_id, server_id')->select(false); + $roleSubSql = M('user_play_info', 'tab_')->field(['game_id', 'server_id', 'count(*) count'])->where($roleMap)->groupBy('game_id, server_id')->select(false); - M('spend', 'tab_')->field(['game_id', 'server_id', 'sum(pay_amount) amount'])->where()->groupBy('game_id, server_id')->select(); - M('user_play_info', 'tab_')->field(['game_id', 'server_id', 'count(*) count'])->where()->groupBy('game_id, server_id')->select(); + $query = M('server', 'tab_')->alias('a') + ->field(['a.game_id', 'a.game_name', 'a.server_id', 'a.server_name', 'b.amount', 'c.count']) + ->join('left join (' . $spendSubSql . ') b on a.game_id = b.game_id and a.server_id = b.server_id') + ->join('left join (' . $roleSubSql . ') c on a.game_id = c.game_id and a.server_id = c.server_id') + ->where($map); + $orderBy = ''; + $sortNameData = ['amount', 'count']; + if (!empty($sortName)) { + if (in_array($sortName, $sortNameData)) { + $desc = ' desc'; + $asc = ' asc'; + if ($lastSortName != $sortName) { + $sortString = $desc; + $sort = 1; + } else { + $sortString = ($sort == 1) ? $desc : $asc; + } + $orderBy = $sortName . $sortString; + } + } + + if ($orderBy) { + $query->order($orderBy); + } + list($records, $pagination, $count) = $this->paginate($query); + + $gameRepository = new GameRepository(); + + $this->assign('games', $gameRepository->getChoiceGames()); + $this->assign('servers', $gameRepository->getServersByGameId($gameId)); + $this->assign('sort', $sort); + $this->assign('sortName', $sortName); + $this->assign('records', $records); + $this->assign('start', $start); + $this->assign('end', $end); + $this->display(); } } diff --git a/Application/Home/View/default/Query/gameData.html b/Application/Home/View/default/Query/gameData.html new file mode 100644 index 000000000..396260f03 --- /dev/null +++ b/Application/Home/View/default/Query/gameData.html @@ -0,0 +1,227 @@ + + + + + + + +
+
+
+
当前位置:数据管理>用户留存率
+
+ + 角色查询 +
+
+ +
+ + + + + + + + + + + + + + + + + + + + +
游戏名称区服名称创角数 + + + + + + + + + + 消费金额 + + + + + + + + + +
+

暂无数据

+
{$vo.game_name}{$vo.server_name}{$vo.count}{$vo.amount}
+ +
+
+ + 导出 + + {$pagination} +
+
+
+
+ +
+
+
+
+ + + + + + + + \ No newline at end of file