From d4968e4c721e1a99174b75b880c88bc490e04710 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Fri, 6 Dec 2019 10:49:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=A8=E5=B9=BF=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/MemberController.class.php | 39 +++++++++++++++++-- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index 174a0cf8d..f8d37e199 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -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) {