数据汇总

master
chenxiaojun 5 years ago
parent 615e6f660d
commit e53268815c

@ -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();//充值次数

Loading…
Cancel
Save