master
sunke 5 years ago
parent 8007d9954f
commit ef1857d752

@ -1241,6 +1241,17 @@ class DownloadController extends BaseController {
$promoteId = I('promote_id', 0); $promoteId = I('promote_id', 0);
$sdkVersion = I('sdk_version', 0); $sdkVersion = I('sdk_version', 0);
$headmanPromoteId = I('headman_promote_id', 0); $headmanPromoteId = I('headman_promote_id', 0);
$costBegin = I('cost_begin', ''); //充值总额范围
$costEnd = I('cost_end', '');
$nowTime = date('Y-m-d');
$initBegTime = date('Y-m-d', strtotime('-6 day', strtotime($nowTime)));
$initBegTime = empty(I('begtime')) ? $initBegTime : I('begtime');
$initEndTime = $nowTime;
$initEndTime = empty(I('endtime')) ? $initEndTime : I('endtime');
$begTime = strtotime($initBegTime);
$endTime = strtotime($initEndTime);
$endTime += 3600 * 24;
$map1['chain'] = ['like','%'.'/'.PID.'/'.'%']; $map1['chain'] = ['like','%'.'/'.PID.'/'.'%'];
$rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select(); $rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select();
$childPromoteIds = ''; $childPromoteIds = '';
@ -1270,7 +1281,7 @@ class DownloadController extends BaseController {
if(empty($levelPromote)) { if(empty($levelPromote)) {
array_push($ids,PID); array_push($ids,PID);
} }
array_push($ids,$queryPromote['id']); // array_push($ids,$queryPromote['id']);
if (!empty($ids)) { if (!empty($ids)) {
$map['promote_id'] = ['in',$ids]; $map['promote_id'] = ['in',$ids];
@ -1304,6 +1315,18 @@ class DownloadController extends BaseController {
} }
} }
if($costBegin) {
$map['costbegin'] = $costBegin;
}else {
$map['costbegin'] = "";
}
if($costEnd) {
$map['costend'] = $costEnd;
}else {
$map['costend'] = "";
}
$map['begintime'] = $begTime;
$map['endtime'] = $endTime;
$conditions = json_encode($map,TRUE); $conditions = json_encode($map,TRUE);
$addtime = time(); $addtime = time();
$data = [ $data = [
@ -1763,11 +1786,11 @@ class DownloadController extends BaseController {
array('promote_account','推广账号'), array('promote_account','推广账号'),
array('game_name','游戏名称'), array('game_name','游戏名称'),
array('server_name','区服'), array('server_name','区服'),
array('user_nickname','游戏昵称'), array('role_name','游戏昵称'),
array('role_level','等级'), array('role_level','等级'),
); );
$model = M('user_play_info','tab_'); $model = M('user_play_info','tab_');
$data = $model->field('user_account,promote_account,game_name,server_name,user_nickname,role_level')->where($map)->select(); $data = $model->field('user_account,promote_account,game_name,server_name,role_name,role_level')->where($map)->select();
$xlsData = []; $xlsData = [];
foreach ($data as $key1 => $value1) { foreach ($data as $key1 => $value1) {
$value1['user_account'] = $this->encryption($value1['user_account']); $value1['user_account'] = $this->encryption($value1['user_account']);
@ -2703,55 +2726,80 @@ class DownloadController extends BaseController {
array('play_time','最后登录时间'), array('play_time','最后登录时间'),
array('promote_account','推广员账号'), array('promote_account','推广员账号'),
); );
if(!empty($map['promote_id'])) { $subMap = [];
$spendMap['promote_id'] = $map['promote_id']; $subMap['game_id'] = $map['game_id'];
} $subMap['server_id'] = $map['server_id'];
$map['create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')) - 6*24*3600, strtotime(date('Y-m-d 23:59:59'))]]; $costBegin = $map['costbegin'];
$roles = M('user_play_info','tab_')->where($map)->select(); $costEnd = $map['costend'];
unset($map['costbegin']);
$roleIds = array_column($roles, 'role_id'); unset($map['costend']);
$spendMap['pay_status'] = 1; $roleIds = M('user_play_data_count', 'tab_')->group('role_id')->getField('role_id', true);
$spendMap['pay_game_status'] = 1; $map['role_id'] = ['in', $roleIds];
if (count($roleIds) > 0) { $subMap['create_time'] = ['between', [$map['begintime'], $map['endtime'] - 1]];
$spendMap['game_player_id'] = ['in', $roleIds]; if ($costBegin != '' || $costEnd != '') {
} else { $having = '';
$spendMap['_string'] = '1<>1'; if ($costBegin != '' && $costEnd != '') {
} $having = 'sum(recharge_cost) between ' . $costBegin . ' and ' . $costEnd;
$allRecharges = M('spend', 'tab_')->field('count(*) count, sum(cost) cost, game_player_id')->where($spendMap)->group('game_player_id')->select(); } elseif ($costBegin != '' && $costEnd == '') {
$allRecords = []; $having = 'sum(recharge_cost) >= ' . $costBegin;
foreach ($allRecharges as $recharge) { } elseif ($costBegin == '' && $costEnd != '') {
$allRecords[$recharge['game_player_id']] = $recharge; $having = 'sum(recharge_cost) <= ' . $costEnd;
} }
$subQuery = M('user_play_data_count', 'tab_')->field('role_id')
->where($subMap)
->group('game_id,server_id,role_id')
->having($having)
->buildSql();
$map['_string'] = 'role_id in (' . $subQuery . ')';
}
$spendMap['uc.create_time'] = ['between', [$map['begintime'], $map['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';
// $map['create_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')) - 6*24*3600, strtotime(date('Y-m-d 23:59:59'))]];
$sqlCost = M('user_play_data_count', 'tab_')->alias('uc')
->field('sum(uc.recharge_cost) cost')
->where($spendMap)
->buildSql();
$map['pay_time'] = ['between', [strtotime(date('Y-m-d 00:00:00')), strtotime(date('Y-m-d 23:59:59'))]]; $sqlCount = M('user_play_data_count', 'tab_')->alias('uc')
$todayRecharges = M('spend', 'tab_')->field('sum(cost) cost, game_player_id')->where($map)->group('game_player_id')->select(); ->field('sum(uc.recharge_count) count')
$todayRecords = []; ->where($spendMap)
foreach ($todayRecharges as $recharge) { ->buildSql();
$todayRecords[$recharge['game_player_id']] = $recharge;
}
$records = []; $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();
unset($map['begintime']);
unset($map['endtime']);
$roles = M('user_play_info', 'tab_')
->field("*,$sqlCost as cost,$sqlCount as count,$sqlTodayCost as today_cost")
->where($map)
->order('play_time desc')
->select();
foreach ($roles as $role) { foreach ($roles as $role) {
$records[] = [ $records[] = [
'user_account' => $role['user_account'], 'user_account' => $role['user_account'],
'game_name' => $role['game_name'], 'game_name' => $role['game_name'],
'role_name' => $role['role_name'], 'role_name' => $role['role_name'],
'role_id' => $role['role_id'], 'role_id' => $role['role_id'],
'role_level' => $role['role_level'], 'role_level' => $role['role_level'],
'server_id' => $role['server_id'], 'server_id' => $role['server_id'],
'server_name' => $role['server_name'], 'server_name' => $role['server_name'],
'recharge_cost' => isset($allRecords[$role['role_id']]) ? round(floatval($allRecords[$role['role_id']]['cost']), 2) : 0, 'recharge_cost' => $role['cost'],
'recharge_count' => isset($allRecords[$role['role_id']]) ? $allRecords[$role['role_id']]['count'] : 0, 'recharge_count' => $role['count'],
'recharge_cost_today' => isset($todayRecords[$role['role_id']]) ? round(floatval($todayRecords[$role['role_id']]['cost']), 2) : 0, 'recharge_cost_today' => $role['cost_today'],
'play_time' => $role['play_time'], 'play_time' => $role['play_time'],
'play_ip' => $role['play_ip'], 'play_ip' => $role['play_ip'],
'promote_id' => $role['promote_id'], 'promote_id' => $role['promote_id'],
'promote_account' => $role['promote_account'], 'promote_account' => $role['promote_account'],
'sdk_version' => $role['sdk_version'], '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)) 'unlogin_day' => intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $role['play_time']))) / (24 * 3600))
]; ];
} }
$xlsData = []; $xlsData = [];
foreach ($records as $key1 => $value1) { foreach ($records as $key1 => $value1) {
$value1['user_account'] = $this->encryption($value1['user_account']); $value1['user_account'] = $this->encryption($value1['user_account']);

Loading…
Cancel
Save