[优化]玩家列表累记充值统计

master
chenzhi 5 years ago
parent df9d1415df
commit b7dd9edaa9

@ -243,6 +243,7 @@ class ExportController extends Controller
$promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
if ($promoter_ids) {
$map['tab_user.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))];
$spendprom = " AND ss.promote_id IN (" . implode(',', array_column($promoter_ids, 'id')) . ") ";
}
}
}
@ -259,24 +260,24 @@ class ExportController extends Controller
// unset($_REQUEST['promote_account']);
// }
if (isset($_REQUEST['register_way'])) {
if($_REQUEST['type']==1) {
if ($_GET['register_way'] == 1) {
empty($hav) || $hav .= ' AND ';
$hav .= ' tab_user.register_type in (0,1)';
$maps['tab_user.register_type'] = ['in',[0,1]];
} elseif($_GET['register_way'] == 7){
empty($hav) || $hav .= ' AND ';
$hav .= ' tab_user.register_type in(7)';
$maps['tab_user.register_type'] = 7;
}else {
empty($hav) || $hav .= ' AND ';
$hav .= ' tab_user.register_type in(2)';
$maps['tab_user.register_type'] = 2;
}
} else {
$map['register_way'] = I('register_way');
unset($_REQUEST['register_way']);
}
if($_REQUEST['type']==1) {
if ($_GET['register_way'] == 1) {
empty($hav) || $hav .= ' AND ';
$hav .= ' tab_user.register_type in (0,1)';
$maps['tab_user.register_type'] = ['in',[0,1]];
} elseif($_GET['register_way'] == 7){
empty($hav) || $hav .= ' AND ';
$hav .= ' tab_user.register_type in(7)';
$maps['tab_user.register_type'] = 7;
}else {
empty($hav) || $hav .= ' AND ';
$hav .= ' tab_user.register_type in(2)';
$maps['tab_user.register_type'] = 2;
}
} else {
$map['register_way'] = I('register_way');
unset($_REQUEST['register_way']);
}
}
if (isset($_REQUEST['register_type'])) {
$map['register_type'] = I('register_type');
@ -301,16 +302,25 @@ class ExportController extends Controller
$order = 'id desc';
}
if (isset($_REQUEST['viplevel'])) {
if (isset($_REQUEST['viplevel'])) {
$havs = get_vip_level_limit('recharge_total',$_REQUEST['viplevel']);
}
$havs = get_vip_level_limit('recharge_total',$_REQUEST['viplevel']);
}
$map['puid'] = array('eq',0);
$map['is_platform'] = 0;
//数据
$xlsData = M('user', 'tab_')->field('tab_user.id,tab_user.age_status,tab_user.account,tab_user.gold_coin,tab_user.alipay,tab_user.balance,tab_user.promote_account,register_time,tab_user.lock_status,tab_user.register_way,tab_user.register_type,tab_user.register_ip,tab_user.login_time,(IFNULL(sum(b.pay_amount),0) + IFNULL(sum(ss.pay_amount),0)) AS recharge_total')
->join('left join tab_deposit AS b ON tab_user.id = b.user_id AND b.pay_status = 1')
$map['puid'] = array('eq',0);
$map['is_platform'] = 0;
if($_REQUEST['promote_id'] && $_REQUEST['promote_id'] > -1){
$xlsData = M('user', 'tab_')->field('tab_user.id,tab_user.age_status,tab_user.account,tab_user.gold_coin,tab_user.alipay,tab_user.balance,tab_user.promote_account,register_time,tab_user.lock_status,tab_user.register_way,tab_user.register_type,tab_user.register_ip,tab_user.login_time,IFNULL(sum(ss.pay_amount),0) AS recharge_total')
->join('left join tab_spend as ss on ss.user_id=tab_user.id AND ss.pay_status = 1'.$spendprom)
->join($game_map ? "tab_user_play on tab_user_play.user_id = tab_user.id $game_map" : false)
->join($game_play_map ? "tab_user_play_info on tab_user_play_info.user_id = tab_user.id $game_play_map" : false)
->where($map)
->group('tab_user.id')
->order($order)
->having($havs)
->select();
}else{
$xlsData = M('user', 'tab_')->field('tab_user.id,tab_user.age_status,tab_user.account,tab_user.gold_coin,tab_user.alipay,tab_user.balance,tab_user.promote_account,register_time,tab_user.lock_status,tab_user.register_way,tab_user.register_type,tab_user.register_ip,tab_user.login_time,IFNULL(sum(ss.pay_amount),0) AS recharge_total')
->join('left join tab_spend as ss on ss.user_id=tab_user.id AND ss.pay_status = 1')
->join($game_map ? "tab_user_play on tab_user_play.user_id = tab_user.id $game_map" : false)
->join($game_play_map ? "tab_user_play_info on tab_user_play_info.user_id = tab_user.id $game_play_map" : false)
@ -319,38 +329,42 @@ class ExportController extends Controller
->order($order)
->having($havs)
->select();
if($xlsData) {
$ids = array_column($xlsData,'id');
/* 在手里 */
$small = M('user','tab_')->field('count(id) as count,puid')->where(['puid'=>array('in',$ids)])->group('puid')->select();
/* 出售中 */
$small2 = M('user','tab_')->field('count(id) as count,source_puid')->where(['source_puid'=>array('in',$ids),'source_time'=>0])->group('source_puid')->select();
foreach($xlsData as $k => $v) {
$xlsData[$k]['vip_level'] = get_vip_level($v['recharge_total']);
if(empty($v['alipay'])){
$xlsData[$k]['alipay'] = '--';
}
$xlsData[$k]['register_type'] = $v['register_type'] == 2?'手机号':($v['register_type']==7?'邮箱':'账号');
$xlsData[$k]['small_count'] = 0;
foreach($small as $s) {
if($s['puid'] == $v['id']) {
$xlsData[$k]['small_count'] += $s['count'];break;
}
}
foreach($small2 as $s) {
if($s['source_puid'] == $v['id']) {
$xlsData[$k]['small_count'] += $s['count'];break;
}
}
}
//数据
if($xlsData) {
$ids = array_column($xlsData,'id');
/* 在手里 */
$small = M('user','tab_')->field('count(id) as count,puid')->where(['puid'=>array('in',$ids)])->group('puid')->select();
/* 出售中 */
$small2 = M('user','tab_')->field('count(id) as count,source_puid')->where(['source_puid'=>array('in',$ids),'source_time'=>0])->group('source_puid')->select();
}
foreach($xlsData as $k => $v) {
}
$xlsData[$k]['vip_level'] = get_vip_level($v['recharge_total']);
if(empty($v['alipay'])){
$xlsData[$k]['alipay'] = '--';
}
$xlsData[$k]['register_type'] = $v['register_type'] == 2?'手机号':($v['register_type']==7?'邮箱':'账号');
$xlsData[$k]['small_count'] = 0;
foreach($small as $s) {
if($s['puid'] == $v['id']) {
$xlsData[$k]['small_count'] += $s['count'];break;
}
}
foreach($small2 as $s) {
if($s['source_puid'] == $v['id']) {
$xlsData[$k]['small_count'] += $s['count'];break;
}
}
}
}
break;
case 4:

