Merge branch 'dev' of 47.111.118.107:/srv/git/platform into dev

master
zhanglingsheng 5 years ago
commit 9c89f1bcd3

@ -923,15 +923,17 @@ public function auto_rrdae(){
$map['pay_status'] = 1; $map['pay_status'] = 1;
$map['pay_game_status'] = 1; $map['pay_game_status'] = 1;
$map['game_player_id'] = ['gt', 0]; $map['game_player_id'] = ['gt', 0];
$field = 'FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day,game_id,server_id,game_player_id,sum(pay_amount) as recharge_cost,count(id) as recharge_count'; $field = 'FROM_UNIXTIME(pay_time, "%Y-%m-%d") as day,promote_id,user_id,game_id,server_id,game_player_id,sum(pay_amount) as recharge_cost,count(id) as recharge_count';
$spendData = M('spend', 'tab_')->field($field) $spendData = M('spend', 'tab_')->field($field)
->where($map) ->where($map)
->group('day,game_player_id,server_id,game_id') ->group('day,game_player_id,server_id,game_id,user_id,promote_id')
->select(); ->select();
if (!empty($spendData)) { if (!empty($spendData)) {
$data = []; $data = [];
foreach ($spendData as $list) { foreach ($spendData as $list) {
$save['promote_id'] = $list['promote_id'];
$save['user_id'] = $list['user_id'];
$save['game_id'] = $list['game_id']; $save['game_id'] = $list['game_id'];
$save['server_id'] = $list['server_id']; $save['server_id'] = $list['server_id'];
$save['role_id'] = $list['game_player_id']; $save['role_id'] = $list['game_player_id'];

@ -1726,6 +1726,7 @@ class QueryController extends BaseController
$begTime = strtotime($initBegTime); $begTime = strtotime($initBegTime);
$endTime = strtotime($initEndTime); $endTime = strtotime($initEndTime);
$endTime += 3600 * 24; $endTime += 3600 * 24;
$nowTime = strtotime(date('Y-m-d 00:00:00', time()));
$promote = $this->getLoginPromote(); $promote = $this->getLoginPromote();
$levelPromote = $this->getLevelPromote(); $levelPromote = $this->getLevelPromote();
@ -1735,50 +1736,38 @@ class QueryController extends BaseController
$pagination = ''; $pagination = '';
$count = 0; $count = 0;
if (intval($endTime - $begTime) / (24 * 3600) <= 31) { if (intval($endTime - $begTime) / (24 * 3600) <= 31) {
$map = [ $map['chain'] = ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%'];
'_logic' => 'or',
'id' => $queryPromote['id'],
'chain' => ['like', $queryPromote['chain'] . $queryPromote['id'] . '/%']
];
$ids = M('promote', 'tab_')->where($map)->getField('id', true); $ids = M('promote', 'tab_')->where($map)->getField('id', true);
$ids[] = $queryPromote['id'];
$map = []; $map = ['uc.promote_id' => ['in', $ids]];
if (count($ids) > 0) { $subMap = ['promote_id' => ['in', $ids]];
$map = ['promote_id' => ['in', $ids]];
} else {
$map['_string'] = '1<>1';
}
$subMap = [];
if ($relationGameId != 0) { if ($relationGameId != 0) {
$gameMap['relation_game_id'] = $relationGameId; $gameMap['relation_game_id'] = $relationGameId;
if ($sdkVersion != 0) { if ($sdkVersion != 0) {
$gameMap['sdk_version'] = $sdkVersion; $gameMap['sdk_version'] = $sdkVersion;
} }
$gameId = M('game', 'tab_')->where($gameMap)->getField('id', true); $gameId = M('game', 'tab_')->where($gameMap)->getField('id', true);
$map['game_id'] = ['in', $gameId];
$map['uc.game_id'] = ['in', $gameId];
$subMap['game_id'] = ['in', $gameId]; $subMap['game_id'] = ['in', $gameId];
} }
if ($serverId != 0) { if ($serverId != 0) {
$map['server_id'] = $serverId; $map['uc.server_id'] = $serverId;
$subMap['server_id'] = $serverId; $subMap['server_id'] = $serverId;
} }
if ($roleName != '') { if ($roleName != '') {
$map['role_name'] = ['like', '%' . $roleName . '%']; $map['ui.role_name'] = ['like', $roleName . '%'];
} }
if ($userAccount != '') { if ($userAccount != '') {
$map['user_account'] = ['like', '%' . $userAccount . '%']; $map['ui.user_account'] = ['like', $userAccount . '%'];
} }
if ($isSelf) { if ($isSelf) {
$map['promote_id'] = $queryPromote['id']; $map['uc.promote_id'] = $queryPromote['id'];
} }
$subMap['create_time'] = ['between', [$begTime, $endTime - 1]]; $subMap['create_time'] = ['between', [$begTime, $endTime - 1]];
$roleIdMap = $subMap;
$roleIds = M('user_play_data_count', 'tab_')->where($roleIdMap)->group('role_id')->getField('role_id', true);
if (count($roleIds) > 0) {
$map['role_id'] = ['in', $roleIds];
}
if ($costBegin != '' || $costEnd != '') { if ($costBegin != '' || $costEnd != '') {
$having = ''; $having = '';
if ($costBegin != '' && $costEnd != '') { if ($costBegin != '' && $costEnd != '') {
@ -1793,10 +1782,10 @@ class QueryController extends BaseController
->group('game_id,server_id,role_id') ->group('game_id,server_id,role_id')
->having($having) ->having($having)
->buildSql(); ->buildSql();
$map['_string'] = 'role_id in(' . $subQuery . ')'; $map['_string'] = 'ui.role_id in(' . $subQuery . ')';
} }
$orderBy = 'play_time desc'; $orderBy = 'ui.play_time desc';
if (!empty($sortName)) { if (!empty($sortName)) {
if (in_array($sortName, $sortNameData)) { if (in_array($sortName, $sortNameData)) {
$desc = ' desc'; $desc = ' desc';
@ -1819,53 +1808,25 @@ class QueryController extends BaseController
} }
} }
$spendMap['uc.create_time'] = ['between', [$begTime, $endTime - 1]]; $map['uc.create_time'] = ['between', [$begTime, $endTime - 1]];
$spendMap['_string'] = 'uc.game_id = tab_user_play_info.game_id and uc.server_id = tab_user_play_info.server_id and uc.role_id = tab_user_play_info.role_id'; $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";
$sqlCost = M('user_play_data_count', 'tab_')->alias('uc') $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";
->field('sum(uc.recharge_cost) cost') $field = $fieldUC . ',' . $fieldUI;
->where($spendMap) $subQuery = M('user_play_data_count', 'tab_')->alias('uc')
->buildSql(); ->field($field)
$sqlCount = M('user_play_data_count', 'tab_')->alias('uc') ->join('tab_user_play_info as ui on ui.promote_id = uc.promote_id and ui.game_id = uc.game_id and ui.server_id = uc.server_id and ui.role_id = uc.role_id')
->field('sum(uc.recharge_count) count')
->where($spendMap)
->buildSql();
$spendMap['uc.create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]];
$sqlTodayCost = M('user_play_data_count', 'tab_')->alias('uc')
->field('sum(uc.recharge_count) count')
->where($spendMap)
->buildSql();
$subQuery = M('user_play_info', 'tab_')
->field("*,$sqlCost as recharge_cost,$sqlCount as recharge_count,$sqlTodayCost as recharge_cost_today")
->where($map) ->where($map)
->having('recharge_cost > 0') ->group('uc.role_id,uc.server_id,uc.game_id')
->order('play_time desc')
->buildSql(); ->buildSql();
$query = M()->field('*') $query = M()->alias('record')
->table($subQuery) ->table($subQuery)
->alias('a')
->order($orderBy); ->order($orderBy);
list($roles, $pagination, $count) = $this->paginate($query); list($records, $pagination, $count) = $this->paginate($query);
foreach ($roles as $role) { foreach ($records as &$list) {
$records[] = [ $list['user_account'] = encryption($list['user_account']);
'user_account' => encryption($role['user_account']), $list['unlogin_day'] = intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $list['play_time']))) / (24 * 3600));
'game_name' => $role['game_name'],
'role_name' => $role['role_name'],
'role_id' => $role['role_id'],
'role_level' => $role['role_level'],
'server_id' => $role['server_id'],
'server_name' => $role['server_name'],
'recharge_cost' => empty($role['recharge_cost']) ? 0 : $role['recharge_cost'],
'recharge_count' => empty($role['recharge_count']) ? 0 : $role['recharge_count'],
'recharge_cost_today' => empty($role['recharge_cost_today']) ? 0 : $role['recharge_cost_today'],
'play_time' => $role['play_time'],
'play_ip' => $role['play_ip'],
'promote_id' => $role['promote_id'],
'promote_account' => $role['promote_account'],
'sdk_version' => $role['sdk_version'],
'unlogin_day' => intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $role['play_time']))) / (24 * 3600))
];
} }
} }

