diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index beb2d0db9..2e97495b4 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1176,86 +1176,29 @@ 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; + $userPlayInfoMap['tab_user_play_info.create_time'] = ['between', [$begTime, $endTime + 86399]]; +// $userPlayInfoWhere['_string'] = 'tab_user_play_info.game_id = tab_apply.game_id'; +// $userPlayInfoMap['_complex'] = $userPlayInfoWhere; - $userGameLoginWhere['_string'] = 'tab_user_game_login_record.game_id = tab_apply.game_id'; - $userGameLoginMap['_complex'] = $userGameLoginWhere; +// $userGameLoginWhere['_string'] = 'tab_user_game_login_record.game_id = tab_apply.game_id'; +// $userGameLoginMap['_complex'] = $userGameLoginWhere; $userGameLoginMap['tab_user_game_login_record.login_time'] = ['between', [$begTime, $endTime + 86399]]; $spendMap['tab_spend.pay_time'] = ['between', [$begTime, $endTime + 86399]]; $spendMap2 = $spendMap; - $spendWhere['_string'] = 'tab_spend.game_id = tab_apply.game_id'; - $spendMap['_complex'] = $spendWhere; +// $spendWhere['_string'] = 'tab_spend.game_id = tab_apply.game_id'; +// $spendMap['_complex'] = $spendWhere; $userPlayInfoModel = M('UserPlayInfo', 'tab_'); $userGameLoginModel = M('UserGameLoginRecord', 'tab_'); $spendModel = M('Spend', 'tab_'); - $roleNumSql = $userPlayInfoModel - ->where($userPlayInfoMap) - ->fetchSql(true) - ->count(); - $roleNumSql = ',(' . $roleNumSql . ') as role_num';//创角数 - - $userNumSql = $userPlayInfoModel - ->where($userPlayInfoMap) - ->fetchSql(true) - ->count('distinct tab_user_play_info.user_id'); - $userNumSql = ',(' . $userNumSql . ') as user_num';//创角用户 - - $loginUserNumSql = $userGameLoginModel - ->where($userGameLoginMap) - ->fetchSql(true) - ->count('distinct tab_user_game_login_record.user_id'); - $loginUserNumSql = ',(' . $loginUserNumSql . ') as login_user_num';//登录用户数 - - $spendUserNumSql = $spendModel - ->where($spendMap) - ->fetchSql(true) - ->count('distinct tab_spend.user_id'); - $spendUserNumSql = ',(' . $spendUserNumSql . ') as spend_user_num';//充值人数 - - $spendNumSql = $spendModel - ->where($spendMap) - ->fetchSql(true) - ->count(); - $spendNumSql = ',(' . $spendNumSql . ') as spend_num';//充值次数 - - $spendAllAmountSql = $spendModel - ->where($spendMap) - ->fetchSql(true) - ->sum('tab_spend.pay_amount'); - $spendAllAmountSql = ',(' . $spendAllAmountSql . ') as spend_all_amount';//充值总额 - - $spendCashSql = $spendModel - ->where($spendMap) - ->where(array('tab_spend.pay_way' => ['in', '1,2,3,4,5,6'])) - ->fetchSql(true) - ->sum('tab_spend.pay_amount'); - $spendCashSql = ',(' . $spendCashSql . ') as spend_cash';//现金充值 - - $spendGenericSql = $spendModel - ->where($spendMap) - ->where(array('tab_spend.pay_way' => 0)) - ->fetchSql(true) - ->sum('tab_spend.pay_amount'); - $spendGenericSql = ',(' . $spendGenericSql . ') as spend_generic';//通用币 - - $spendBindingSql = $spendModel - ->where($spendMap) - ->where(array('tab_spend.pay_way' => -1)) - ->fetchSql(true) - ->sum('tab_spend.pay_amount'); - $spendBindingSql = ',(' . $spendBindingSql . ') as spend_binding';//绑定币 - // var_dump($newUserNumSql); // die; $field = 'tab_apply.game_id,tab_game.game_name,tab_game.sdk_version'; - $field .= $serverField . $roleNumSql . $userNumSql . $loginUserNumSql . $spendUserNumSql . $spendNumSql . $spendAllAmountSql . $spendCashSql . $spendGenericSql . $spendBindingSql; + $field .= $serverField; $data = M('Apply', 'tab_') ->field($field) ->join('tab_game on tab_apply.game_id = tab_game.id') @@ -1291,7 +1234,18 @@ class QueryController extends BaseController $allData = []; if (!empty($data)) { foreach ($data as &$list) { + $userPlayInfoMap['tab_user_play_info.game_id'] = $list['game_id']; $userPlayInfoMap2['tab_user_play_info.game_id'] = $list['game_id']; + $userGameLoginMap['tab_user_game_login_record.game_id'] = $list['game_id']; + $spendMap['tab_spend.game_id'] = $list['game_id']; + + $list['role_num'] = $userPlayInfoModel + ->where($userPlayInfoMap) + ->count();//创角数 + + $list['user_num'] = $userPlayInfoModel + ->where($userPlayInfoMap) + ->count('distinct tab_user_play_info.user_id');//创角用户 $newUserNumData = $userPlayInfoModel ->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.user_id) as num') @@ -1316,6 +1270,37 @@ class QueryController extends BaseController ->order('tab_user_play_info.id') ->find(); $list['new_ip_num'] = empty($newIpData['num']) ? 0 : $newIpData['num'];//新增创角IP + + $list['login_user_num'] = $userGameLoginModel + ->where($userGameLoginMap) + ->count('distinct tab_user_game_login_record.user_id');//登录用户数 + + $list['spend_user_num'] = $spendModel + ->where($spendMap) + ->count('distinct tab_spend.user_id');//充值人数 + + $list['spend_num'] = $spendModel + ->where($spendMap) + ->count();//充值次数 + + $list['spend_all_amount'] = $spendModel + ->where($spendMap) + ->sum('tab_spend.pay_amount');//充值总额 + + $list['spend_cash'] = $spendModel + ->where($spendMap) + ->where(array('tab_spend.pay_way' => ['in', '1,2,3,4,5,6'])) + ->sum('tab_spend.pay_amount');//现金充值 + + $list['spend_generic'] = $spendModel + ->where($spendMap) + ->where(array('tab_spend.pay_way' => 0)) + ->sum('tab_spend.pay_amount');//通用币 + + $list['spend_binding'] = $spendModel + ->where($spendMap) + ->where(array('tab_spend.pay_way' => -1)) + ->sum('tab_spend.pay_amount');//绑定币 } $allData['spend_num'] = M('Spend', 'tab_')