@ -26,6 +26,7 @@ class MemberController extends ThinkController
if ($promoter_ids) {
$maps['tab_user.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))];
$hav .= "tab_user.promote_id in (" . implode(',', array_column($promoter_ids, 'id')) . ") ";
$spendprom = " AND ss.promote_id IN (" . implode(',', array_column($promoter_ids, 'id')) . ") ";
}
}
}
@ -176,7 +177,28 @@ class MemberController extends ThinkController
// ->order($order)
->select(false);
$data = $usermodel->table('(' . $sql1 . ') as a ')->field('a.id,a.device_number,a.age_status,a.account,a.balance,a.gold_coin,a.alipay,a.promote_id,a.register_type,a.promote_account,a.register_time,a.lock_status,a.register_way,a.register_type,a.register_ip,a.login_time,(a.deposit_total+IFNULL(sum(ss.pay_amount),0)) as recharge_total,check_status')
// $data = $usermodel->table('(' . $sql1 . ') as a ')->field('a.id,a.device_number,a.age_status,a.account,a.balance,a.gold_coin,a.alipay,a.promote_id,a.register_type,a.promote_account,a.register_time,a.lock_status,a.register_way,a.register_type,a.register_ip,a.login_time,IFNULL(sum(ss.pay_amount),0) as recharge_total,check_status')
// ->join('left join tab_spend as ss on ss.user_id=a.id AND ss.pay_status = 1')
// ->join($game_map ? "tab_user_play on tab_user_play.user_id = a.id $game_map" : false)
// ->join($game_play_map ? "tab_user_play_info on tab_user_play_info.user_id = a.id $game_play_map" : false)
// ->page($page, $row)
// ->having($havs)
// ->group('a.id')
// ->order($order)
// ->select();
if($_REQUEST['promote_id'] && $_REQUEST['promote_id'] > -1){
$data = $usermodel->table('(' . $sql1 . ') as a ')->field('a.id,a.device_number,a.age_status,a.account,a.balance,a.gold_coin,a.alipay,a.promote_id,a.register_type,a.promote_account,a.register_time,a.lock_status,a.register_way,a.register_type,a.register_ip,a.login_time,IFNULL(sum(ss.pay_amount),0) as recharge_total,check_status')
->join('left join tab_spend as ss on ss.user_id=a.id AND ss.pay_status = 1'.$spendprom)
->join($game_map ? "tab_user_play on tab_user_play.user_id = a.id $game_map" : false)
->join($game_play_map ? "tab_user_play_info on tab_user_play_info.user_id = a.id $game_play_map" : false)
->page($page, $row)
->having($havs)
->group('a.id')
->order($order)
->select();
// echo $data;die();
}else{
$data = $usermodel->table('(' . $sql1 . ') as a ')->field('a.id,a.device_number,a.age_status,a.account,a.balance,a.gold_coin,a.alipay,a.promote_id,a.register_type,a.promote_account,a.register_time,a.lock_status,a.register_way,a.register_type,a.register_ip,a.login_time,IFNULL(sum(ss.pay_amount),0) as recharge_total,check_status')
->join('left join tab_spend as ss on ss.user_id=a.id AND ss.pay_status = 1')
->join($game_map ? "tab_user_play on tab_user_play.user_id = a.id $game_map" : false)
->join($game_play_map ? "tab_user_play_info on tab_user_play_info.user_id = a.id $game_play_map" : false)
@ -185,10 +207,11 @@ class MemberController extends ThinkController
->group('a.id')
->order($order)
->select();
}
//计数
$sql = M('user', 'tab_')->field('tab_user.id,(IFNULL(sum(b.pay_amount),0) + IFNULL(sum(ss.pay_amount),0)) AS recharge_total')
->join('left join tab_deposit AS b ON tab_user.id = b.user_id AND b.pay_status = 1')
$sql = M('user', 'tab_')->field('tab_user.id,IFNULL(sum(ss.pay_amount),0) AS recharge_total')
->join('left join tab_spend as ss on ss.user_id=tab_user.id AND ss.pay_status = 1')
->join($game_map ? "tab_user_play on tab_user_play.user_id = tab_user.id $game_map" : false)
->join($game_play_map ? "tab_user_play_info on tab_user_play_info.user_id = tab_user.id $game_play_map" : false)
@ -196,6 +219,18 @@ class MemberController extends ThinkController
->group('tab_user.id')
->where($hav)
->having($havs)->select(false);
//替换为新表
if($_REQUEST['promote_id'] && $_REQUEST['promote_id'] > -1){
$sql = M('user', 'tab_')->field('tab_user.id,IFNULL(sum(ss.pay_amount),0) AS recharge_total')
->join('left join tab_spend as ss on ss.user_id=tab_user.id AND ss.pay_status = 1'.$spendprom)
->join($game_map ? "tab_user_play on tab_user_play.user_id = tab_user.id $game_map" : false)
->join($game_play_map ? "tab_user_play_info on tab_user_play_info.user_id = tab_user.id $game_play_map" : false)
->where($map)
->group('tab_user.id')
->where($hav)
->having($havs)->select(false);
}
$jcount = M('User', 'tab_')->field('count(a.id) as count')->table('(' . $sql . ') as a')->select();
$count = $jcount[0]['count'];

Loading…
Cancel
Save