@ -1113,163 +1113,83 @@ class QueryController extends BaseController
$dayList = $this->getDayList($begTime, $endTime + 3600 * 24);
$params['dayList'] = $dayList;
$allData['role_num'] = 0;
$allData['user_num'] = 0;
$allData['new_user_num'] = 0;
$allData['new_device_num'] = 0;
$allData['new_ip_num'] = 0;
$allData['login_user_num'] = 0;
$allData['spend_user_num'] = 0;
$allData['spend_num'] = 0;
$allData['spend_all_amount'] = 0;
$allData['spend_cash'] = 0;
$allData['spend_generic'] = 0;
$allData['pay_amount'] = 0;
$allData['spend_discount'] = 0;
$allData['spend_voucher'] = 0;
foreach ($data as & $list) {
$thisDateTime = strtotime($list['day']);
$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]];
$list['role_num'] = $userPlayInfoModel
->join($join)
->where($userPlayInfoWhere)
->where($map)
->order('play_time desc')
->count();//创角数
$list['user_num'] = count($userPlayInfoModel
->join($join)
->where($userPlayInfoWhere)
->where($map)
->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,(' . $newUserNumSql . ') as num')
->join($join)
->where($userPlayInfoWhere)
->where($map)
->group('tab_user_play_info.user_id')
->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,(' . $newDeviceSql . ') as num')
->join($join)
->where($userPlayInfoWhere)
->where($map)
->group('tab_user_play_info.create_device_number')
->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,(' . $newIpNumSql . ') as num')
->join($join)
->where($userPlayInfoWhere)
->where($map)
->group('tab_user_play_info.create_ip')
->having('num = 0')
->order('tab_user_play_info.id')
->select();
$list['new_ip_num'] = count($newIpNumData);//新增创角IP
$list['login_user_num'] = count(M('UserGameLoginRecord', 'tab_')
->join($join)
->where($userGameLoginWhere)
->where($map)
->group('tab_user_game_login_record.game_id,tab_user_game_login_record.user_id')
->select());//登录用户数
$list['spend_user_num'] = count(M('Spend', 'tab_')
->join($join)
->where($spendWhere)
->where($map)
->group('tab_spend.game_id,tab_spend.user_id')
->select());//充值人数
$list['spend_num'] = M('Spend', 'tab_')
->join($join)
->where($spendWhere)
->where($map)
->count();//充值次数
$list['spend_all_amount'] = M('Spend', 'tab_')
->join($join)
->where($spendWhere)
->where($map)
->sum('tab_spend.pay_amount');//充值总额
$list['spend_all_amount'] = empty($list['spend_all_amount']) ? 0 : $list['spend_all_amount'];
$list['spend_cash'] = M('Spend', 'tab_')
->join($join)
->where($spendWhere)
->where($map)
->where(array('tab_spend.pay_way' => ['in', '1,2,3,4,5,6']))
->sum('tab_spend.pay_amount');//现金充值
$list['spend_cash'] = empty($list['spend_cash']) ? 0 : $list['spend_cash'];
$list['spend_generic'] = M('Spend', 'tab_')
->join($join)
->where($spendWhere)
->where($map)
->where(array('tab_spend.pay_way' => 0))
->sum('tab_spend.pay_amount');//通用币
$list['spend_generic'] = empty($list['spend_generic']) ? 0 : $list['spend_generic'];
$list['spend_binding'] = M('Spend', 'tab_')
->join($join)
->where($spendWhere)
->where($map)
->where(array('tab_spend.pay_way' => -1))
->sum('tab_spend.pay_amount');//绑定币
$list['spend_binding'] = empty($list['spend_binding']) ? 0 : $list['spend_binding'];
$list['spend_discount'] = 0;//折扣币
$list['spend_voucher'] = 0;//代金券
$allData['role_num'] += $list['role_num'];
$allData['user_num'] += $list['user_num'];
$allData['new_user_num'] += $list['new_user_num'];
$allData['new_device_num'] += $list['new_device_num'];
$allData['new_ip_num'] += $list['new_ip_num'];
$allData['login_user_num'] += $list['login_user_num'];
$allData['spend_user_num'] += $list['spend_user_num'];
$allData['spend_num'] += $list['spend_num'];
$allData['spend_all_amount'] = bcadd($allData['spend_all_amount'], $list['spend_all_amount'], 2);
$allData['spend_cash'] = bcadd($allData['spend_cash'], $list['spend_cash'], 2);
$allData['spend_generic'] = bcadd($allData['spend_generic'], $list['spend_generic'], 2);
$allData['spend_binding'] = bcadd($allData['spend_binding'], $list['spend_binding'], 2);
$allData['spend_discount'] = bcadd($allData['spend_discount'], $list['spend_discount'], 2);
$allData['spend_voucher'] = bcadd($allData['spend_voucher'], $list['spend_voucher'], 2);
$summaryData['role_num'][] = $list['role_num'];
$summaryData['user_num'][] = $list['user_num'];
$summaryData['new_user_num'][] = $list['new_user_num'];
$summaryData['new_device_num'][] = $list['new_device_num'];
$summaryData['spend_user_num'][] = $list['spend_user_num'];
$summaryData['spend_all_amount'][] = $list['spend_all_amount'];
$records = [];
if (intval($endTime - $begTime) / (24 * 3600) < = 30) {
$userRepository = new UserRepository();
$spendRepository = new SpendRepository();
$roleNumList = $userRepository->getCreateRoleCountByDay($params);//创角数
$userNumList = $userRepository->getCreateRoleUserCountByDay($params);//创角用户
$newUserNumList = $userRepository->getNewCreateRoleUserCountByDay($params);//新创角用户
$newDeviceNumList = $userRepository->getNewCreateRoleDeviceCountByDay($params);//新创角设备
$newIpNumList = $userRepository->getNewCreateRoleIpCountByDay($params);//新创角IP
$loginUserNumList = $userRepository->getLoginCountGroupByDay($params);//登录用户数
$spendUserNumList = $spendRepository->getPayUserCountGroupByDay($params);//充值人数
$spendNumList = $spendRepository->getPayCountGroupByDay($params);//充值次数
$spendAllAmountList = $spendRepository->getPayAmountGroupByDayAndType($params);//充值总额
$params['pay_way'] = ['in', '1,2,3,4,5,6'];
$spendCashList = $spendRepository->getPayAmountGroupByDayAndType($params);//现金充值
$params['pay_way'] = 0;
$spendGenericList = $spendRepository->getPayAmountGroupByDayAndType($params);//通用币充值
$params['pay_way'] = -1;
$spendBindingList = $spendRepository->getPayAmountGroupByDayAndType($params);//绑定币充值
$allData['role_num'] = 0;
$allData['user_num'] = 0;
$allData['new_user_num'] = 0;
$allData['new_device_num'] = 0;
$allData['new_ip_num'] = 0;
$allData['login_user_num'] = 0;
$allData['spend_user_num'] = 0;
$allData['spend_num'] = 0;
$allData['spend_all_amount'] = 0;
$allData['spend_cash'] = 0;
$allData['spend_generic'] = 0;
$allData['spend_binding'] = 0;
$allData['spend_discount'] = 0;
$allData['spend_voucher'] = 0;
foreach ($dayList as $day) {
$date = date('Ymd', strtotime($day));
$records[] = [
'day' => $date,
'role_num' => $roleNumList[$day],
'user_num' => $userNumList[$day],
'new_user_num' => $newUserNumList[$day],
'new_device_num' => $newDeviceNumList[$day],
'new_ip_num' => $newIpNumList[$day],
'login_user_num' => $loginUserNumList[$day],
'spend_user_num' => $spendUserNumList[$day],
'spend_num' => $spendNumList[$day],
'spend_all_amount' => $spendAllAmountList[$day],
'spend_cash' => $spendCashList[$day],
'spend_generic' => $spendGenericList[$day],
'spend_binding' => $spendBindingList[$day],
'spend_discount' => 0,
'spend_voucher' => 0,
];
$allData['role_num'] += $roleNumList[$day];
$allData['user_num'] += $userNumList[$day];
$allData['new_user_num'] += $newUserNumList[$day];
$allData['new_device_num'] += $newDeviceNumList[$day];
$allData['new_ip_num'] += $newIpNumList[$day];
$allData['login_user_num'] += $loginUserNumList[$day];
$allData['spend_user_num'] += $spendUserNumList[$day];
$allData['spend_num'] += $spendNumList[$day];
$allData['spend_all_amount'] = bcadd($allData['spend_all_amount'], $spendAllAmountList[$day], 2);
$allData['spend_cash'] = bcadd($allData['spend_cash'], $spendCashList[$day], 2);
$allData['spend_generic'] = bcadd($allData['spend_generic'], $spendGenericList[$day], 2);
$allData['spend_binding'] = bcadd($allData['spend_binding'], $spendBindingList[$day], 2);
$allData['spend_discount'] = bcadd($allData['spend_discount'], 0, 2);
$allData['spend_voucher'] = bcadd($allData['spend_voucher'], 0, 2);
$summaryData['date'][] = $date;
$summaryData['role_num'][] = $roleNumList[$day];
$summaryData['user_num'][] = $userNumList[$day];
$summaryData['new_user_num'][] = $newUserNumList[$day];
$summaryData['new_device_num'][] = $newDeviceNumList[$day];
$summaryData['spend_user_num'][] = $spendUserNumList[$day];
$summaryData['spend_all_amount'][] = $spendAllAmountList[$day];
}
}
$summaryData['date'] = array_reverse($summaryData['date']);
@ -1381,7 +1301,7 @@ class QueryController extends BaseController
->join('tab_game as g on g.id = a.game_id')
->join($serverJoin)
->where($map)
->count('distinct t ab_apply .game_id');
->count('distinct a.game_id');
//分页
$parameter['p'] = I('get.p', 1);