diff --git a/Application/Admin/Controller/MarketPercentageController.class.php b/Application/Admin/Controller/MarketPercentageController.class.php index 751d73030..d22c1a7ae 100644 --- a/Application/Admin/Controller/MarketPercentageController.class.php +++ b/Application/Admin/Controller/MarketPercentageController.class.php @@ -68,36 +68,13 @@ class MarketPercentageController extends ThinkController $_REQUEST['promote_id'] ? ($map['promote_id'] = $_REQUEST['promote_id']) : ''; $_REQUEST['relation_game_id'] ? ($map['relation_game_id'] = $_REQUEST['relation_game_id']) : ''; // $_REQUEST['sdk_version']?($map['sdk_version'] = $_REQUEST['sdk_version']):''; - $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; + $_REQUEST['admin_id'] ? ($map['_string'] .= " AND admin_id = {$_REQUEST['admin_id']}") : ''; ($_REQUEST['company_id'] || $_REQUEST['company_id'] == '0') ? ($map['company_id'] = $_REQUEST['company_id']) : ''; - $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; - $gid = session('user_group_id'); - $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid); - if($markerGroup){ - $map['department_id'] =["in",[0,$markerGroup['department_id']]]; - if( !$this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){ - $map['admin_id'] = $admin_id ; - } + if($this->MarketEvent->getConfig('isMarket')){ + $map['admin_id'] = ['in',$this->MarketEvent->getAdminidByLeaderid()] ; } - // dd($map); - - // $map['admin_id'] = $admin_id; - // if (is_administrator() || session('user_group_id') == 15 || session('user_group_id') == 14 || session('user_group_id') == 19 || session('user_group_id') == 23) { - // unset($map['admin_id']); - // $admin_data = M("member") - // ->field("access.uid admin_id") - // ->join("left join sys_auth_group_access access on sys_member.uid = access.uid") - // ->join("left join sys_auth_group auth on access.group_id=auth.id") - // ->where(['group_id' => ['in', '11,12,21,25']]) - // ->select(); - // if ($admin_data) { - // $map['admin_id'] = ['in', array_column($admin_data, 'admin_id')]; - // } - // $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; - // } - $search_date = []; if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { @@ -281,30 +258,20 @@ class MarketPercentageController extends ThinkController public function indexuncaculate($row = 10, $p = 1) { - $map = []; + $map = [ + "_string"=>'1=1', + "is_settlement"=>0 + ]; // $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):''; $_REQUEST['promote_id'] ? ($map['promote_id'] = $_REQUEST['promote_id']) : ''; $_REQUEST['relation_game_id'] ? ($map['relation_game_id'] = $_REQUEST['relation_game_id']) : ''; $_REQUEST['sdk_version'] ? ($map['sdk_version'] = $_REQUEST['sdk_version']) : ''; - $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; + $_REQUEST['admin_id'] ? ($map['_string'] .= " AND admin_id = {$_REQUEST['admin_id']}") : ''; ($_REQUEST['company_id'] || $_REQUEST['company_id'] == '0') ? ($map['company_id'] = $_REQUEST['company_id']) : ''; - $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; - $map['admin_id'] = $admin_id; - $map['is_settlement'] = 0; - if (is_administrator() || session('user_group_id') == 15 || session('user_group_id') == 14 || session('user_group_id') == 19 || session('user_group_id') == 23) { - unset($map['admin_id']); - $admin_data = M("member") - ->field("access.uid admin_id") - ->join("left join sys_auth_group_access access on sys_member.uid = access.uid") - ->join("left join sys_auth_group auth on access.group_id=auth.id") - ->where(['group_id' => ['in', '11,12,21']]) - ->select(); - if ($admin_data) { - $map['admin_id'] = ['in', array_column($admin_data, 'admin_id')]; - } - $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; + if($this->MarketEvent->getConfig('isMarket')){ + $map['admin_id'] = ['in',$this->MarketEvent->getAdminidByLeaderid()] ; } $search_date = []; @@ -479,7 +446,7 @@ class MarketPercentageController extends ThinkController } $data = M("auth_group") - ->where(['title' => ['like', '%市场专员%']]) + ->where(['department_id' => ['in', $this->MarketEvent->getConfig('MarketDepartmentId')]]) ->select(false); $member = M("auth_group_access") @@ -616,18 +583,17 @@ class MarketPercentageController extends ThinkController } else { - $map['id'] =['in',A("Market","Event")->getNoLeaderMarketGroupId()]; - $data = M("auth_group") - ->where($map) - ->select(false); + $map['sys_auth_group_access.uid'] =['in',$this->MarketEvent->getAdminidByLeaderid()]; + $map['auth.id'] =['in',$this->MarketEvent->getNoLeaderMarketGroupId()]; $data = M("auth_group_access") ->field("sys_member.nickname,sys_member.real_name,sys_member.uid,sys_auth_group_access.group_id,IF(coefficient is not NULL, coefficient, 100) coefficient,sys_ucenter_member.leave_time") - ->join("left join ({$data}) auth on auth.id = sys_auth_group_access.group_id") + ->join("left join sys_auth_group auth on auth.id = sys_auth_group_access.group_id") ->join("left join sys_member on sys_member.uid = sys_auth_group_access.uid") ->join("left join sys_ucenter_member on sys_member.uid = sys_ucenter_member.id") ->join("left join tab_coefficient on tab_coefficient.admin_id = sys_member.uid and pay_time='{$pay_time}'") ->where("auth.title is not null") + ->where($map) ->select(); $hideTime = strtotime(date('Y-m-01') . " - 1 month")-1; foreach ($data as &$v) { @@ -652,23 +618,12 @@ class MarketPercentageController extends ThinkController //获取权限 $marketPercentage = M("auth_group")->where($map)->getField("id,market_percentage"); - - $_REQUEST['admin_id'] ? ($map['admin_id'] = $_REQUEST['admin_id']) : ''; $_REQUEST['level'] ? ($map['level'] = $_REQUEST['level']) : ''; - - $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; - $gid = session('user_group_id'); - $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid); - if($markerGroup){ - if( $this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){ - $map['admin_id'] = ['in',$this->MarketEvent->getDepartmentUserId($markerGroup['department_id'])]; - }else{ - $map['admin_id'] = $admin_id ; - } - } - $_REQUEST['admin_id'] ? ($map['_string'] .= " AND admin_id = {$_REQUEST['admin_id']}") : ''; + if($this->MarketEvent->getConfig('isMarket')){ + $map['admin_id'] = ['in',$this->MarketEvent->getAdminidByLeaderid()] ; + } $search_date = []; if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { @@ -1036,17 +991,10 @@ class MarketPercentageController extends ThinkController } } - $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; - $gid = session('user_group_id'); - $markerGroup = $this->MarketEvent->isMarketAdminGroup($gid); - if($markerGroup){ - if( $this->MarketEvent->isDepartmentLeder($markerGroup['department_id'],$admin_id)){ - $map['admin_id'] = ['in',$this->MarketEvent->getDepartmentUserId($markerGroup['department_id'])]; - }else{ - $map['admin_id'] = $admin_id ; - } - } $_REQUEST['admin_id'] ? ($map['_string'] .= " AND admin_id = {$_REQUEST['admin_id']}") : ''; + if($this->MarketEvent->getConfig('isMarket')){ + $map['admin_id'] = ['in',$this->MarketEvent->getAdminidByLeaderid()] ; + } $search_date = []; diff --git a/Application/Admin/Event/MarketEvent.class.php b/Application/Admin/Event/MarketEvent.class.php index b757985db..859aedb6e 100644 --- a/Application/Admin/Event/MarketEvent.class.php +++ b/Application/Admin/Event/MarketEvent.class.php @@ -14,7 +14,22 @@ class MarketEvent extends Controller '3'=>'高级', '4'=>'经理' ]; + private $uid; + private $gid; + private $isMarket = false; + private $isInit = false; + public function defaultInit() + { + if($isInit) return $this; + $this->uid = $_SESSION['onethink_admin']['user_auth']['uid']; + $this->gid = session('user_group_id'); + $info = $this->isMarketAdminGroup($this->gid); + if($info){ + $this->isMarket = true; + } + return $this; + } /** * 获取所有市场部组id */ @@ -78,7 +93,7 @@ class MarketEvent extends Controller */ public function getConfig($key) { - return $this->$key; + return $this->defaultInit()->$key; } /** * 获取等级名称 @@ -87,6 +102,11 @@ class MarketEvent extends Controller { return $this->LevelConfig[$level]; } + /** + * 是否是市场专员 + * @param [int] $gid 管理组id + * @return boolean + */ public function isMarketAdminGroup($gid) { $where = [ @@ -95,19 +115,18 @@ class MarketEvent extends Controller ]; return M('auth_group','sys_')->field("id,department_id,department_level")->where($where)->find(); } - + /** + * 是否是某个部门领导 + * @param int $department_id 部门id + * @param int $uid 管理员id + * @return boolean + */ public function isDepartmentLeder($department_id,$uid) { $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 @@ -239,5 +258,28 @@ class MarketEvent extends Controller session('user_auth_company_ids', $companyIds); return $companyIds; } + + /** + * 获取部门领导管辖的所有用户,非领导返回自己 + * + * @param int $value uid/null时候为自己 + * @param string $type uid/group_id + * @return array + */ + public function getAdminidByLeaderid($uid=null) + { + $this->defaultInit(); + if($uid){ + $gid = M("auth_group_access")->where("uid = '{$uid}'")->getField('group_id'); + }else{ + $uid = $this->uid; + $gid = $this->gid; + } + $group_ids = M('department','sys_')->where("leader_group = '{$gid}'")->getField("group_concat(group_ids) as group_ids"); + if(!$group_ids) return $uid; + + $adminIds = M("auth_group_access")->where("group_id in ({$group_ids})")->getField('uid',true); + return $adminIds ?? $uid; + } } \ No newline at end of file diff --git a/Application/Admin/View/MarketPercentage/coefficient.html b/Application/Admin/View/MarketPercentage/coefficient.html index 9c62368a9..a48112313 100644 --- a/Application/Admin/View/MarketPercentage/coefficient.html +++ b/Application/Admin/View/MarketPercentage/coefficient.html @@ -95,7 +95,7 @@