@ -132,10 +132,9 @@ class MemberController extends ThinkController
//计算用户列表
$data = M("user","tab_")
->field("tab_user.id,`device_number`,count(`device_number`) as device_count,`age_status`,`account`,`balance`,`gold_coin`,`alipay`,tab_user.promote_id,`register_type`,tab_user.promote_account,`register_time`,`lock_status`,lock_remark,`register_way`,`register_ip`,`login_time`,`check_status`,IFNULL(sum(ss.pay_amount),0) AS recharge_total")
->field("tab_user.id,`device_number`,`age_status`,`account`,`balance`,`gold_coin`,`alipay`,tab_user.promote_id,`register_type`,tab_user.promote_account,`register_time`,`lock_status`,lock_remark,`register_way`,`register_ip`,`login_time`,`check_status`,IFNULL(ss.pay_amount,0) AS recharge_total")
->where($map)
->group("device_number,tab_user.register_ip")
// ->page($page, $row)
->group("tab_user.id")
->order($order);
if($havs){
@ -154,49 +153,15 @@ class MemberController extends ThinkController
if($promoterSelect){
$data->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1".$spendprom,"left");
}else{
$data->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left");
$data->join("tab_user_data AS ss ON ss.user_id = tab_user.id","left");
}
$data = $data->select(false);
$data = M()->table('(' . $data . ') as a ');
if(!isset($_REQUEST['export'])){
$data ->page($page, $row);
}
$data = $data->select();
// var_dump($data);die();
//计算用户列表重复数量
$userRepeat = M("user","tab_")
->field("count(`device_number`) as device_count")
->where($map)
->group("device_number,tab_user.register_ip")
// ->page($page, $row)
->order($order);
if($havs){
$userRepeat->having($havs);
}
if($gameplay){
$userRepeat->join("
(select user_id from tab_user_play where 1 $gameplay group by tab_user_play.user_id) a ON a.user_id = tab_user.id
");
}
if($game_map){
$userRepeat->join("
(select user_id from tab_user_play_info where 1 $game_map group by tab_user_play_info.user_id) a ON a.user_id = tab_user.id
");
}
if($promoterSelect){
$userRepeat->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1".$spendprom,"left");
}else{
$userRepeat->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left");
}
$userRepeat = $userRepeat->select(false);
$userRepeat = M()->table('(' . $userRepeat . ') as a ')->count();
// echo($data);die();
if(isset($_REQUEST['export'])){
@ -277,7 +242,7 @@ class MemberController extends ThinkController
if($promoterSelect){
$user_count->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1".$spendprom,"left");
}else{
$user_count->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left");
$user_count->join("tab_user_data AS ss ON ss.user_id = tab_user.id","left");
}
$user_count = $user_count->select(false);
$count = M()->table('(' . $user_count . ') as a ')->field("count(*) user_count,sum(a.recharge_total) recharge_total")->find();
@ -300,31 +265,39 @@ class MemberController extends ThinkController
");
}
$user_count = $user_count->find()['user_count'];
//计算累计充值总额
$now_count = M("user","tab_")
->field("IFNULL(sum(ss.pay_amount), 0) AS recharge_total")
//累计充值统计
$user_sql = M("user","tab_")
->field('id')
->where($map);
if($game_map){
$now_count->join("
$user_sql->join("
(select user_id from tab_user_play_info where 1 $game_map group by tab_user_play_info.user_id) a ON a.user_id = tab_user.id
");
}
if($gameplay){
$now_count->join("
$user_sql->join("
(select user_id from tab_user_play where 1 $gameplay group by tab_user_play.user_id) a ON a.user_id = tab_user.id
");
}
if($promoterSelect){
$now_count->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1".$spendprom,"left");
// dump($spendprom);
// dd($map);
$user_sql->field("IFNULL(sum(ss.pay_amount), 0) AS recharge_total");
$user_sql->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1".$spendprom,"left");
$now_count = $user_sql->find()['recharge_total'];
}else{
$now_count->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left");
$user_sql = $user_sql->select(false);
$now_count = M("UserData","tab_")
->alias('ss')
->field("IFNULL(sum(ss.pay_amount), 0) AS recharge_total")
->where("user_id in (".$user_sql.")")->find()['recharge_total'];