数据汇总 每日概况

master
chenxiaojun 5 years ago
commit 66b86e074e

@ -642,8 +642,9 @@ class QueryController extends BaseController
$dayList = []; $dayList = [];
do { do {
$dayList[] = date('Y-m-d', $beginTime); $dayList[] = date('Y-m-d', $beginTime);
$beginTime += 24*60*60; $beginTime += 24 * 60 * 60;
} while($beginTime < $endTime); } while ($beginTime < $endTime);
return $dayList; return $dayList;
} }
@ -651,7 +652,8 @@ class QueryController extends BaseController
{ {
$this->meta_title = 'ARPU统计'; $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); $time = I('time', $defaultTime);
$sdkVersion = I('sdk_version', 0); $sdkVersion = I('sdk_version', 0);
@ -686,7 +688,7 @@ class QueryController extends BaseController
$timeout = 0; $timeout = 0;
$records = []; $records = [];
if (intval($endTime - $beginTime)/(24*3600) <= 30) { if (intval($endTime - $beginTime) / (24 * 3600) <= 30) {
$userRepository = new UserRepository(); $userRepository = new UserRepository();
$spendRepository = new SpendRepository(); $spendRepository = new SpendRepository();
$payGameCountList = $spendRepository->getPayGameCountByDay($params); $payGameCountList = $spendRepository->getPayGameCountByDay($params);
@ -709,10 +711,10 @@ class QueryController extends BaseController
'historyPayCount' => $historyPayCountList[$day], 'historyPayCount' => $historyPayCountList[$day],
'loginCount' => $loginCountList[$day], 'loginCount' => $loginCountList[$day],
'registerCount' => $registerCountList[$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' => '--', 'ratentionOneDay' => '--',
'arpu' => $loginCountList[$day] == 0 ? '0.00' : number_format(round($payAmountList[$day]/$loginCountList[$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), 'arppu' => $payUserCountList[$day] == 0 ? '0.00' : number_format(round($payAmountList[$day] / $payUserCountList[$day], 2), 2),
]; ];
} }
} else { } else {
@ -1055,11 +1057,12 @@ class QueryController extends BaseController
->where($map) ->where($map)
->order('play_time desc') ->order('play_time desc')
->count();//创角数 ->count();//创角数
$list['user_num'] = $userPlayInfoModel $list['user_num'] = count($userPlayInfoModel
->join($join) ->join($join)
->where($userPlayInfoWhere) ->where($userPlayInfoWhere)
->where($map) ->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 $newUserNumData = $userPlayInfoModel
->field('tab_user_play_info.create_time,count(distinct tab_user_play_info.user_id) as num') ->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(); ->find();
$list['new_ip_num'] = empty($newIpNumData['num']) ? 0 : $newIpNumData['num'];//新增创角IP $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) ->join($join)
->where($userGameLoginWhere) ->where($userGameLoginWhere)
->where($map) ->where($map)
->count('distinct tab_user_game_login_record.user_id');//登录用户数 ->group('tab_user_game_login_record.game_id,tab_user_game_login_record.user_id')
$list['spend_user_num'] = M('Spend', 'tab_') ->select());//登录用户数
->field('tab_spend.id')
$list['spend_user_num'] = count(M('Spend', 'tab_')
->join($join) ->join($join)
->where($spendWhere) ->where($spendWhere)
->where($map) ->where($map)
->count('distinct tab_spend.user_id');//充值人数 ->group('tab_spend.game_id,tab_spend.user_id')
->select());//充值人数
$list['spend_num'] = M('Spend', 'tab_') $list['spend_num'] = M('Spend', 'tab_')
->join($join) ->join($join)
->where($spendWhere) ->where($spendWhere)
@ -1274,6 +1279,7 @@ class QueryController extends BaseController
$userGameLoginMap['tab_user_game_login_record.login_time'] = ['between', [$begTime, $endTime + 86399]]; $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_time'] = ['between', [$begTime, $endTime + 86399]];
$spendMap['tab_spend.pay_status'] = 1;
$spendMap2 = $spendMap; $spendMap2 = $spendMap;
// $spendWhere['_string'] = 'tab_spend.game_id = tab_apply.game_id'; // $spendWhere['_string'] = 'tab_spend.game_id = tab_apply.game_id';
// $spendMap['_complex'] = $spendWhere; // $spendMap['_complex'] = $spendWhere;
@ -1319,7 +1325,13 @@ class QueryController extends BaseController
$parameter['begtime'] = $initBegTime; $parameter['begtime'] = $initBegTime;
$parameter['endtime'] = $initEndTime; $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)) { if (!empty($data)) {
foreach ($data as &$list) { foreach ($data as &$list) {
$userPlayInfoMap['tab_user_play_info.game_id'] = $list['game_id']; $userPlayInfoMap['tab_user_play_info.game_id'] = $list['game_id'];
@ -1389,36 +1401,18 @@ class QueryController extends BaseController
->where($spendMap) ->where($spendMap)
->where(array('tab_spend.pay_way' => -1)) ->where(array('tab_spend.pay_way' => -1))
->sum('tab_spend.pay_amount');//绑定币 ->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'];
$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_') $list['spend_discount'] = 0;//折扣币
->where($spendMap2) $list['spend_voucher'] = 0;//代金券
->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_num'] += $list['spend_num'];
$allData['spend_voucher'] = 0;//代金券 $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')); $serverData = $this->getServer(I('relation_game_id'), I('sdk_version'));
@ -2054,7 +2048,6 @@ class QueryController extends BaseController
$params['begin_time'] = $beginTime; $params['begin_time'] = $beginTime;
$params['end_time'] = $endTime; $params['end_time'] = $endTime;
$promoteRepository = new PromoteRepository(); $promoteRepository = new PromoteRepository();
$createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params); $createRoleCountList = $promoteRepository->getCreateRoleCountByIds($ids, $params);
$createRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds($ids, $params); $createRoleUserCountList = $promoteRepository->getCreateRoleUserCountByIds($ids, $params);

Loading…
Cancel
Save