优化用户列表3

master
chenzhi 5 years ago
parent d4968e4c72
commit 03a03fd61e

@ -90,7 +90,6 @@ class MemberController extends ThinkController
//计算用户列表 //计算用户列表
$data = M("user","tab_") $data = M("user","tab_")
->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`,`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`,`register_way`,`register_ip`,`login_time`,`check_status`,IFNULL(sum(ss.pay_amount), 0) AS recharge_total")
->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left")
->where($map) ->where($map)
->group("tab_user.id") ->group("tab_user.id")
->page($page, $row) ->page($page, $row)
@ -98,17 +97,26 @@ class MemberController extends ThinkController
if($havs){ if($havs){
$data->having($havs); $data->having($havs);
} }
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 = $data->select(); $data = $data->select();
//计算累计充值总额 //计算累计充值总额
$now_count = M("user","tab_") $now_count = M("user","tab_")
->field("IFNULL(sum(ss.pay_amount), 0) AS recharge_total") ->field("IFNULL(sum(ss.pay_amount), 0) AS recharge_total")
->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left")
->where($map); ->where($map);
if($havs){ if($havs){
$now_count->having($havs); $now_count->having($havs);
} }
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");
}
$now_count = $now_count->find()['recharge_total']; $now_count = $now_count->find()['recharge_total'];
//计算用户总数 //计算用户总数

Loading…
Cancel
Save