|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|