diff --git a/Application/Home/Controller/QueryController.class.php b/Application/Home/Controller/QueryController.class.php index fc1d02789..f59133f0b 100644 --- a/Application/Home/Controller/QueryController.class.php +++ b/Application/Home/Controller/QueryController.class.php @@ -1761,8 +1761,8 @@ class QueryController extends BaseController $lastSortName = trim(I('last_sort_name', '')); $sortName = trim(I('sort_name', '')); $sort = intval(I('sort', 1)); - $sortNameData = ['recharge_cost', 'recharge_count', 'recharge_cost_today', 'unlogin_day', 'create_time', 'user_game_login_count']; - $nowTime = date('Y-m-d', time() - 3600 * 24); + $sortNameData = ['recharge_cost', 'recharge_count', 'recharge_cost_today', 'unlogin_day', 'register_time', 'user_game_login_count']; + $nowTime = date('Y-m-d'); $initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime))); $initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime'); $initEndTime = $nowTime; @@ -1771,6 +1771,7 @@ class QueryController extends BaseController $endTime = strtotime($initEndTime); $endTime += 3600 * 24; $nowTime = strtotime($nowTime); + $nowTimeEnd = $nowTime + 3600 * 24 - 1; $promote = $this->getLoginPromote(); $levelPromote = $this->getLevelPromote(); @@ -1785,28 +1786,24 @@ class QueryController extends BaseController $ids = M('promote', 'tab_')->where($map)->getField('id', true); $ids[] = $queryPromote['id']; - $map = ['uc.promote_id' => ['in', $ids]]; - $subMap = ['promote_id' => ['in', $ids]]; + $map = ['s.promote_id' => ['in', $ids]]; + $map['s.pay_status'] = 1; if ($relationGameId != 0 || $sdkVersion != 0) { $gameIds = gameSearch($relationGameId, $sdkVersion); - $map['uc.game_id'] = ['in', $gameIds]; - $subMap['game_id'] = ['in', $gameIds]; + $map['s.game_id'] = ['in', $gameIds]; } if ($serverId != 0) { - $map['uc.server_id'] = $serverId; - $subMap['server_id'] = $serverId; + $map['s.server_id'] = $serverId; } if ($roleName != '') { - $map['ui.role_name'] = ['like', $roleName . '%']; + $map['s.game_player_name'] = ['like', $roleName . '%']; } if ($userAccount != '') { - $userId = M('user', 'tab_')->where(array('account' => ['like', $userAccount . '%']))->getField('id'); - $userId = $userId ?? 0; - $map['uc.user_id'] = $userId; + $map['s.user_account'] = ['like', $userAccount . '%']; } if ($isSelf) { - $map['uc.promote_id'] = $queryPromote['id']; + $map['s.promote_id'] = $queryPromote['id']; } $subMap['create_time'] = ['between', [$begTime, $endTime - 1]]; @@ -1821,24 +1818,24 @@ class QueryController extends BaseController } $subQuery = M('user_play_data_count', 'tab_')->field('role_id') ->where($subMap) - ->group('game_id,server_id,role_id') + ->group('game_id, server_id, role_id') ->having($having) ->buildSql(); - $map['_string'] = 'ui.role_id in(' . $subQuery . ')'; + $map['_string'] = 's.game_player_id in(' . $subQuery . ')'; } - $orderBy = 'play_time desc'; + $orderBy = 'login_time desc'; if (!empty($sortName)) { if (in_array($sortName, $sortNameData)) { $desc = ' desc'; $asc = ' asc'; if ($sortName == 'unlogin_day') { - $sortName = 'play_time'; + $sortName = 'login_time'; $desc = ' asc'; $asc = ' desc'; } if ($lastSortName == 'unlogin_day') { - $lastSortName = 'play_time'; + $lastSortName = 'login_time'; } if ($lastSortName != $sortName) { $sortString = $desc; @@ -1850,22 +1847,30 @@ class QueryController extends BaseController } } - $map['uc.create_time'] = ['between', [$begTime, $endTime - 1]]; - $fieldUC = "sum(uc.recharge_cost) recharge_cost,sum(uc.recharge_count) recharge_count,sum(if(uc.create_time = {$nowTime},uc.recharge_cost,0)) as recharge_cost_today,uc.user_id"; - $fieldUI = "ui.user_account,ui.game_name,ui.role_name,ui.role_level,ui.server_name,ui.play_time,ui.play_ip,ui.promote_account,ui.sdk_version,ui.create_time"; + $map['s.pay_time'] = ['between', [$begTime, $endTime - 1]]; + $fieldS = "sum(s.pay_amount) recharge_cost, count(*) recharge_count, s.user_id, s.user_account, s.promote_account, s.game_name, s.sdk_version, s.server_name, s.game_player_name"; + $fieldUser = 'u.register_time, u.login_time'; - $loginRecordMap['lr.create_time'] = $map['uc.create_time']; - $loginRecordMap['_string'] = 'lr.user_id = uc.user_id and lr.game_id = uc.game_id'; + $spendMap['_string'] = 'today.user_id = s.user_id and today.game_id = s.game_id and today.server_id = s.server_id and today.game_player_id = s.game_player_id and today.promote_id = s.promote_id'; + $spendMap['today.pay_status'] = 1; + $spendMap['today.pay_time'] = ['between', [$nowTime, $nowTimeEnd]]; + $fieldToday = M('spend', 'tab_')->alias('today') + ->field('sum(pay_amount) as recharge_cost_today') + ->where($spendMap) + ->buildSql(); + + $loginRecordMap['lr.create_time'] = $map['s.pay_time']; + $loginRecordMap['_string'] = 'lr.user_id = s.user_id and lr.game_id = s.game_id'; $fieldLR = M('login_daily_record', 'tab_')->alias('lr') ->field("count(*) as count") ->where($loginRecordMap) ->buildSql(); - $field = $fieldUC . ',' . $fieldUI . ',' . $fieldLR . ' as user_game_login_count'; - $subQuery = M('user_play_data_count', 'tab_')->alias('uc') + $field = "$fieldS, $fieldUser, $fieldToday as recharge_cost_today, $fieldLR as user_game_login_count"; + $subQuery = M('spend', 'tab_')->alias('s') ->field($field) - ->join('left join tab_user_play_info as ui on ui.user_id = uc.user_id and ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id') + ->join('join tab_user as u on u.id = s.user_id') ->where($map) - ->group('uc.role_id,uc.server_id,uc.game_id') + ->group('s.game_player_id, s.server_id, s.game_id') ->buildSql(); $query = M()->alias('record') ->table($subQuery) @@ -1873,31 +1878,24 @@ class QueryController extends BaseController list($records, $pagination, $count) = $this->paginate($query); - $totalQuery = M('user_play_data_count', 'tab_')->alias('uc') - ->field($fieldUC) - ->join('left join tab_user_play_info as ui on ui.user_id = uc.user_id and ui.game_id = uc.game_id and uc.server_id = ui.server_id and ui.role_id = uc.role_id') - ->group('uc.role_id,uc.game_id,uc.server_id,uc.user_id') + $total = M('spend', 'tab_')->alias('s') + ->field($fieldS) ->where($map) - ->buildSql(); - $total = M()->alias('totals') - ->table($totalQuery) - ->field('sum(recharge_cost) recharge_cost,sum(recharge_count) recharge_count,sum(recharge_cost_today) as recharge_cost_today') ->find(); - foreach ($records as &$list) { - if (empty($list['user_account']) ) { - $list['user_account'] = M('user', 'tab_')->where("id = {$list['user_id']}")->getField('account'); + if (!empty($records)) { + foreach ($records as &$list) { + $list['user_account'] = empty($list['user_account']) ? '--' : encryption($list['user_account']); + $list['game_name'] = empty($list['game_name']) ? '--' : $list['game_name']; + $list['sdk_version'] = empty($list['sdk_version']) ? '--' : getSDKTypeName($list['sdk_version']); + $list['server_name'] = empty($list['server_name']) ? '--' : $list['server_name']; + $list['game_player_name'] = empty($list['game_player_name']) ? '--' : $list['game_player_name']; + $list['unlogin_day'] = empty($list['login_time']) ? '--' : intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $list['login_time']))) / (24 * 3600)); + $list['login_time'] = empty($list['login_time']) ? '--' : date('Y-m-d H:i:s', $list['login_time']); + $list['register_time'] = empty($list['register_time']) ? '--' : date('Y-m-d H:i:s', $list['register_time']); + $list['promote_account'] = empty($list['promote_account']) ? '--' : $list['promote_account']; + $list['recharge_cost_today'] = empty($list['recharge_cost_today']) ? '0.00' : $list['promote_account']; } - $list['user_account'] = empty($list['user_account']) ? '--' : $list['user_account']; - $list['game_name'] = empty($list['game_name']) ? '--' : $list['game_name']; - $list['sdk_version'] = empty($list['sdk_version']) ? '--' : getSDKTypeName($list['sdk_version']); - $list['server_name'] = empty($list['server_name']) ? '--' : $list['server_name']; - $list['role_name'] = empty($list['role_name']) ? '--' : $list['role_name']; - $list['role_level'] = empty($list['role_level']) ? '--' : $list['role_level']; - $list['unlogin_day'] = empty($list['play_time']) ? '--' : intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $list['play_time']))) / (24 * 3600)); - $list['play_time'] = empty($list['play_time']) ? '--' : date('Y-m-d H:i:s', $list['play_time']); - $list['create_time'] = empty($list['create_time']) ? '--' : date('Y-m-d H:i:s', $list['create_time']); - $list['promote_account'] = empty($list['promote_account']) ? '--' : $list['promote_account']; } } $games = get_promote_serach_game(); diff --git a/Application/Home/View/default/Query/userRecharges.html b/Application/Home/View/default/Query/userRecharges.html index 6cff84622..4b6b46a07 100644 --- a/Application/Home/View/default/Query/userRecharges.html +++ b/Application/Home/View/default/Query/userRecharges.html @@ -34,7 +34,7 @@ 玩家充值 - 说明:充值数据不包含当日 + 说明:玩家角色充值统计