@ -44,15 +44,10 @@ function get_promote_list_by_id($id=0) {
if(is_numeric($id) & & $id>=0) {
$map['parent_id'] = $id;
$list = $query->where($map)->select();
} elseif(is_array($id)) {
$map['parent_id'] = array('in',$id);
$list = $query->where($map)->select();
} elseif(is_numeric($id) & & $id< 0 ) {
$list = $query->where($map)->select();
} else {
$list = '';
}
$list = $query->where($map)->select();
return $list;
}
@ -1590,7 +1585,8 @@ function getPowerPromoteIds()
if ($myPromote_ids) {
if ($userAuth['data_empower_type'] == 2) {//部分会长加上自己创建的会长
$userAuth['data_president'] .= "," . $myPromote_ids;
// $userAuth['data_president'] .= "," . $myPromote_ids;
} elseif ($userAuth['data_empower_type'] == 3) {//自己创建的会长和底下推广员
$userAuth['data_president'] = $myPromote_ids;
}
@ -1598,6 +1594,7 @@ function getPowerPromoteIds()
if (!empty($userAuth['data_president'])) {//查询有权限查看的会长以及底下的推广员
$map = array();
//查询会长底下的推广员(首个斜杆之间的数字)
$userAuth['data_president']= trim($userAuth['data_president'], ",");
$where['SUBSTRING_INDEX(SUBSTRING_INDEX(`chain`,"/",2),"/",-1)'] = array('exp',"IN({$userAuth['data_president']})");
$where['id'] = array('in', $userAuth['data_president']);//会长本身
$where['_logic'] = 'or';
@ -1619,11 +1616,17 @@ function getPowerPromoteIds()
return $promoteIds;
}
/**
* 为数据权限添加筛选参数
* @param array $map 查询条件
* @param string $column 字段名, 默认为promote_id
* @return mixed
*/
function setPowerPromoteIds(& $map, $column = 'promote_id') {
//为数据权限添加
$promoteIds = getPowerPromoteIds();
if (empty($promoteIds)) {
$map[$column] = -1;
$map[$column] = -1;//没权限时将promote_id置为-1
} elseif ($promoteIds != 'all') {
if (isset($map[$column])) {
if (isset($map['_string'])) {//查询字段中已存在promote_id, 不覆盖此条件而处理
@ -1697,4 +1700,19 @@ function get_admin_listOther()
if(empty($list)){return false;}
return $list;
}
/**
* 根据会长id底下的推广员id
* @param $promote_id
* @return mixed
*/
function getOffspringByPromoteId($promote_id) {
$promote_ids = M('promote', 'tab_')
->where(['chain' => ['like', "%/{$promote_id}/%"]])
->field('group_concat(id) as promote_ids')
->find();
return $promote_ids['promote_ids'];
}
?>