优化推广员

master
chenzhi 5 years ago
parent 3f358bb818
commit d4968e4c72

@ -68,6 +68,24 @@ class MemberController extends ThinkController
//与游戏相关
$game = false;
//与推广员相关
$promoterSelect = false;
if ($_REQUEST['promote_id'] != '') {
$promoterSelect = true;
$spendprom = '';
if ($_REQUEST['promote_id'] == 'UC') {
$map['tab_user.promote_account'] = 'UC用户';
} else if ($_REQUEST['promote_id'] == 0) {
$map['tab_user.promote_id'] = 0;
} else {
$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')) . ") ";
}
}
}
//计算用户列表
$data = M("user","tab_")
@ -84,14 +102,14 @@ class MemberController extends ThinkController
//计算累计充值总额
$history_count = M("user","tab_")
$now_count = M("user","tab_")
->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);
if($havs){
$countsql->having($havs);
$now_count->having($havs);
}
$history_count = $history_count->find()['recharge_total'];
$now_count = $now_count->find()['recharge_total'];
//计算用户总数
$user_count = M("user","tab_")
@ -101,13 +119,26 @@ class MemberController extends ThinkController
$user_count->having($havs);
}
$user_count = $user_count->find()['user_count'];
//如股存在会长计算换绑定记录
if($promoterSelect){
$history_count = M("user","tab_")
->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".$spendprom,"left")
->where($map);
if($havs){
$history_count->having($havs);
}
$history_count = $history_count->find()['recharge_total'];
$this->assign('history_count', $history_count?:0);
}
// dump($countsql);die();
// $countres = M()->table('(' . $countsql . ') as a ')->field("count(*) user_count,sum(recharge_total) recharge_total")->find();
$this->assign('user_count',$user_count);
$this->assign('now_count', $history_count?:0);
$this->assign('now_count', $now_count?:0);
$page = set_pagination($user_count, $row);
if ($page) {

Loading…
Cancel
Save