数据汇总 每日概况

master
chenxiaojun 5 years ago
commit 66b86e074e

@ -642,8 +642,9 @@ class QueryController extends BaseController
$dayList = [];
do {
$dayList[] = date('Y-m-d', $beginTime);
$beginTime += 24*60*60;
} while($beginTime < $endTime);
$beginTime += 24 * 60 * 60;
} while ($beginTime < $endTime);
return $dayList;
}
@ -651,7 +652,8 @@ class QueryController extends BaseController
{
$this->meta_title = 'ARPU统计';
$defaultTime = date('Y-m-d', time() - 7*24*3600) . ' 至 ' . date('Y-m-d');
$defaultTime = date('Y-m-d', time() - 7 * 24 * 3600) . ' 至 ' . date('Y-m-d');
$defaultTime = date('Y-m-d', time() - 7 * 24 * 3600) . ' 至 ' . date('Y-m-d');
$time = I('time', $defaultTime);
$sdkVersion = I('sdk_version', 0);
@ -686,7 +688,7 @@ class QueryController extends BaseController
$timeout = 0;
$records = [];
if (intval($endTime - $beginTime)/(24*3600) <= 30) {
if (intval($endTime - $beginTime) / (24 * 3600) <= 30) {
$userRepository = new UserRepository();
$spendRepository = new SpendRepository();
$payGameCountList = $spendRepository->getPayGameCountByDay($params);
@ -697,22 +699,22 @@ class QueryController extends BaseController
$historyPayCountList = $spendRepository->getHistoryPayCountByDay($params);
$loginCountList = $userRepository->getLoginCountByDay($params);
$registerCountList = $userRepository->getRegisterCountByDay($params);
foreach ($dayList as $day) {
$records[] = [
'day' => $day,
'payGameCount' => $payGameCountList[$day],
'payUserCount' => $payUserCountList[$day],
'newPayUserCount' => $newPayUserCountList[$day],
'payAmount' => number_format($payAmountList[$day], 2),
'payAmount' => number_format($payAmountList[$day], 2),
'newPayAmount' => number_format($newPayAmountList[$day], 2),
'historyPayCount' => $historyPayCountList[$day],
'loginCount' => $loginCountList[$day],
'registerCount' => $registerCountList[$day],
'payRate' => $loginCountList[$day] == 0 ? '--' : round($payUserCountList[$day]/$loginCountList[$day]*100, 2) . '%',
'payRate' => $loginCountList[$day] == 0 ? '--' : round($payUserCountList[$day] / $loginCountList[$day] * 100, 2) . '%',
'ratentionOneDay' => '--',
'arpu' => $loginCountList[$day] == 0 ? '0.00' : number_format(round($payAmountList[$day]/$loginCountList[$day], 2), 2),
'arppu' => $payUserCountList[$day] == 0 ? '0.00' : number_format(round($payAmountList[$day]/$payUserCountList[$day], 2), 2),
'arpu' => $loginCountList[$day] == 0 ? '0.00' : number_format(round($payAmountList[$day] / $loginCountList[$day], 2), 2),
'arppu' => $payUserCountList[$day] == 0 ? '0.00' : number_format(round($payAmountList[$day] / $payUserCountList[$day], 2), 2),
];
}
} else {
@ -1055,11 +1057,12 @@ class QueryController extends BaseController
->where($map)
->order('play_time desc')
->count();//创角数
$list['user_num'] = $userPlayInfoModel
$list['user_num'] = count($userPlayInfoModel
->join($join)
->where($userPlayInfoWhere)
->where($map)
->count('distinct tab_user_play_info.user_id');//创角用户
->group('tab_user_play_info.game_id,tab_user_play_info.user_id')
->select());//创角用户
$newUserNumData = $userPlayInfoModel
->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.user_id) as num')
@ -1085,17 +1088,19 @@ class QueryController extends BaseController
->find();
$list['new_ip_num'] = empty($newIpNumData['num']) ? 0 : $newIpNumData['num'];//新增创角IP
$list['login_user_num'] = M('UserGameLoginRecord', 'tab_')
$list['login_user_num'] = count(M('UserGameLoginRecord', 'tab_')
->join($join)
->where($userGameLoginWhere)
->where($map)
->count('distinct tab_user_game_login_record.user_id');//登录用户数
$list['spend_user_num'] = M('Spend', 'tab_')
->field('tab_spend.id')
->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)
->count('distinct tab_spend.user_id');//充值人数
->group('tab_spend.game_id,tab_spend.user_id')
->select());//充值人数
$list['spend_num'] = M('Spend', 'tab_')
->join($join)
->where($spendWhere)
@ -1274,6 +1279,7 @@ class QueryController extends BaseController
$userGameLoginMap['tab_user_game_login_record.login_time'] = ['between', [$begTime, $endTime + 86399]];
$spendMap['tab_spend.pay_time'] = ['between', [$begTime, $endTime + 86399]];
$spendMap['tab_spend.pay_status'] = 1;
$spendMap2 = $spendMap;
// $spendWhere['_string'] = 'tab_spend.game_id = tab_apply.game_id';
// $spendMap['_complex'] = $spendWhere;
@ -1319,7 +1325,13 @@ class QueryController extends BaseController
$parameter['begtime'] = $initBegTime;
$parameter['endtime'] = $initEndTime;
$allData = [];
$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;
if (!empty($data)) {
foreach ($data as &$list) {
$userPlayInfoMap['tab_user_play_info.game_id'] = $list['game_id'];
@ -1389,36 +1401,18 @@ class QueryController extends BaseController
->where($spendMap)
->where(array('tab_spend.pay_way' => -1))
->sum('tab_spend.pay_amount');//绑定币
}
$allData['spend_num'] = M('Spend', 'tab_')
->where($spendMap2)
->count();//充值次数
$allData['spend_all_amount'] = M('Spend', 'tab_')
->where($spendMap2)
->sum('tab_spend.pay_amount');//充值总额
$allData['spend_all_amount'] = empty($allData['spend_all_amount']) ? 0 : $allData['spend_all_amount'];
$allData['spend_cash'] = M('Spend', 'tab_')
->where($spendMap2)
->where(array('tab_spend.pay_way' => ['in', '1,2,3,4,5,6']))
->sum('tab_spend.pay_amount');//现金充值
$allData['spend_cash'] = empty($allData['spend_cash']) ? 0 : $allData['spend_cash'];
$list['spend_discount'] = 0;//折扣币
$list['spend_voucher'] = 0;//代金券
$allData['spend_generic'] = M('Spend', 'tab_')
->where($spendMap2)
->where(array('tab_spend.pay_way' => 0))
->sum('tab_spend.pay_amount');//通用币
$allData['spend_generic'] = empty($allData['spend_generic']) ? 0 : $allData['spend_generic'];
$allData['spend_binding'] = M('Spend', 'tab_')
->where($spendMap2)
->where(array('tab_spend.pay_way' => -1))
->sum('tab_spend.pay_amount');//绑定币
$allData['spend_binding'] = empty($allData['spend_binding']) ? 0 : $allData['spend_binding'];
$allData['spend_discount'] = 0;//折扣币
$allData['spend_voucher'] = 0;//代金券
$allData['spend_num'] += $list['spend_num'];
$allData['spend_all_amount'] += $list['spend_all_amount'];
$allData['spend_cash'] += $list['spend_cash'];
$allData['spend_generic'] += $list['spend_generic'];
$allData['spend_binding'] += $list['spend_binding'];
$allData['spend_discount'] += $list['spend_discount'];
$allData['spend_voucher'] += $list['spend_voucher'];
}
}
$serverData = $this->getServer(I('relation_game_id'), I('sdk_version'));
@ -2010,7 +2004,7 @@ class QueryController extends BaseController
$gameId = I('game_id', 0);
$serverId = I('server_id', 0);
$parentId = I('parent_id', 0);
$loginPromote = $this->getLoginPromote();
$promote = null;
@ -2021,7 +2015,7 @@ class QueryController extends BaseController
}
$games = $this->getGamesByPromote($promote);
$subPromotes = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $promote['id']])->select();
$query = M('promote', 'tab_')->field(['id', 'account', 'real_name'])->where(['parent_id' => $promote['id']]);
@ -2053,8 +2047,7 @@ class QueryController extends BaseController
list($beginTime, $endTime) = $this->getBetweenTime($time);
$params['begin_time'] = $beginTime;
$params['end_time'] = $endTime;
$promoteRepository = new PromoteRepository();
$createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params);
$createRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds($ids, $params);

Loading…
Cancel
Save