From 27665e5b14dbf8eca763c39271954e12cc8e194e Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Thu, 24 Oct 2019 20:22:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E5=B9=B3=E5=8F=B0->=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=B1=87=E6=80=BB|=E6=AF=8F=E6=97=A5=E6=A6=82?= =?UTF-8?q?=E5=86=B5->bug=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Home/Controller/QueryController.class.php | 52 ++++++++++++++----- 1 file changed, 39 insertions(+), 13 deletions(-) diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index d593ace66..a2a242e79 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1036,12 +1036,14 @@ class QueryController extends BaseController $childPromoteIds = getAllChildPromoteList(3); if (empty($childPromoteIds)) { $userPlayInfoWhere['tab_user_play_info.promote_id'] = PID; + $userPlayInfoWhere2['ti.promote_id'] = PID; $userGameLoginWhere['tab_user_game_login_record.promote_id'] = PID; $spendWhere['tab_spend.promote_id'] = PID; } else { $childPromoteIds .= ',' . PID; $userPlayInfoWhere['tab_user_play_info.promote_id'] = ['in', $childPromoteIds]; + $userPlayInfoWhere2['ti.promote_id'] = ['in', $childPromoteIds]; $userGameLoginWhere['tab_user_game_login_record.promote_id'] = ['in', $childPromoteIds]; $spendWhere['tab_spend.promote_id'] = ['in', $childPromoteIds]; } @@ -1056,12 +1058,14 @@ class QueryController extends BaseController $childPromoteIds = getAllChildPromoteList(3, $teamLeaderId); if (empty($childPromoteIds)) { $userPlayInfoWhere['tab_user_play_info.promote_id'] = $teamLeaderId; + $userPlayInfoWhere2['ti.promote_id'] = $teamLeaderId; $userGameLoginWhere['tab_user_game_login_record.promote_id'] = $teamLeaderId; $spendWhere['tab_spend.promote_id'] = $teamLeaderId; } else { $childPromoteIds = $teamLeaderId . ',' . $childPromoteIds; $userPlayInfoWhere['tab_user_play_info.promote_id'] = ['in', $childPromoteIds]; + $userPlayInfoWhere2['ti.promote_id'] = ['in', $childPromoteIds]; $userGameLoginWhere['tab_user_game_login_record.promote_id'] = ['in', $childPromoteIds]; $spendWhere['tab_spend.promote_id'] = ['in', $childPromoteIds]; } @@ -1075,12 +1079,14 @@ class QueryController extends BaseController } $userPlayInfoWhere['tab_user_play_info.promote_id'] = $promoteId; + $userPlayInfoWhere2['ti.promote_id'] = $promoteId; $userGameLoginWhere['tab_user_game_login_record.promote_id'] = $promoteId; $spendWhere['tab_spend.promote_id'] = $promoteId; } if (!empty(I('own_id'))) { $userPlayInfoWhere['tab_user_play_info.promote_id'] = I('own_id'); + $userPlayInfoWhere2['ti.promote_id'] = I('own_id'); $userGameLoginWhere['tab_user_game_login_record.promote_id'] = I('own_id'); $spendWhere['tab_spend.promote_id'] = I('own_id'); } @@ -1094,6 +1100,7 @@ class QueryController extends BaseController if (!empty(I('sdk_version'))) { $userPlayInfoWhere['tab_user_play_info.sdk_version'] = I('sdk_version'); + $userPlayInfoWhere2['ti.sdk_version'] = I('sdk_version'); $userGameLoginWhere['tab_user_game_login_record.sdk_version'] = I('sdk_version'); $spendWhere['tab_spend.sdk_version'] = I('sdk_version'); } @@ -1111,6 +1118,7 @@ class QueryController extends BaseController $spendWhere['tab_spend.pay_status'] = 1; if (!empty(I('server_id'))) { $userPlayInfoWhere['tab_user_play_info.server_id'] = I('server_id'); + $userPlayInfoWhere2['ti.server_id'] = I('server_id'); $userGameLoginWhere['tab_user_game_login_record.server_id'] = I('server_id'); $spendWhere['tab_spend.server_id'] = I('server_id'); } @@ -1135,7 +1143,6 @@ 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]]; @@ -1153,35 +1160,53 @@ class QueryController extends BaseController ->group('tab_user_play_info.game_id,tab_user_play_info.user_id') ->select());//创角用户 + $newUserNumSql = $userPlayInfoModel + ->table('tab_user_play_info as ti') + ->where($userPlayInfoWhere2) + ->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) + ->fetchSql(true) + ->count(); $newUserNumData = $userPlayInfoModel - ->field('tab_user_play_info.create_time') + ->field('tab_user_play_info.create_time,(' . $newUserNumSql . ') as num') ->join($join) - ->where($userPlayInfoWhere2) + ->where($userPlayInfoWhere) ->where($map) ->group('tab_user_play_info.user_id') - ->having('tab_user_play_info.create_time between ' . $thisDateTime . ' and ' . ($thisDateTime + 86399)) + ->having('num = 0') ->order('tab_user_play_info.id') ->select(); $list['new_user_num'] = count($newUserNumData);//新创角用户 + $newDeviceSql = $userPlayInfoModel + ->table('tab_user_play_info as ti') + ->where($userPlayInfoWhere2) + ->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) + ->fetchSql(true) + ->count(); $newDeviceData = $userPlayInfoModel - ->field('tab_user_play_info.create_time') + ->field('tab_user_play_info.create_time,(' . $newDeviceSql . ') as num') ->join($join) - ->where($userPlayInfoWhere2) + ->where($userPlayInfoWhere) ->where($map) ->group('tab_user_play_info.create_device_number') - ->having('tab_user_play_info.create_time between ' . $thisDateTime . ' and ' . ($thisDateTime + 86399)) + ->having('num = 0') ->order('tab_user_play_info.id') ->select(); $list['new_device_num'] = count($newDeviceData);//新创角设备 + $newIpNumSql = $userPlayInfoModel + ->table('tab_user_play_info as ti') + ->where($userPlayInfoWhere2) + ->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) + ->fetchSql(true) + ->count(); $newIpNumData = $userPlayInfoModel - ->field('tab_user_play_info.create_time') + ->field('tab_user_play_info.create_time,(' . $newIpNumSql . ') as num') ->join($join) - ->where($userPlayInfoWhere2) + ->where($userPlayInfoWhere) ->where($map) ->group('tab_user_play_info.create_ip') - ->having('tab_user_play_info.create_time between ' . $thisDateTime . ' and ' . ($thisDateTime + 86399)) + ->having('num = 0') ->order('tab_user_play_info.id') ->select(); $list['new_ip_num'] = count($newIpNumData);//新增创角IP @@ -1480,9 +1505,10 @@ class QueryController extends BaseController ->select(); $list['new_ip_num'] = count($newIpData);//新增创角IP - $list['login_user_num'] = $userGameLoginModel + $list['login_user_num'] = count($userGameLoginModel ->where($userGameLoginMap) - ->count('distinct tab_user_game_login_record.user_id');//登录用户数 + ->group('tab_user_game_login_record.game_id,tab_user_game_login_record.user_id') + ->select());//登录用户数 $list['spend_user_num'] = $spendModel ->where($spendMap) @@ -2011,7 +2037,7 @@ class QueryController extends BaseController $subMap['pay_status'] = 1; $subMap['pay_game_status'] = 1; $subQuery = M('spend', 'tab_')->field('game_player_id')->where($subMap)->group('game_player_id')->having($having)->buildSql(); - $map['_string'] = 'role_id in ('. $subQuery . ')'; + $map['_string'] = 'role_id in (' . $subQuery . ')'; } $query = M('user_play_info', 'tab_')->where($map); list($roles, $pagination, $count) = $this->paginate($query);