优化vip等级筛选时的玩家列表

master
chenzhi 5 years ago
parent 95aa18a928
commit 6ad8154832

@ -122,42 +122,59 @@ class MemberController extends ThinkController
$data->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left");
}
$data = $data->select();
// echo($data);die();
//计算累计充值总额
$now_count = M("user","tab_")
->field("IFNULL(sum(ss.pay_amount), 0) AS recharge_total")
->where($map);
if($havs){
$now_count->having($havs);
}
if($game_map){
$now_count->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){
$now_count->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1".$spendprom,"left");
}else{
$now_count->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left");
}
// dump($now_count->select(false));die();
$now_count = $now_count->find()['recharge_total'];
//计算用户总数
$user_count = M("user","tab_")
->field("count(*) user_count")
->where($map);
if($havs){
$user_count->having($havs);
}
if($game_map){
$user_count->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($havs){
//判断是否需要vip等级分类
$user_count = M("user","tab_")
->field("tab_user.id,IFNULL(sum(ss.pay_amount), 0) AS recharge_total")
->where($map)
->group("tab_user.id")
->having($havs);
if($game_map){
$user_count->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){
$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 = $user_count->select(false);
$count = M()->table('(' . $user_count . ') as a ')->field("count(*) user_count,sum(a.recharge_total) recharge_total")->find();
$user_count = $count['user_count'];
$now_count = $count['recharge_total'];
}else{
//计算总人数
$user_count = M("user","tab_")
->field("count(*) user_count")
->where($map);
if($game_map){
$user_count->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
");
}
$user_count = $user_count->find()['user_count'];
//计算累计充值总额
$now_count = M("user","tab_")
->field("IFNULL(sum(ss.pay_amount), 0) AS recharge_total")
->where($map);
if($game_map){
$now_count->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){
$now_count->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1".$spendprom,"left");
}else{
$now_count->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left");
}
// dump($now_count->select(false));die();
$now_count = $now_count->find()['recharge_total'];
}
$user_count = $user_count->find()['user_count'];
//如果存在推广员只计算所属的推广员充值记录
if($promoterSelect){

Loading…
Cancel
Save