From 736c0fd4320f8b54c11febd1e109f05970ce213c Mon Sep 17 00:00:00 2001 From: jbrazz <2436953959@qq.com> Date: Thu, 24 Oct 2019 10:46:17 +0800 Subject: [PATCH] fix --- .../Admin/Controller/AjaxController.class.php | 7 ++ .../Controller/MemberController.class.php | 28 +++++--- .../RechargeSumController.class.php | 32 +++++---- .../Controller/SpendController.class.php | 45 +++++++----- .../Admin/Controller/UserController.class.php | 5 ++ .../Admin/Model/PromoteModel.class.php | 17 +++++ Application/Admin/Model/SpendModel.class.php | 11 +-- Application/Admin/View/Member/user_info.html | 69 ++++++++++++++++--- .../Admin/View/RechargeSum/summation.html | 44 +++++++++++- Application/Admin/View/Spend/lists.html | 41 +++++++++++ Application/Admin/View/User/rolelist.html | 40 ++++++++++- 11 files changed, 275 insertions(+), 64 deletions(-) diff --git a/Application/Admin/Controller/AjaxController.class.php b/Application/Admin/Controller/AjaxController.class.php index b854f8b2d..ad020d72d 100644 --- a/Application/Admin/Controller/AjaxController.class.php +++ b/Application/Admin/Controller/AjaxController.class.php @@ -8,6 +8,8 @@ namespace Admin\Controller; +use Admin\Model\PromoteModel; + class AjaxController extends ThinkController{ /** @@ -125,4 +127,9 @@ class AjaxController extends ThinkController{ $this->AjaxReturn($return_msg); } } + + public function getPromotersByLevel($level=1) + { + $this->ajaxReturn(['code'=>1, 'msg'=>'获取成功', 'data'=>(new PromoteModel)->getPromotersByLevel($level)]); + } } \ No newline at end of file diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index b203db626..98f059052 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -19,9 +19,15 @@ class MemberController extends ThinkController if($_REQUEST['promote_id']=='UC'){ $maps['tab_user.promote_account'] = 'UC用户'; $hav .= "tab_user.promote_account = 'UC用户' "; - }else{ - $maps['tab_user.promote_id'] = I('promote_id'); - $hav .= "tab_user.promote_id = " . I('promote_id'); + } else if ($_REQUEST['promote_id']==0) { + $maps['tab_user.promote_id'] = 0; + $hav .= "tab_user.promote_id = 0"; + } else{ + $promoter_ids = D("Promote")->where("parent_id={$_REQUEST['promote_id']} or grand_id={$_REQUEST['promote_id']} or id={$_REQUEST['promote_id']}")->field('id')->select(); + if ($promoter_ids) { + $maps['tab_user.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))]; + $hav .= "tab_user.promote_id in (".implode(',', array_column($promoter_ids, 'id')).") "; + } } } if(I('type',1) == 1){ @@ -56,8 +62,7 @@ class MemberController extends ThinkController $maps['tab_user.register_type'] = ['in',[0,3,4,5,6]]; } } - - + if (isset($_REQUEST['account'])) { empty($hav) || $hav .= ' AND '; $hav .= "tab_user.account like '%" . I('account') . "%'"; @@ -105,10 +110,10 @@ class MemberController extends ThinkController unset($_REQUEST['status']); } - if (isset($_REQUEST['viplevel'])) { - - $havs = get_vip_level_limit('recharge_total',$_REQUEST['viplevel']); - } + if (isset($_REQUEST['viplevel'])) { + + $havs = get_vip_level_limit('recharge_total',$_REQUEST['viplevel']); + } $page = intval($p); $page = $page ? $page : 1; //默认显示第一页数据 @@ -158,13 +163,13 @@ class MemberController extends ThinkController ->select(false); $data = $usermodel->table('('.$sql1.') as a ')->field('a.id,a.device_number,a.age_status,a.account,a.balance,a.gold_coin,a.alipay,a.promote_id,a.register_type,a.promote_account,a.register_time,a.lock_status,a.register_way,a.register_type,a.register_ip,a.login_time,(a.deposit_total+IFNULL(sum(ss.pay_amount),0)) as recharge_total,check_status') - ->join('left join tab_spend as ss on ss.user_id=a.id AND ss.pay_status = 1') + ->join('left join tab_spend as ss on ss.user_id=a.id AND ss.pay_status = 1') + ->join(isset($_REQUEST['game_id']) ? "tab_user_play as up on up.user_id = a.id and up.game_id = {$_REQUEST['game_id']} " : false) ->page($page, $row) ->having($havs) ->group('a.id') ->order($order) ->select(); - // var_dump($data);die; //计数 @@ -172,6 +177,7 @@ class MemberController extends ThinkController $sql = M('user', 'tab_')->field('tab_user.id,(IFNULL(sum(b.pay_amount),0) + IFNULL(sum(ss.pay_amount),0)) AS recharge_total') ->join('left join tab_deposit AS b ON tab_user.id = b.user_id AND b.pay_status = 1') ->join('left join tab_spend as ss on ss.user_id=tab_user.id AND ss.pay_status = 1') + ->join(isset($_REQUEST['game_id']) ? "tab_user_play as up on up.user_id = tab_user.id and up.game_id = {$_REQUEST['game_id']} " : false) ->where($map) ->group('tab_user.id') ->where($hav) diff --git a/Application/Admin/Controller/RechargeSumController.class.php b/Application/Admin/Controller/RechargeSumController.class.php index 3f6518cfa..84eec8aa7 100644 --- a/Application/Admin/Controller/RechargeSumController.class.php +++ b/Application/Admin/Controller/RechargeSumController.class.php @@ -44,21 +44,23 @@ class RechargeSumController extends ThinkController{ $map['pay_way'] = array('egt',0); } - if(!empty($_REQUEST['promote_id']) && $_REQUEST['promote_id'] != "ALL"){ - switch ($_REQUEST['promote_id']) { - case 'GUANFANG': - $map['promote_id'] = 0; - $rmap['promote_id'] = 0; - break; - case 'PROMOTE': - $map['promote_id'] = array('neq',0); - $rmap['promote_id'] = array('neq',0); - break; - default: - $map['promote_id'] = $_REQUEST['promote_id']; - $rmap['promote_id'] = $_REQUEST['promote_id']; - break; - } + if(!empty($_REQUEST['promote_id'])){ + // switch ($_REQUEST['promote_id']) { + // case 'GUANFANG': + // $map['promote_id'] = 0; + // $rmap['promote_id'] = 0; + // break; + // case 'PROMOTE': + // $map['promote_id'] = array('neq',0); + // $rmap['promote_id'] = array('neq',0); + // break; + // default: + // $map['promote_id'] = $_REQUEST['promote_id']; + // $rmap['promote_id'] = $_REQUEST['promote_id']; + // break; + // } + $promoter_ids = D("Promote")->where("parent_id={$_REQUEST['promote_id']} or grand_id={$_REQUEST['promote_id']} or id={$_REQUEST['promote_id']}")->field('id')->select(); + $promoter_ids ? $rmap['promote_id'] = $map['promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))] : null; } //当天注册人数 diff --git a/Application/Admin/Controller/SpendController.class.php b/Application/Admin/Controller/SpendController.class.php index 92b3067ca..c58167a3b 100644 --- a/Application/Admin/Controller/SpendController.class.php +++ b/Application/Admin/Controller/SpendController.class.php @@ -11,65 +11,72 @@ class SpendController extends ThinkController { const model_name = 'Spend'; public function lists(){ if(isset($_REQUEST['user_account'])){ - $map['user_account']=array('like','%'.trim($_REQUEST['user_account']).'%'); + $map['tab_spend.user_account']=array('like','%'.trim($_REQUEST['user_account']).'%'); unset($_REQUEST['user_account']); } if(isset($_REQUEST['spend_ip'])){ - $map['spend_ip']=array('like','%'.trim($_REQUEST['spend_ip']).'%'); + $map['tab_spend.spend_ip']=array('like','%'.trim($_REQUEST['spend_ip']).'%'); unset($_REQUEST['spend_ip']); } if(isset($_REQUEST['time-start'])&&isset($_REQUEST['time-end'])){ - $map['pay_time'] =array('BETWEEN',array(strtotime($_REQUEST['time-start']),strtotime($_REQUEST['time-end'])+24*60*60-1)); + $map['tab_spend.pay_time'] =array('BETWEEN',array(strtotime($_REQUEST['time-start']),strtotime($_REQUEST['time-end'])+24*60*60-1)); unset($_REQUEST['time-start']);unset($_REQUEST['time-end']); }elseif(isset($_REQUEST['time-start'])){ - $map['pay_time'] = ['GT',strtotime(I('time-start'))]; + $map['tab_spend.pay_time'] = ['GT',strtotime(I('time-start'))]; unset($_REQUEST['time-start']); }elseif(isset($_REQUEST['time-end'])){ - $map['pay_time'] = ['LT',strtotime(I('time-end'))+86399]; + $map['tab_spend.pay_time'] = ['LT',strtotime(I('time-end'))+86399]; unset($_REQUEST['time-end']); } if(isset($_REQUEST['start'])&&isset($_REQUEST['end'])){ - $map['pay_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1)); + $map['tab_spend.pay_time'] =array('BETWEEN',array(strtotime($_REQUEST['start']),strtotime($_REQUEST['end'])+24*60*60-1)); unset($_REQUEST['start']);unset($_REQUEST['end']); }elseif(isset($_REQUEST['start'])){ - $map['pay_time'] = ['GT',strtotime(I('start'))]; + $map['tab_spend.pay_time'] = ['GT',strtotime(I('start'))]; unset($_REQUEST['start']); }elseif(isset($_REQUEST['end'])){ - $map['pay_time'] = ['LT',strtotime(I('end'))+86399]; + $map['tab_spend.pay_time'] = ['LT',strtotime(I('end'))+86399]; unset($_REQUEST['end']); } if(isset($_REQUEST['game_name'])){ if($_REQUEST['game_name']=='全部'){ unset($_REQUEST['game_name']); }else{ - $map['game_name']=$_REQUEST['game_name']; + $map['tab_spend.game_name']=$_REQUEST['game_name']; unset($_REQUEST['game_name']); } } if(isset($_REQUEST['server_name'])){ - $map['server_name']=$_REQUEST['server_name']; + $map['tab_spend.server_name']=$_REQUEST['server_name']; unset($_REQUEST['server_name']); } if(isset($_REQUEST['pay_order_number'])){ - $map['pay_order_number']=array('like','%'.trim($_REQUEST['pay_order_number']).'%'); + $map['tab_spend.pay_order_number']=array('like','%'.trim($_REQUEST['pay_order_number']).'%'); unset($_REQUEST['pay_order_number']); } if(isset($_REQUEST['pay_status'])){ - $map['pay_status']=$_REQUEST['pay_status']; + $map['tab_spend.pay_status']=$_REQUEST['pay_status']; unset($_REQUEST['pay_status']); } if(isset($_REQUEST['pay_way'])){ if($_REQUEST['pay_way']==2){ - $map['pay_way']=['in','2,3,4']; + $map['tab_spend.pay_way']=['in','2,3,4']; }else{ - $map['pay_way']=$_REQUEST['pay_way']; + $map['tab_spend.pay_way']=$_REQUEST['pay_way']; } unset($_REQUEST['pay_way']); } if(isset($_REQUEST['pay_game_status'])){ - $map['pay_game_status']=$_REQUEST['pay_game_status']; + $map['tab_spend.pay_game_status']=$_REQUEST['pay_game_status']; unset($_REQUEST['pay_game_status']); } + if(isset($_REQUEST['promote_id'])) { + $map['_complex'] = ['tp.parent_id'=>$_REQUEST['promote_id'], 'tp.grand_id'=>$_REQUEST['promote_id'], 'tp.id'=>$_REQUEST['promote_id'], '_logic' => 'or']; + $tab_promote_join = "left join tab_promote as tp on tp.id = tab_spend.promote_id"; + //unset($_REQUEST['promote_id']); + } else { + $tab_promote_join = false; + } if($_REQUEST['data_order']!=''){ $data_order=reset(explode(',',$_REQUEST['data_order'])); @@ -84,9 +91,9 @@ class SpendController extends ThinkController { $map1=$map; $map1['pay_status']=1; - $total=null_to_0(D(self::model_name)->where($map1)->sum('pay_amount')); - $ttotal=null_to_0(D(self::model_name)->where('pay_time'.total(1))->where(array('pay_status'=>1))->sum('pay_amount')); - $ytotal=null_to_0(D(self::model_name)->where('pay_time'.total(5))->where(array('pay_status'=>1))->sum('pay_amount')); + $total=null_to_0(D(self::model_name)->where($map1)->join($tab_promote_join)->sum('pay_amount')); + $ttotal=null_to_0(D(self::model_name)->where('pay_time'.total(1))->where(array('pay_status'=>1))->join($tab_promote_join)->sum('pay_amount')); + $ytotal=null_to_0(D(self::model_name)->where('pay_time'.total(5))->where(array('pay_status'=>1))->join($tab_promote_join)->sum('pay_amount')); $this->assign('total',$total); $this->assign('ttotal',$ttotal); $this->assign('ytotal',$ytotal); @@ -104,6 +111,6 @@ class SpendController extends ThinkController { $this->assign('_page',$data['page']); $this->display(); - } + } diff --git a/Application/Admin/Controller/UserController.class.php b/Application/Admin/Controller/UserController.class.php index b9b8ff816..aec80c71f 100644 --- a/Application/Admin/Controller/UserController.class.php +++ b/Application/Admin/Controller/UserController.class.php @@ -569,6 +569,11 @@ function think_ucenter_md5($str, $key = 'ThinkUCenter'){ $map['role_name'] = trim($_REQUEST['role_name']); unset($_REQUEST['role_name']); } + if (isset($_REQUEST['promote_id'])) { + $promoter_ids = D("Promote")->where("parent_id={$_REQUEST['promote_id']} or grand_id={$_REQUEST['promote_id']} or id={$_REQUEST['promote_id']}")->field('id')->select(); + $promoter_ids ? $map['promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))] : null; + + } empty(I('user_account')) || $map['user_account'] = ['like',"%".I('user_account')."%"]; $list = $this->lists(M('user_play_info', 'tab_'), $map, 'play_time desc'); $this->assign('list', $list); diff --git a/Application/Admin/Model/PromoteModel.class.php b/Application/Admin/Model/PromoteModel.class.php index 379fa42ee..a12fecfa6 100644 --- a/Application/Admin/Model/PromoteModel.class.php +++ b/Application/Admin/Model/PromoteModel.class.php @@ -371,4 +371,21 @@ class PromoteModel extends Model{ return $user; } + + public function getPromotersByLevel($level=1) + { + $result = []; + switch ($level) { + case 1: // 会长 + $result = $this->field("id, nickname")->where("grand_id = 0 and parent_id = 0")->select(); + break; + case 2: // 组长 + $result = $this->field("id, nickname")->where("grand_id = 0 and parent_id > 0")->select(); + break; + case 3: //组员 + $result = $this->field("id, nickname")->where("parent_id > 0 and grand_id > 0")->select(); + break; + } + return $result; + } } \ No newline at end of file diff --git a/Application/Admin/Model/SpendModel.class.php b/Application/Admin/Model/SpendModel.class.php index 5f03bb50f..bfb91151c 100644 --- a/Application/Admin/Model/SpendModel.class.php +++ b/Application/Admin/Model/SpendModel.class.php @@ -720,14 +720,14 @@ protected function _after_select(&$result,$options){ } else { $row = 10; } - - $list = $this->field($field?:true) + $list = $this->field("tab_spend.*") + ->join("left join tab_promote as tp on tp.id = tab_spend.promote_id") ->where($map) ->page($page, $row) - ->order($order?$order:'pay_time desc') + ->order($order?$order:'tab_spend.pay_time desc') ->select(); - $count = $this->where($map)->count(); + $count = $this->where($map)->join("left join tab_promote as tp on tp.id = tab_spend.promote_id")->count(); $data['data'] = $list; @@ -738,6 +738,7 @@ protected function _after_select(&$result,$options){ } return $data; - } + } + } diff --git a/Application/Admin/View/Member/user_info.html b/Application/Admin/View/Member/user_info.html index 9dbf16d59..5bb75a9ad 100644 --- a/Application/Admin/View/Member/user_info.html +++ b/Application/Admin/View/Member/user_info.html @@ -73,7 +73,7 @@ -
+
@@ -103,15 +103,38 @@
-
- -
+
+ +
+
+ +
+
+ + - +
+
+ +
@@ -375,6 +398,30 @@ $(function(){ autoclose:true, pickerPosition:'bottom-left' }) + var promote_id = "{:I('promote_id')}"; + $("#promote_level").change(function(){ + $.ajax({ + url:"{:U('Ajax/getPromotersByLevel')}", + type:"get", + data:{level:$("#promote_level option:selected").val()}, + dataType:'json', + success:function(response){ + str = ''; + // $.each(response.data, function(index, item){ + // console.log(item.id); + // str += ''; + // }); + data = response.data; + for (var i in data){ + str += "" + } + $("#promote_id").empty(); + $("#promote_id").append(str); + $("#promote_id").select2(); + } + }) + }); + $("#promote_level").change(); }) function shenhe(){ var text = $("input:checkbox[name='ids[]']:checked").map(function(index,elem) { diff --git a/Application/Admin/View/RechargeSum/summation.html b/Application/Admin/View/RechargeSum/summation.html index f565d0e41..51ee0b684 100644 --- a/Application/Admin/View/RechargeSum/summation.html +++ b/Application/Admin/View/RechargeSum/summation.html @@ -55,7 +55,7 @@
-
+
+
+ + - +
+
+ +
搜索
@@ -268,6 +282,32 @@ $(function(){ autoclose: true, pickerPosition: 'bottom-left' }) + + var promote_id = "{:I('promote_id')}"; + console.log(promote_id); + $("#promote_level").change(function(){ + $.ajax({ + url:"{:U('Ajax/getPromotersByLevel')}", + type:"get", + data:{level:$("#promote_level option:selected").val()}, + dataType:'json', + success:function(response){ + str = ""; + // $.each(response.data, function(index, item){ + // console.log(item.id); + // str += ''; + // }); + data = response.data; + for (var i in data){ + str += "" + } + $("#promote_id").empty(); + $("#promote_id").append(str); + $("#promote_id").select2(); + } + }) + }); + $("#promote_level").change(); }) diff --git a/Application/Admin/View/Spend/lists.html b/Application/Admin/View/Spend/lists.html index e4c2e2aad..b160f7f19 100644 --- a/Application/Admin/View/Spend/lists.html +++ b/Application/Admin/View/Spend/lists.html @@ -96,6 +96,20 @@
+
+
+ + - +
+
+ +
@@ -463,6 +477,33 @@ } }) }); + + var promote_id = "{:I('promote_id')}"; + console.log(promote_id); + $("#promote_level").change(function(){ + $.ajax({ + url:"{:U('Ajax/getPromotersByLevel')}", + type:"get", + data:{level:$("#promote_level option:selected").val()}, + dataType:'json', + success:function(response){ + str = ""; + // $.each(response.data, function(index, item){ + // console.log(item.id); + // str += ''; + // }); + data = response.data; + for (var i in data){ + str += "" + } + $("#promote_id").empty(); + $("#promote_id").append(str); + $("#promote_id").select2(); + } + }) + }); + $("#promote_level").change(); + var game_id = "{:I('game_name')}"; var game_server = "{:I('server_name')}"; if(game_id){ diff --git a/Application/Admin/View/User/rolelist.html b/Application/Admin/View/User/rolelist.html index a6b8e04ab..b5b65bc90 100644 --- a/Application/Admin/View/User/rolelist.html +++ b/Application/Admin/View/User/rolelist.html @@ -69,7 +69,21 @@
- +
+ + - +
+
+ +
搜索
@@ -224,5 +238,29 @@ $(".select_gallery").select2(); } }) } + var promote_id = "{:I('promote_id')}"; + $("#promote_level").change(function(){ + $.ajax({ + url:"{:U('Ajax/getPromotersByLevel')}", + type:"get", + data:{level:$("#promote_level option:selected").val()}, + dataType:'json', + success:function(response){ + str = ''; + // $.each(response.data, function(index, item){ + // console.log(item.id); + // str += ''; + // }); + data = response.data; + for (var i in data){ + str += "" + } + $("#promote_id").empty(); + $("#promote_id").append(str); + $("#promote_id").select2(); + } + }) + }); + $("#promote_level").change();