@ -547,7 +547,15 @@ ALTER TABLE `tab_withdraw`
ADD COLUMN `last_up_update_time` int(10) NOT NULL DEFAULT 0 COMMENT '最后更新时间', ADD COLUMN `last_up_update_time` int(10) NOT NULL DEFAULT 0 COMMENT '最后更新时间',
ADD COLUMN `spend_ids` longtext NOT NULL COMMENT '充值订单id'; ADD COLUMN `spend_ids` longtext NOT NULL COMMENT '充值订单id';
--广oa --广oa
ALTER TABLE `tab_promote` ALTER TABLE `tab_promote`
ADD COLUMN`oa_associated` tinyint(1) DEFAULT '0' COMMENT 'oa是否关联', ADD COLUMN`oa_associated` tinyint(1) DEFAULT '0' COMMENT 'oa是否关联',
----ID广ID
ALTER TABLE `tab_user_play_data_count`
ADD COLUMN `user_id` int(11) NOT NULL DEFAULT 0 COMMENT '玩家ID',
ADD COLUMN `promote_id` int(11) NOT NULL DEFAULT 0 COMMENT '推广员ID';
ALTER TABLE `tab_user_play_data_count`
DROP INDEX `search`,
ADD INDEX `search`(`user_id`, `promote_id`, `game_id`, `server_id`, `role_id`, `create_time`) USING BTREE;

Loading…
Cancel
Save