From e53268815c12ba1edc970c3b1ce4de78969e1c83 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Mon, 14 Oct 2019 14:40:56 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=B1=87=E6=80=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Controller/QueryController.class.php | 68 ++++++++++--------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index 600920294..a2753514f 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1188,10 +1188,10 @@ class QueryController extends BaseController $begTime = strtotime($initBegTime); $endTime = strtotime($initEndTime); + $userPlayInfoMap['tab_user_play_info.create_time'] = ['between', [$begTime, $endTime + 86399]]; + $userPlayInfoMap2 = $userPlayInfoMap; $userPlayInfoWhere['_string'] = 'tab_user_play_info.game_id = tab_apply.game_id'; $userPlayInfoMap['_complex'] = $userPlayInfoWhere; - $userPlayInfoMap2 = $userPlayInfoMap; - $userPlayInfoMap['tab_user_play_info.create_time'] = ['between', [$begTime, $endTime + 86399]]; $userGameLoginWhere['_string'] = 'tab_user_game_login_record.game_id = tab_apply.game_id'; $userGameLoginMap['_complex'] = $userGameLoginWhere; @@ -1218,36 +1218,6 @@ class QueryController extends BaseController ->count('distinct tab_user_play_info.user_id'); $userNumSql = ',(' . $userNumSql . ') as user_num';//创角用户 - $newUserNumSql = $userPlayInfoModel - ->field('tab_user_play_info.create_time') - ->where($userPlayInfoMap2) - ->group('tab_user_play_info.user_id') - ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) - ->order('tab_user_play_info.id') - ->fetchSql(true) - ->select(); - $newUserNumSql = ',count((' . $newUserNumSql . ')) as new_user_num';//新创角用户 - - $newDeviceSql = $userPlayInfoModel - ->field('tab_user_play_info.create_time') - ->where($userPlayInfoMap2) - ->group('tab_user_play_info.create_device_number') - ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) - ->order('tab_user_play_info.id') - ->fetchSql(true) - ->select(); - $newDeviceSql = ',count((' . $newDeviceSql . ')) as new_device_num';//新创角设备 - - $newIpSql = $userPlayInfoModel - ->field('tab_user_play_info.create_time') - ->where($userPlayInfoMap2) - ->group('tab_user_play_info.create_ip') - ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) - ->order('tab_user_play_info.id') - ->fetchSql(true) - ->select(); - $newIpSql = ',count((' . $newIpSql . ')) as new_ip_num';//新增创角IP - $loginUserNumSql = $userGameLoginModel ->where($userGameLoginMap) ->fetchSql(true) @@ -1293,7 +1263,7 @@ class QueryController extends BaseController ->sum('tab_spend.pay_amount'); $spendBindingSql = ',(' . $spendBindingSql . ') as spend_binding';//绑定币 -// var_dump($spendCashSql); +// var_dump($newUserNumSql); // die; $field = 'tab_apply.game_id,tab_game.game_name,tab_game.sdk_version'; @@ -1305,9 +1275,13 @@ class QueryController extends BaseController ->where($map) ->group('tab_apply.game_id') ->order('tab_game.sort desc,tab_game.id desc') +// ->fetchSql(true) ->page($page, $row) ->select(); +// var_dump($data); +// die; + $count = M('Apply', 'tab_') ->join('tab_game on tab_apply.game_id = tab_game.id') ->join($serverJoin)//关联区服表 @@ -1328,6 +1302,34 @@ class QueryController extends BaseController $allData = []; if (!empty($data)) { + foreach ($data as $key => $list) { + $userPlayInfoMap2['tab_user_play_info.game_id'] = $list['game_id']; + + $newUserNumData = $userPlayInfoModel + ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.id) as num') + ->where($userPlayInfoMap2) + ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) + ->order('tab_user_play_info.id') + ->find(); + $data[$key]['new_user_num'] = empty($newUserNumData['num']) ? 0 : $newUserNumData['num'];//新创角用户 + + $newDeviceData = $userPlayInfoModel + ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.create_device_number) as num') + ->where($userPlayInfoMap2) + ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) + ->order('tab_user_play_info.id') + ->find(); + $data[$key]['new_device_num'] = empty($newDeviceData['num']) ? 0 : $newDeviceData['num'];//新创角设备 + + $newIpData = $userPlayInfoModel + ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.create_ip) as num') + ->where($userPlayInfoMap2) + ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) + ->order('tab_user_play_info.id') + ->select(); + $data[$key]['new_ip_num'] = empty($newIpData['num']) ? 0 : $newIpData['num'];//新增创角IP + } + $allData['spend_num'] = M('Spend', 'tab_') ->where($spendMap2) ->count();//充值次数 From c678968253fd4a142dde8035f34117256b25a43e Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Mon, 14 Oct 2019 14:41:18 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=B1=87=E6=80=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Home/Controller/QueryController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index a2753514f..d5e22bea6 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1267,7 +1267,7 @@ class QueryController extends BaseController // die; $field = 'tab_apply.game_id,tab_game.game_name,tab_game.sdk_version'; - $field .= $serverField . $roleNumSql . $userNumSql . $newUserNumSql . $newDeviceSql . $newIpSql . $loginUserNumSql . $spendUserNumSql . $spendNumSql . $spendAllAmountSql . $spendCashSql . $spendGenericSql . $spendBindingSql; + $field .= $serverField . $roleNumSql . $userNumSql . $loginUserNumSql . $spendUserNumSql . $spendNumSql . $spendAllAmountSql . $spendCashSql . $spendGenericSql . $spendBindingSql; $data = M('Apply', 'tab_') ->field($field) ->join('tab_game on tab_apply.game_id = tab_game.id') From a5bd8c25c46e0c7c29c749042bea84a57fda2e1b Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Mon, 14 Oct 2019 16:22:58 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=B1=87=E6=80=BB=20?= =?UTF-8?q?=E6=AF=8F=E6=97=A5=E6=A6=82=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Controller/QueryController.class.php | 84 ++++++++----------- .../Home/View/default/Query/dailySummary.html | 2 +- .../Home/View/default/Query/summary.html | 2 +- 3 files changed, 38 insertions(+), 50 deletions(-) diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index d5e22bea6..beb2d0db9 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -927,7 +927,6 @@ class QueryController extends BaseController $userPlayInfoModel = M('UserPlayInfo', 'tab_'); - $newWhere = ''; $begTime = strtotime($initBegTime); $endTime = strtotime($initEndTime); $spendWhere['tab_spend.pay_status'] = 1; @@ -935,7 +934,6 @@ class QueryController extends BaseController $userPlayInfoWhere['tab_user_play_info.server_id'] = I('server_id'); $userGameLoginWhere['tab_user_game_login_record.server_id'] = I('server_id'); $spendWhere['tab_spend.server_id'] = I('server_id'); - $newWhere = ' and ti.server_id = ' . I('server_id'); } $summaryData = []; @@ -958,6 +956,7 @@ class QueryController extends BaseController $allData['spend_voucher'] = 0; foreach ($data as &$list) { $thisDateTime = strtotime($list['day']); + $userPlayInfoWhere2 = $userPlayInfoWhere; $userPlayInfoWhere['tab_user_play_info.create_time'] = ['between', [$thisDateTime, $thisDateTime + 86399]]; $userGameLoginWhere['tab_user_game_login_record.login_time'] = ['between', [$thisDateTime, $thisDateTime + 86399]]; $spendWhere['tab_spend.pay_time'] = ['between', [$thisDateTime, $thisDateTime + 86399]]; @@ -968,58 +967,47 @@ class QueryController extends BaseController ->where($map) ->order('play_time desc') ->count();//创角数 - $list['user_num'] = count($userPlayInfoModel - ->field('tab_user_play_info.id') + $list['user_num'] = $userPlayInfoModel ->join($join) ->where($userPlayInfoWhere) ->where($map) - ->group('tab_user_play_info.user_id') - ->select());//创角用户 + ->count('distinct tab_user_play_info.user_id');//创角用户 - $newUserSql = '(select count(ti.id) from tab_user_play_info as ti where ti.user_id = tab_user_play_info.user_id and ti.game_id = tab_user_play_info.game_id and ti.create_time < ' . $thisDateTime . $newWhere . ') as old_num'; - $list['new_user_num'] = count($userPlayInfoModel - ->field($newUserSql) - ->join($join) - ->where($userPlayInfoWhere) - ->where($map) - ->group('tab_user_play_info.user_id') - ->having('old_num = 0') - ->select());//新创角用户 + $newUserNumData = $userPlayInfoModel + ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.user_id) as num') + ->where($userPlayInfoWhere2) + ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) + ->order('tab_user_play_info.id') + ->find(); + $list['new_user_num'] = empty($newUserNumData['num']) ? 0 : $newUserNumData['num'];//新创角用户 - $newDeviceSql = '(select count(ti.id) from tab_user_play_info as ti where ti.create_device_number = tab_user_play_info.create_device_number and ti.game_id = tab_user_play_info.game_id and ti.create_time < ' . $thisDateTime . $newWhere . ') as old_num'; - $list['new_device_num'] = count($userPlayInfoModel - ->field($newDeviceSql) - ->join($join) - ->where($userPlayInfoWhere) - ->where($map) - ->group('tab_user_play_info.create_device_number') - ->having('old_num = 0') - ->select());//新创角设备 + $newDeviceData = $userPlayInfoModel + ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.create_device_number) as num') + ->where($userPlayInfoWhere2) + ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) + ->order('tab_user_play_info.id') + ->find(); + $list['new_device_num'] = empty($newDeviceData['num']) ? 0 : $newDeviceData['num'];//新创角设备 - $newIpSql = '(select count(ti.id) from tab_user_play_info as ti where ti.create_ip = tab_user_play_info.create_ip and ti.game_id = tab_user_play_info.game_id and ti.create_time < ' . $thisDateTime . $newWhere . ') as old_num'; - $list['new_ip_num'] = count($userPlayInfoModel - ->field($newIpSql) - ->join($join) - ->where($userPlayInfoWhere) - ->where($map) - ->group('tab_user_play_info.create_ip') - ->having('old_num = 0') - ->fetchSql(true) - ->select());//新增创角IP - $list['login_user_num'] = count(M('UserGameLoginRecord', 'tab_') - ->field('tab_user_game_login_record.id') + $newIpNumData = $userPlayInfoModel + ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.create_ip) as num') + ->where($userPlayInfoWhere2) + ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) + ->order('tab_user_play_info.id') + ->find(); + $list['new_ip_num'] = empty($newIpNumData['num']) ? 0 : $newIpNumData['num'];//新增创角IP + + $list['login_user_num'] = M('UserGameLoginRecord', 'tab_') ->join($join) ->where($userGameLoginWhere) ->where($map) - ->group('user_id') - ->select());//登录用户数 - $list['spend_user_num'] = count(M('Spend', 'tab_') + ->count('distinct tab_user_game_login_record.user_id');//登录用户数 + $list['spend_user_num'] = M('Spend', 'tab_') ->field('tab_spend.id') ->join($join) ->where($spendWhere) ->where($map) - ->group('tab_spend.user_id') - ->select());//充值人数 + ->count('distinct tab_spend.user_id');//充值人数 $list['spend_num'] = M('Spend', 'tab_') ->join($join) ->where($spendWhere) @@ -1302,16 +1290,16 @@ class QueryController extends BaseController $allData = []; if (!empty($data)) { - foreach ($data as $key => $list) { + foreach ($data as &$list) { $userPlayInfoMap2['tab_user_play_info.game_id'] = $list['game_id']; $newUserNumData = $userPlayInfoModel - ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.id) as num') + ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.user_id) as num') ->where($userPlayInfoMap2) ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) ->order('tab_user_play_info.id') ->find(); - $data[$key]['new_user_num'] = empty($newUserNumData['num']) ? 0 : $newUserNumData['num'];//新创角用户 + $list['new_user_num'] = empty($newUserNumData['num']) ? 0 : $newUserNumData['num'];//新创角用户 $newDeviceData = $userPlayInfoModel ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.create_device_number) as num') @@ -1319,15 +1307,15 @@ class QueryController extends BaseController ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) ->order('tab_user_play_info.id') ->find(); - $data[$key]['new_device_num'] = empty($newDeviceData['num']) ? 0 : $newDeviceData['num'];//新创角设备 + $list['new_device_num'] = empty($newDeviceData['num']) ? 0 : $newDeviceData['num'];//新创角设备 $newIpData = $userPlayInfoModel ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.create_ip) as num') ->where($userPlayInfoMap2) ->having('tab_user_play_info.create_time between ' . $begTime . ' and ' . ($endTime + 86399)) ->order('tab_user_play_info.id') - ->select(); - $data[$key]['new_ip_num'] = empty($newIpData['num']) ? 0 : $newIpData['num'];//新增创角IP + ->find(); + $list['new_ip_num'] = empty($newIpData['num']) ? 0 : $newIpData['num'];//新增创角IP } $allData['spend_num'] = M('Spend', 'tab_') @@ -1514,7 +1502,7 @@ class QueryController extends BaseController $where['show_status'] = 1; $serverData = M('Server', 'tab_') - ->field('id,server_name') + ->field('server_id,server_name') ->where($where) ->select(); $result['status'] = 1; diff --git a/Application/Home/View/default/Query/dailySummary.html b/Application/Home/View/default/Query/dailySummary.html index 96197f933..0f2fc4022 100644 --- a/Application/Home/View/default/Query/dailySummary.html +++ b/Application/Home/View/default/Query/dailySummary.html @@ -118,7 +118,7 @@ diff --git a/Application/Home/View/default/Query/summary.html b/Application/Home/View/default/Query/summary.html index 6444d4133..7932c5592 100644 --- a/Application/Home/View/default/Query/summary.html +++ b/Application/Home/View/default/Query/summary.html @@ -108,7 +108,7 @@