充值玩家

master
sunke 5 years ago
parent 5b7a0ad8b2
commit 7e68257724

@ -1909,16 +1909,9 @@ class DownloadController extends BaseController {
foreach($data as $key => $v) {
$v['create_time'] = date('Y-m-d H:i:s',$v['create_time']);
$promoteInfo = M('promote','tab_')->field("account")->where(['id' => intval($v['promote_id'])])->find();
if($v['server_id'] != 0) {
$serverId1 = $v['server_id'];
$gameId = $v['game_id'];
$serverInfo = M('server','tab_')->field('server_name')->where(['server_num'=>$serverId1,'game_id'=>$gameId])->find();
$servername = $serverInfo['server_name'];
}else {
$servername = "";
$v['game_player_id'] = "";
$v['game_player_name'] = "";
}
$serverId = $v['server_id'];
$gameId = $v['game_id'];
$serverInfo = M('server','tab_')->field('server_name')->where(['server_num'=>$serverId,'game_id'=>$gameId])->find();
$v['promote_id']= $promoteInfo['account'];
if(empty($v['extend'])) {
$v['extend'] = $v['order_id'];
@ -1928,7 +1921,7 @@ class DownloadController extends BaseController {
$csvData['user_account'] = $v['user_account'];
$csvData['game_name'] = $v['game_name'];
$csvData['promote_id'] = $v['promote_id'];
$csvData['server_name'] = $servername;
$csvData['server_name'] = $serverInfo['server_name'];
$csvData['user_id'] = $v['game_player_id'];
$csvData['game_player_name'] = $v['game_player_name'];
$csvData['price'] = $v['price'];
@ -1982,7 +1975,7 @@ class DownloadController extends BaseController {
->field('account,device_number,promote_account,register_time,register_ip,login_time,login_ip')
->where($map)
->limit(($i-1)*$perSize ,$perSize)
->order('tab_user.id desc')
->order('tab_user.id desc')
->select();
foreach($data as $value1) {
$csvData['account'] = $this->encryption($value1['account']);
@ -3148,13 +3141,12 @@ class DownloadController extends BaseController {
'游戏区服',
'平台',
'角色名',
'等级',
'充值总额',
'充值次数',
'日充值',
'日充值',
'未登录天数',
'游戏累计登陆天数',
'创角时间',
'注册时间',
'最后登录时间',
'推广员账号',
@ -3208,43 +3200,49 @@ class DownloadController extends BaseController {
$map['_string'] = 'ui.role_id in (' . $subQuery . ')';
}
$secondDay = 24*3600 + 1;
$map['uc.create_time'] = ['between', [$map['begintime'], $map['endtime']-1]];
//$map['uc.create_time'] = ['between', [$map['begintime'], $map['endtime']-1]];
$map['uc.pay_time'] = ['between', [$map['begintime'], $map['endtime']-1]];
unset($map['begintime']);
unset($map['endtime']);
//$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['uc.pay_status'] = 1;
$fieldS = "sum(uc.pay_amount) recharge_cost, count(*) recharge_count, uc.user_id, uc.user_account, uc.promote_account, uc.game_name, uc.sdk_version, uc.server_name, SUBSTRING_INDEX(GROUP_CONCAT(uc.game_player_name order by uc.id desc), ',', 1) as game_player_name";
$fieldUser = 'u.register_time, u.login_time';
$now = date('Y-m-d');
$now = strtotime($now);
$nowTimeEnd = $now + 3600 * 24 - 1;
$spendMap['_string'] = 'today.user_id = uc.user_id and today.game_id = uc.game_id and today.server_id = uc.server_id and today.game_player_id = uc.game_player_id and today.promote_id = uc.promote_id';
$spendMap['today.pay_status'] = 1;
$spendMap['today.pay_time'] = ['between', [$now, $nowTimeEnd]];
$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";
$fieldToday = M('spend', 'tab_')->alias('today')
->field('sum(pay_amount) as recharge_cost_today')
->where($spendMap)
->buildSql();
$loginRecordMap['lr.create_time'] = $map['uc.create_time'];
$loginRecordMap['lr.create_time'] = $map['uc.pay_time'];
$loginRecordMap['_string'] = 'lr.user_id = uc.user_id and lr.game_id = uc.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 = $fieldUC . ',' . $fieldUI . ',' . $fieldLR . ' as user_game_login_count';
$field = "$fieldS, $fieldUser, $fieldToday as recharge_cost_today, $fieldLR as user_game_login_count";
$subQuery = M('spend', 'tab_')->alias('uc')
->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')
->where($map)
->group('uc.role_id,uc.server_id,uc.game_id')
// ->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 = uc.user_id')
->where($map)
->group('uc.game_player_id,uc.server_id,uc.game_id')
->buildSql();
$roles = M()->alias('record')
->table($subQuery)
->select();
$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('uc')
->field("$fieldS,$fieldToday as recharge_cost_today")
->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();
$userIds = array_column($roles, 'user_id');
$userIds = $userIds ? $userIds : [-1];
$users = M('user', 'tab_')->where(array('id' => ['in', $userIds]))->getField('id, account', true);
$total['recharge_cost_today'] = empty($total['recharge_cost_today']) ? '0.00' :$total['recharge_cost_today'];
$csvFileName = $xlsName.'.csv';
//设置好告诉浏览器要下载excel文件的headers
header('Content-Description: File Transfer');
@ -3267,9 +3265,9 @@ class DownloadController extends BaseController {
->limit(($i-1)*$perSize ,$perSize)
->select();
foreach($data as $key => $value) {
if (empty($value['user_account']) ) {
$value['user_account'] = $users[$value['user_id']] ?? '';
}
// if (empty($value['user_account']) ) {
// $value['user_account'] = $users[$value['user_id']] ?? '';
// }
$csvData['user_account'] = empty($value['user_account']) ? '--' : encryption($value['user_account']);
$csvData['game_name'] = empty($value['game_name']) ? '--' :$value['game_name'];
$csvData['server_name'] = empty($value['server_name']) ? '--' :$value['server_name'];
@ -3280,15 +3278,14 @@ class DownloadController extends BaseController {
} else {
$csvData['sdk_version'] = "--";
}
$csvData['role_name'] = empty($value['role_name']) ? '--' :$value['role_name'];
$csvData['role_level'] = empty($value['role_level']) ? '--' :$value['role_level'];
$csvData['game_player_name'] = empty($value['game_player_name']) ? '--' :$value['game_player_name'];
$csvData['recharge_cost'] = empty($value['recharge_cost']) ? 0 : $value['recharge_cost'];
$csvData['recharge_count'] = empty($value['recharge_count']) ? 0 : $value['recharge_count'];
$csvData['recharge_cost_today'] = empty($value['recharge_cost_today']) ? 0 : $value['recharge_cost_today'];
$csvData['unlogin_day'] = empty($value['play_time']) ? '--' : intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $value['play_time']))) / (24 * 3600));
$csvData['unlogin_day'] = empty($value['login_time']) ? '--' : intval((strtotime(date('Y-m-d 00:00:00')) - strtotime(date('Y-m-d 00:00:00', $value['login_time']))) / (24 * 3600));
$csvData['user_game_login_count'] = empty($value['user_game_login_count']) ? 0 : $value['user_game_login_count'];
$csvData['create_time'] = empty($value['create_time']) ? '--' : date('Y-m-d H:i:s', $value['create_time']);
$csvData['play_time'] = empty($value['play_time']) ? '--' :date('Y-m-d H:i:s',$value['play_time']);
$csvData['create_time'] = empty($value['register_time']) ? '--' : date('Y-m-d H:i:s', $value['register_time']);
$csvData['login_time'] = empty($value['login_time']) ? '--' :date('Y-m-d H:i:s',$value['login_time']);
$csvData['promote_account'] = empty($value['promote_account']) ? '--' :$value['promote_account'];
mb_convert_variables('GBK', 'UTF-8', $csvData);
@ -3303,15 +3300,14 @@ class DownloadController extends BaseController {
$allData['game_name'] = '--';
$allData['server_name'] = '--';
$allData['sdk_version'] = '--';
$allData['role_name'] = '--';
$allData['role_level'] = '--';
$allData['game_player_name'] = '--';
$allData['recharge_cost'] = $total['recharge_cost'];
$allData['recharge_count'] = $total['recharge_count'];
$allData['recharge_cost_today'] = $total['recharge_cost_today'];
$allData['unlogin_day'] = '--';
$allData['user_game_login_count'] = '--';
$allData['create_time'] = '--';
$allData['play_time'] = '--';
$allData['login_time'] = '--';
$allData['promote_account'] = '--';
mb_convert_variables('GBK', 'UTF-8', $allData);
fputcsv($fp, $allData);

Loading…
Cancel
Save