diff --git a/Application/Admin/Controller/CompanyGameRatioController.class.php b/Application/Admin/Controller/CompanyGameRatioController.class.php index 20db93a21..e19b6002e 100644 --- a/Application/Admin/Controller/CompanyGameRatioController.class.php +++ b/Application/Admin/Controller/CompanyGameRatioController.class.php @@ -6,6 +6,7 @@ class CompanyGameRatioController extends AdminController { public $admininfo; public $DBModel; + public $MarketEvent; public $OpAuthList=[]; public $Status = [ "-2"=>"管理员拒绝", @@ -24,6 +25,7 @@ class CompanyGameRatioController extends AdminController { $this->admininfo = $_SESSION['onethink_admin']['user_auth']; $this->DBModel = M("company_game_ratio","tab_"); + $this->MarketEvent = A("Market","Event"); parent::_initialize(); } @@ -78,18 +80,16 @@ class CompanyGameRatioController extends AdminController } } } - - $isMarketAdmin = isMarketAdmin(); - if($isMarketAdmin) { - $userAuth = session('user_auth'); - $adminId = $userAuth['uid']; - $companyIds = M('promote', 'tab_')->where(['admin_id' => $adminId, 'level' => 1])->getField('company_id', true); - $companyIds = array_unique($companyIds); - $marketCondition = ''; - if (count($companyIds) > 0) { - $marketCondition = 'm.company_id in(' . implode(',', $companyIds) . ')'; - } else { - $marketCondition = '1<>1'; + $gid = session('user_group_id'); + $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid); + if($markerGroup){ + $companyIds = $this->MarketEvent->getAdminCompanyId(); + //取消0 + $companyIds = implode(",",array_diff(explode(",",$companyIds),[0])); + $marketCondition = 'm.company_id in(' . $companyIds . ')'; + if($markerGroup['department_level'] == $this->MarketEvent->getConfig("DirectorLevel")){ + //总监 + $marketCondition .= " OR (m.company_id = 0 AND m.company_belong != 0 )"; } $where['_string'] = isset($where['_string']) ? $where['_string'] . ' and ' . $marketCondition : $marketCondition; } @@ -265,6 +265,22 @@ class CompanyGameRatioController extends AdminController } } + + $gid = session('user_group_id'); + $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid); + if($markerGroup){ + $companyIds = $this->MarketEvent->getAdminCompanyId(); + //取消0 + $companyIds = implode(",",array_diff(explode(",",$companyIds),[0])); + $marketCondition = 'm.company_id in(' . $companyIds . ')'; + if($markerGroup['department_level'] == $this->MarketEvent->getConfig("DirectorLevel")){ + //总监 + $marketCondition .= " OR (m.company_id = 0 AND m.company_belong != 0 )"; + } + $where['_string'] = isset($where['_string']) ? $where['_string'] . ' and ' . $marketCondition : $marketCondition; + } + + if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { $time_start = strtotime($_REQUEST['time_start']); $time_end = strtotime($_REQUEST['time_end'])+ 86399; diff --git a/Application/Admin/Controller/OldCountController.class.php b/Application/Admin/Controller/OldCountController.class.php index 3b4dfcd1b..770c0875e 100644 --- a/Application/Admin/Controller/OldCountController.class.php +++ b/Application/Admin/Controller/OldCountController.class.php @@ -58,6 +58,7 @@ class OldCountController extends \Think\Controller // 'id'=>1, // 'name'=>'市场一部', // 'group_ids'=>'11,12,14,21,25', + // 'leader_group'=>'14', // 'create_time'=>time(), // 'update_time'=>time() // ]); @@ -65,6 +66,7 @@ class OldCountController extends \Think\Controller // 'id'=>2, // 'name'=>'市场二部', // 'group_ids'=>'26,27,28,29,30', + // 'leader_group'=>'28', // 'create_time'=>time(), // 'update_time'=>time() // ]); diff --git a/Application/Admin/Event/MarketEvent.class.php b/Application/Admin/Event/MarketEvent.class.php index a37235944..23a888829 100644 --- a/Application/Admin/Event/MarketEvent.class.php +++ b/Application/Admin/Event/MarketEvent.class.php @@ -99,6 +99,13 @@ class MarketEvent extends Controller $gid = M("auth_group_access")->where("uid = '{$uid}'")->getField('group_id'); return M('department','sys_')->where("id = '{$department_id}' and leader_group = '$gid'")->field("id")->find(); } + + public function isMarketLeder($uid) + { + $gid = M("auth_group_access")->where("uid = '{$uid}'")->getField('group_id'); + return M("auth_group")->where("id = '{$gid}' and department_level = '{$this->DirectorLevel}'")->field("id")->find(); + } + /** * 添加部门总监的会长权限 * $uid,$promote_id