diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index d9d631072..2be802ac6 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -3021,11 +3021,19 @@ function getMarketAuthPromoteId() { $map['level'] = 1; if (isMarketLeader()) { - $map['admin_id'] = ['gt', 0]; + //搜索所有市场部管理员id + $mid = M("AuthGroup")->where("title like '%市场%'")->getField("id",true); + $mid = implode(",",$mid); + + $admin_id = M("AuthGroupAccess")->where("group_id in ({$mid})")->getField("uid",true); + $admin_id = implode(",",$admin_id); + + $map['admin_id'] = ['in', $admin_id]; }elseif(isMarketAdmin()){ $userAuth = session('user_auth'); $adminId = $userAuth['uid']; $map['admin_id'] = $adminId; + }else{ return false; } @@ -3039,12 +3047,11 @@ function getMarketAuthPromoteId() function throwPromoteIdToCompanyId($p_ids) { - $map["id"]=["in","{$p_ids}"]; - $dbres = M("Promote","tab_")->where($map)->group("company_id")->getField("company_id",true); + $dbres = M("Promote","tab_")->where("id in ({$p_ids})")->field("count(*) count,company_id")->group("company_id")->select(); if(empty($dbres)){ return -1; }else{ - return implode(",",$dbres); + return implode(",",array_column($dbres,"company_id")); } } diff --git a/Application/Admin/Controller/PromoteCompanyController.class.php b/Application/Admin/Controller/PromoteCompanyController.class.php index a1d87edb6..eaf5f5484 100644 --- a/Application/Admin/Controller/PromoteCompanyController.class.php +++ b/Application/Admin/Controller/PromoteCompanyController.class.php @@ -40,16 +40,20 @@ class PromoteCompanyController extends ThinkController $is_export = true; $this->getAggregatePackage(); } - $map = []; - $promotemap=[]; + $map = [ + "_string" => "1 = 1" + ]; + $promotemap=[ + "_string" => "1 = 1" + ]; $company_name = trim(I('company_name')); //市场部权限begin $pro_id = getMarketAuthPromoteId(); if($pro_id){ - $promotemap["_string"]="p.id in ({$pro_id})"; + $promotemap["_string"] .=" AND p.id in ({$pro_id})"; $c_id = throwPromoteIdToCompanyId($pro_id); - $map["_string"]="id in ({$c_id})"; + $map["_string"] .=" AND id in ({$c_id})"; } //市场部权限end @@ -74,11 +78,7 @@ class PromoteCompanyController extends ThinkController $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 },"; - if (isset($map["_string"])) { - $map['_string'] = ' AND concat(",", game_ids, ",") like "%,' . $g_id . ',%"'; - }else{ - $map["_string"] = ' concat(",", game_ids, ",") like "%,' . $g_id . ',%"'; - } + $map["_string"] .= ' AND concat(",", game_ids, ",") like "%,' . $g_id . ',%"'; // $map["game_ids"]=["EXP","REGEXP '{$reg_str}'"]; } @@ -93,11 +93,8 @@ class PromoteCompanyController extends ThinkController $c_id = -1; } $c_id = implode(",", $c_id); - if(isset($map["_string"])){ - $map["_string"] .= " ADN id in ($c_id)"; - }else{ - $map["_string"] = " id in ($c_id)"; - } + $map["_string"] .= " AND id in ($c_id)"; + } diff --git a/Application/Home/Controller/BaseController.class.php b/Application/Home/Controller/BaseController.class.php index eca59c3f5..3705e3848 100644 --- a/Application/Home/Controller/BaseController.class.php +++ b/Application/Home/Controller/BaseController.class.php @@ -397,7 +397,7 @@ class BaseController extends HomeController // 推广公司 $promoteCompanyService = new PromoteCompanyService(); $promoteCompany = $promoteCompanyService->getCompanies([$topPromote['company_id']]); - if ($promoteCompany[$topPromote['company_id']]['type'] == $promoteCompanyService::TYPE_CUSTOM) { // 特殊公司不能看 + if ($promoteCompany[$topPromote['company_id']]['type'] == $promoteCompanyService::TYPE_CUSTOM && $promote['level'] == 4) { // 特殊公司不能看 return false; } diff --git a/Application/Home/Controller/PromoteGradeController.class.php b/Application/Home/Controller/PromoteGradeController.class.php index dc3e43cc1..2178be476 100644 --- a/Application/Home/Controller/PromoteGradeController.class.php +++ b/Application/Home/Controller/PromoteGradeController.class.php @@ -4,6 +4,7 @@ namespace Home\Controller; use Base\Model\PromoteModel; +use Base\Service\PromoteCompanyService; use Base\Service\PromoteService; use Base\Service\PromoteGradeService; @@ -14,7 +15,10 @@ class PromoteGradeController extends BaseController parent::_initialize(); $loginPromote = $this->getLoginPromote(); - if(C('APP_ENV') == 'dev' || in_array($loginPromote['company_id'], [334, 370])) { + // 推广公司 + $promoteCompanyService = new PromoteCompanyService(); + $promoteCompany = $promoteCompanyService->getCompanies([$loginPromote['company_id']]); + if (C('APP_ENV') == 'dev' || $promoteCompany[$loginPromote['company_id']]['type'] == $promoteCompanyService::TYPE_CUSTOM) { // 特殊公司 } else { return $this->error('您没有权限');