From a6f9d822457a0b30412ca499039082d7c85bf150 Mon Sep 17 00:00:00 2001 From: chenzhi Date: Tue, 17 Nov 2020 20:16:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=A8=E5=B9=BF=E5=91=98?= =?UTF-8?q?=E7=B4=AF=E8=AE=A1=E6=B3=A8=E5=86=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PlatformController.class.php | 94 ++++++++++++++++--- .../Admin/View/Platform/promote_pool.html | 9 +- .../View/Platform/promote_statistics.html | 18 +++- 3 files changed, 105 insertions(+), 16 deletions(-) diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php index 9e958090b..fbd9760ae 100644 --- a/Application/Admin/Controller/PlatformController.class.php +++ b/Application/Admin/Controller/PlatformController.class.php @@ -36,9 +36,9 @@ class PlatformController extends ThinkController if($companyBelong > -1){ $companyMap .= " AND company_belong = {$companyBelong}"; } - if(isset($_REQUEST['company_name'])){ - $companyId = $_REQUEST['company_name']; - $companyMap .= " AND company_name like '%{$companyId}%' "; + if(isset($_REQUEST['company_id'])){ + $companyId = $_REQUEST['company_id']; + $companyMap .= " AND id = '{$companyId}' "; } $promoteCompany = M("promote_company","tab_"); @@ -81,6 +81,7 @@ class PlatformController extends ThinkController $th = array_keys(self::setYearList($year)); $this->assign('th', $th); $this->assign('list_data', $sendData); + $this->assign("companyList",D("PromoteCompany")->getList()); $this->getYearList(); $page = set_pagination($count, $row); @@ -627,7 +628,60 @@ class PlatformController extends ThinkController $this->assign("is_admin",is_administrator()); $this->display(); } + function promote_statistics1($p = 0) + { + $page = intval($p); + $page = $page ? $page : 1; //默认显示第一页数据 + $arraypage = $page; + + if (isset($_REQUEST['row'])) { + $row = $_REQUEST['row']; + } else { + $row = 10; + } + + $user = M('User', 'tab_'); + if (!empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { + $map['register_time'] = ['between', array(strtotime($_REQUEST['timestart']), strtotime($_REQUEST['timeend']) + 86399)]; + unset($_REQUEST['timestart']); + unset($_REQUEST['timeend']); + } elseif (!empty($_REQUEST['timestart']) && empty($_REQUEST['timeend'])) { + $map['register_time'] = ['between', array(strtotime($_REQUEST['timestart']), time())]; + unset($_REQUEST['timestart']); + } elseif (empty($_REQUEST['timestart']) && !empty($_REQUEST['timeend'])) { + $map['register_time'] = ['elt', strtotime($_REQUEST['timeend']) + 86399]; + unset($_REQUEST['timeend']); + } + + + $data = M("User u","tab_") + ->field("count(u.id) as count,CASE when (fgame_name is null or fgame_name = '') THEN '无' ELSE left(fgame_name,char_length(fgame_name)-5) END fgame_name,promote_id,promote_account,admin_id,company_name,s.real_name") + ->join("tab_promote promote ON u.promote_id = promote.id","left") + ->join("tab_promote_company pc on promote.company_id = pc.id", 'left') + ->join('sys_member s on promote.admin_id = s.uid', 'left') + ->where($map) + ->group('fgame_name,promote_id') + ->page($page,$row) + ->order("count desc") + ->select(); + + + $sql = M("User u","tab_")->field("count(u.id) as count,CASE when (fgame_name is null or fgame_name = '') THEN '无' ELSE left(fgame_name,char_length(fgame_name)-5) END fgame_name,promote_id")->where($map)->group('fgame_name,promote_id')->select(false); + $count = M()->table("(".$sql.") c")->count(); + + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + $this->assign('list_data', $data); + + $this->display(); + // dd($data); + + + + } function promote_statistics($p = 0) { $page = intval($p); @@ -678,12 +732,24 @@ class PlatformController extends ThinkController $week = total(2); $mounth = total(3); - if (isset($_REQUEST['promote_id'])) { - $promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select(); + if (isset($_REQUEST['promote_id']) || isset($_REQUEST['company_id'])) { + $pwhere = "1"; + if(isset($_REQUEST['promote_id'])){ + $pwhere .= " and (chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']})"; + } + if(isset($_REQUEST['company_id'])){ + $pwhere .= " and company_id={$_REQUEST['company_id']}"; + } + $promoter_ids = D("Promote")->where($pwhere)->field('id')->select(); + if ($promoter_ids) { $map['u.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))]; } } + $promoteTableMap = ''; + if (isset($_REQUEST['company_belong'])){ + $promoteTableMap .= " and promote.company_belong = {$_REQUEST['company_belong']}"; + } // 如果是市场专员那么只能看自己的会长信息 @@ -698,15 +764,15 @@ class PlatformController extends ThinkController $data = M("User u","tab_") ->field(" count(u.id) as count, - tab_game.relation_game_id, - tab_game.relation_game_name, + IFNULL(tab_game.relation_game_id,0) relation_game_id, + IFNULL(tab_game.relation_game_name,'其他渠道') relation_game_name, IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='', u.promote_id, substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) id") - ->join("tab_promote promote ON u.promote_id = promote.id","left") - ->join($play_map ? "tab_user_play as up on up.user_id = u.id " . $play_map : false) - ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) - ->join('tab_game on u.fgame_id = tab_game.id') + ->join("tab_promote promote ON u.promote_id = promote.id {$promoteTableMap}") + ->join($play_map ? "left join tab_user_play as up on up.user_id = u.id " . $play_map : false) + ->join($play_info_map ? "left join tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) + ->join('tab_game on u.fgame_id = tab_game.id',"left") ->where($map) ->group('tab_game.relation_game_id, id') ->order('count desc, register_time') @@ -731,9 +797,10 @@ class PlatformController extends ThinkController ->field("count(IF(register_time {$today},1,null)) as today, count(IF(register_time {$week},1,null)) as week, count(IF(register_time {$mounth},1,null)) as mounth, - tab_game.relation_game_id,tab_game.relation_game_name, + IFNULL(tab_game.relation_game_id,0) relation_game_id, + IFNULL(tab_game.relation_game_name,'其他渠道') relation_game_name, IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',u.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) id") - ->join("tab_promote promote ON u.promote_id = promote.id","left") + ->join("tab_promote promote ON u.promote_id = promote.id {$promoteTableMap}") ->join($play_map ? "tab_user_play as up on up.user_id = u.id " . $play_map : false) ->join($play_info_map ? "tab_user_play_info as upi on upi.user_id = u.id " . $play_info_map : false) ->join('tab_game on u.fgame_id = tab_game.id') @@ -839,6 +906,7 @@ class PlatformController extends ThinkController $this->assign("is_admin",is_administrator()); $this->assign('list_data', $data); $this->assign('admin_users', M('member')->field('uid,nickname')->select()); + $this->assign("companyList",D("PromoteCompany")->getList()); $this->assign('total', $total); $this->display(); } diff --git a/Application/Admin/View/Platform/promote_pool.html b/Application/Admin/View/Platform/promote_pool.html index d4a4745aa..f75dca60c 100644 --- a/Application/Admin/View/Platform/promote_pool.html +++ b/Application/Admin/View/Platform/promote_pool.html @@ -64,8 +64,13 @@ -
-   +
+
diff --git a/Application/Admin/View/Platform/promote_statistics.html b/Application/Admin/View/Platform/promote_statistics.html index 8a3df4834..e670a210d 100644 --- a/Application/Admin/View/Platform/promote_statistics.html +++ b/Application/Admin/View/Platform/promote_statistics.html @@ -54,7 +54,22 @@
- + +
+
+ +
+
+