diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index fab99c87a..3d2bfa213 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2807,4 +2807,37 @@ function promote_listsMarket($type){ } return $data; -} \ No newline at end of file +} +//市场部获取公司或推广员id +function getMarketAuthPromoteId() +{ + $map['level'] = 1; + if (isMarketLeader()) { + $map['admin_id'] = ['gt', 0]; + }elseif(isMarketAdmin()){ + $userAuth = session('user_auth'); + $adminId = $userAuth['uid']; + $map['admin_id'] = $adminId; + }else{ + return false; + } + $dbres = M("Promote","tab_")->where($map)->getField("id",true); + if(empty($dbres)){ + return -1; + }else{ + return implode(",",$dbres); + } +} + +function throwPromoteIdToCompanyId($p_ids) +{ + $map["id"]=["in","{$p_ids}"]; + $dbres = M("Promote","tab_")->where($map)->group("company_id")->getField("company_id",true); + if(empty($dbres)){ + return -1; + }else{ + return implode(",",$dbres); + } +} + + diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index 3d3099e07..dbaa627d3 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -33,15 +33,24 @@ class PromoteCompanyController extends ThinkController $map = []; $promotemap=[]; $company_name = trim(I('company_name')); + + //市场部权限begin + $pro_id = getMarketAuthPromoteId(); + if($pro_id){ + $promotemap["_string"]="p.id in ({$pro_id})"; + $c_id = throwPromoteIdToCompanyId($pro_id); + $map["_string"]="id in ({$c_id})"; + } + //市场部权限end + if($company_name) $map['tab_promote_company.company_name'] = array('like',"%{$company_name}%"); if (isset($_REQUEST['status']) && $_REQUEST['status'] !== '') { $status = intval($_REQUEST['status']); $map['tab_promote_company.status'] = $status; - $parameter['status'] = $status; } if (isset($_REQUEST['promote_id'])) { $map['id'] = M("Promote","tab_")->field("company_id")->where("id={$_REQUEST['promote_id']}")->find()['company_id']; - $promotemap['id']=$_REQUEST['promote_id']; + $promotemap['p.id']=$_REQUEST['promote_id']; } if (isset($_REQUEST['company_type'])) { $map['company_type'] = $_REQUEST['company_type']; @@ -49,6 +58,13 @@ class PromoteCompanyController extends ThinkController if (isset($_REQUEST['company_belong'])) { $map['company_belong'] = $_REQUEST['company_belong']; } + if (isset($_REQUEST['game_name'])) { + //换成id + $g_name = $_REQUEST['game_name']; + $g_id = M("Game","tab_")->where("relation_game_name = '{$g_name}'")->field("relation_game_id")->find()['relation_game_id']; + $reg_str = "([^0-9]|^){$g_id },"; + $map["game_ids"]=["EXP","REGEXP '{$reg_str}'"]; + } $page = intval(I('get.p', 0)); @@ -92,10 +108,14 @@ class PromoteCompanyController extends ThinkController $v['validity_time'] = $validity_start_time . '-' . $validity_end_time; //遍历获取游戏信息 if(empty($v["game_ids"])){ - $game = $this->getPromoteGameRadio($v["id"],false); + $senddata=false; }else{ - $game = $this->getGamePromoteCompanyRadio($v["id"],$v["game_ids"],$is_export); + if(isset($_REQUEST['game_name'])) { + $v["game_ids"] = $g_id; + } + $senddata = $this->getGamePromoteCompanyRadio($v["id"],$v["game_ids"],$is_export); } + $game = $this->getPromoteGameRadio($v["id"],$senddata,$promotemap); $v += $game; } } @@ -104,9 +124,9 @@ class PromoteCompanyController extends ThinkController $companycount = $model->field("id")->where($map)->select(); $count = count($companycount); $companyallids = implode(',', array_column($companycount, 'id')); - $promotemap['company_id']=["in",$companyallids]; - $promotemap['level']=1; - $promotecount = M("Promote","tab_")->where($promotemap)->count(); + $promotemap['p.company_id']=["in",$companyallids]; + $promotemap['p.level']=1; + $promotecount = M("Promote","tab_")->alias('p')->where($promotemap)->count(); // dd($companyres); $this->assign('listData', $companyres); $this->assign('count', $count); @@ -1094,7 +1114,7 @@ class PromoteCompanyController extends ThinkController } if(empty($game_arr)){ - return $this->getPromoteGameRadio($company_id,$senddata); + return $senddata; } $diff_ids = implode(",",array_keys($game_arr)); @@ -1130,16 +1150,16 @@ class PromoteCompanyController extends ThinkController } } if(empty($game_arr)){ - return $this->getPromoteGameRadio($company_id,$senddata); + return $senddata; } foreach($game_arr as $k=>$v){ $senddata[$k]= ["turnover_ratio"=>[["name"=>"--","ratio"=>"--"]],"ratio"=>0,"relation_game_id"=>$k,"cp_ratio"=>[["name"=>"--","ratio"=>"--"]],"row"=>1]; $senddata[$k]+= $game[$k];; } - return $this->getPromoteGameRadio($company_id,$senddata); + return $senddata; } - protected function getPromoteGameRadio($company_id,$ratio){ + protected function getPromoteGameRadio($company_id,$ratio,$p_map = false){ //获取会长信息 $payWays = PresidentDepositService::$payWays; $payTypes = PresidentDepositService::$payTypes; @@ -1148,6 +1168,9 @@ class PromoteCompanyController extends ThinkController $rdata = []; $promotemap['p.company_id']=$company_id; $promotemap['p.level'] = 1; + if($p_map){ + $promotemap += $p_map;//外界条件 + } $company_row = 0; $promoteres = M("Promote","tab_") @@ -1191,6 +1214,7 @@ class PromoteCompanyController extends ThinkController $v['row'] += $ratio[$ke]["row"]; } } + if($v['row'] == 0) $v['row']=1; $rdata[] = $v; $company_row += $v['row']; } diff --git a/Application/Admin/View/PromoteCompany/lists.html b/Application/Admin/View/PromoteCompany/lists.html index 2b0a8797f..f4f22b254 100644 --- a/Application/Admin/View/PromoteCompany/lists.html +++ b/Application/Admin/View/PromoteCompany/lists.html @@ -75,7 +75,7 @@ -
+
+ +
+ +
+
搜索