From 42881595aaeeb589e815d98e78c213f882d86f07 Mon Sep 17 00:00:00 2001 From: liuweiwen <“529520975@qq.com> Date: Fri, 13 Dec 2019 14:37:52 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=BD=93=E5=89=8D=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E6=9C=89=E6=9D=83=E9=99=90=E6=9F=A5=E7=9C=8B?= =?UTF-8?q?=E6=89=80=E6=9C=89=E6=8E=A8=E5=B9=BF=E5=91=98id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 73 +++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 1d6b3fb72..c13ccf1a2 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -1541,4 +1541,77 @@ function getGameList($partner_id) { return $data; } +function getAdminData ($uid) { + $adminData = M('auth_group_access') + ->field('data_empower_type,data_president') + ->join('left join sys_auth_group on sys_auth_group_access.group_id=sys_auth_group.id') + ->where(array('uid'=>$uid))->find(); + + $promoteData = M('promote','tab_')->field('id')->where(array('admin_id'=>$uid))->select(); + $promoteData = implode(',',array_column($promoteData,'id')); + $adminData['data_president'] = $adminData['data_president'].','.$promoteData; + + return $adminData; +} + +/** + * 获取当前管理员有权限查看所有推广员id + * @return mixed|string 格式如;all-全部;1,2,3;为空表示都没有权限 + */ +function getPowerPromoteIds() +{ + //session已存在当前管理员可查看数据的推广员id,则直接返回,权限有变化事删除此session + if (!empty(session('user_auth_promote_ids'))) { + return session('user_auth_promote_ids'); + } + $userAuth = session('user_auth'); + $promoteIds = 'all'; + $userAuth['data_president']= trim($userAuth['data_president'], ","); + if (!empty($userAuth['data_empower_type'])) {//数据权限 1 全部 2 部分数据 3 自己底下的会长 + //等于1默认全部数据,不进行筛选 + if (in_array($userAuth['data_empower_type'], [2, 3])) { + $promoteIds = ''; + //自己创建的会长 + $myPromote_ids = M('promote', 'tab_') + ->field('GROUP_CONCAT(id) as promote_ids') + ->where(['admin_id' => $userAuth['uid']]) + ->find(); + $myPromote_ids = $myPromote_ids['promote_ids']; + + if ($myPromote_ids) { + if ($userAuth['data_empower_type'] == 2) {//部分会长加上自己创建的会长 + $userAuth['data_president'] .= "," . $myPromote_ids; + } elseif ($userAuth['data_empower_type'] == 3) {//自己创建的会长和底下推广员 + $userAuth['data_president'] = $myPromote_ids; + } + } + if (!empty($userAuth['data_president'])) {//查询有权限查看的会长以及底下的推广员 + $map = array(); + //查询会长底下的推广员(首个斜杆之间的数字) + $where['SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,"/",2),"/",-1)'] = array('exp',"IN({$userAuth['data_president']})"); + $where['id'] = array('in', $userAuth['data_president']);//会长本身 + $where['_logic'] = 'or'; + $map['_complex'] = $where; + $sqlResult = M('promote', 'tab_') + ->field('GROUP_CONCAT(id) as promote_ids') + ->where($map) + ->find(); + $promoteIds = $sqlResult['promote_ids']; + } + } + } + session('user_auth_promote_ids', $promoteIds); + return $promoteIds; +} + +function setPowerPromoteIds(&$map, $column = 'promote_id') { + //为数据权限添加 + $promoteIds = getPowerPromoteIds(); + if (empty($promoteIds)) { + $map[$column] = 0; + } elseif ($promoteIds != 'all') { + $map[$column] = array('in', $promoteIds); + } +} + ?>