|
|
|
@ -37,44 +37,54 @@ class QueryController extends BaseController
|
|
|
|
|
$row = 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$childPromoteIds = getAllChildPromoteList(3);
|
|
|
|
|
if (empty($childPromoteIds)) {
|
|
|
|
|
$map['tab_spend.promote_id'] = PID;
|
|
|
|
|
} else {
|
|
|
|
|
$childPromoteIds .= ',' . PID;
|
|
|
|
|
|
|
|
|
|
$map['tab_spend.promote_id'] = ['in', $childPromoteIds];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$teamLeaderId = intval(I('team_leader_id'));//组长账号
|
|
|
|
|
if (!empty($teamLeaderId)) {
|
|
|
|
|
$hasTeamLeaderPermission = hasPromotePermission(PID, $teamLeaderId);
|
|
|
|
|
if ($hasTeamLeaderPermission === false) {
|
|
|
|
|
$this->error('组长权限异常');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$childPromoteIds = getAllChildPromoteList(3, $teamLeaderId);
|
|
|
|
|
if (empty($childPromoteIds)) {
|
|
|
|
|
$map['tab_spend.promote_id'] = $teamLeaderId;
|
|
|
|
|
} else {
|
|
|
|
|
$childPromoteIds = $teamLeaderId . ',' . $childPromoteIds;
|
|
|
|
|
|
|
|
|
|
$map['tab_spend.promote_id'] = ['in', $childPromoteIds];
|
|
|
|
|
// $childPromoteIds = getAllChildPromoteList(3);
|
|
|
|
|
// if (empty($childPromoteIds)) {
|
|
|
|
|
// $map['tab_spend.promote_id'] = PID;
|
|
|
|
|
// } else {
|
|
|
|
|
// $childPromoteIds .= ',' . PID;
|
|
|
|
|
//
|
|
|
|
|
// $map['tab_spend.promote_id'] = ['in', $childPromoteIds];
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$map1['chain'] = ['like','%'.PID.'/'.'%'];
|
|
|
|
|
$rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select();
|
|
|
|
|
$childPromoteIds = '';
|
|
|
|
|
if(empty($rs)) {
|
|
|
|
|
$map['tab_user.promote_id'] = PID;
|
|
|
|
|
}else {
|
|
|
|
|
foreach ($rs as $rsKey => $rsValue) {
|
|
|
|
|
$id = $rsValue['id'];
|
|
|
|
|
$childPromoteIds .= $id.',';
|
|
|
|
|
}
|
|
|
|
|
$childPromoteIds = rtrim($childPromoteIds, ',');
|
|
|
|
|
$childPromoteIds .= ',' . PID;
|
|
|
|
|
$map['tab_spend.promote_id'] = ['in', $childPromoteIds];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$promoteId = I('promote_id');//推广员账号
|
|
|
|
|
if (!empty($promoteId)) {
|
|
|
|
|
$hasPromotePermission = hasPromotePermission(PID, $promoteId);
|
|
|
|
|
if ($hasPromotePermission === false) {
|
|
|
|
|
$this->error('推广员权限异常');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$map['tab_spend.promote_id'] = $promoteId;
|
|
|
|
|
$levelPromote = I('level_promote', []);
|
|
|
|
|
$promote = $this->getLoginPromote();
|
|
|
|
|
$queryPromote = $this->getQueryPromote($levelPromote);
|
|
|
|
|
$map2['chain'] = ['like', $queryPromote['chain'].$queryPromote['id'].'/%'];
|
|
|
|
|
$ids = M('promote', 'tab_')->where($map2)->getField('id', true);
|
|
|
|
|
if(empty($ids)) {
|
|
|
|
|
$ids = array();
|
|
|
|
|
}
|
|
|
|
|
if(empty($levelPromote)) {
|
|
|
|
|
array_push($ids,PID);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
array_push($ids,$queryPromote['id']);
|
|
|
|
|
if (!empty($ids)) {
|
|
|
|
|
$map['tab_spend.promote_id'] = ['in',$ids];
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
$map['_string'] = '1<>1';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty(I('own_id'))) {
|
|
|
|
|
$map['tab_spend.promote_id'] = I('own_id');//本账号
|
|
|
|
|
$map['tab_spend.promote_id'] = $promote['id'];//本账号
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!empty(I('begtime')) && empty(I('endtime'))) {
|
|
|
|
@ -183,44 +193,52 @@ class QueryController extends BaseController
|
|
|
|
|
$row = 10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$childPromoteIds = getAllChildPromoteList(3);
|
|
|
|
|
if (empty($childPromoteIds)) {
|
|
|
|
|
//$childPromoteIds = getAllChildPromoteList(3);
|
|
|
|
|
// if (empty($childPromoteIds)) {
|
|
|
|
|
// $map['tab_user.promote_id'] = PID;
|
|
|
|
|
// } else {
|
|
|
|
|
// $childPromoteIds .= ',' . PID;
|
|
|
|
|
//
|
|
|
|
|
// $map['tab_user.promote_id'] = ['in', $childPromoteIds];
|
|
|
|
|
// }
|
|
|
|
|
// $map['tab_user.promote_id'] = ['like','%'.PID.'/'.'%'];
|
|
|
|
|
$map1['chain'] = ['like','%'.PID.'/'.'%'];
|
|
|
|
|
$rs = M('promote','tab_')->where($map1)->field('id,account,nickname')->select();
|
|
|
|
|
$childPromoteIds = '';
|
|
|
|
|
if(empty($rs)) {
|
|
|
|
|
$map['tab_user.promote_id'] = PID;
|
|
|
|
|
} else {
|
|
|
|
|
$childPromoteIds .= ',' . PID;
|
|
|
|
|
|
|
|
|
|
$map['tab_user.promote_id'] = ['in', $childPromoteIds];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$teamLeaderId = intval(I('team_leader_id'));//组长账号
|
|
|
|
|
if (!empty($teamLeaderId)) {
|
|
|
|
|
$hasTeamLeaderPermission = hasPromotePermission(PID, $teamLeaderId);
|
|
|
|
|
if ($hasTeamLeaderPermission === false) {
|
|
|
|
|
$this->error('组长权限异常');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$childPromoteIds = getAllChildPromoteList(3, $teamLeaderId);
|
|
|
|
|
if (empty($childPromoteIds)) {
|
|
|
|
|
$map['tab_user.promote_id'] = $teamLeaderId;
|
|
|
|
|
} else {
|
|
|
|
|
$childPromoteIds = $teamLeaderId . ',' . $childPromoteIds;
|
|
|
|
|
|
|
|
|
|
$map['tab_user.promote_id'] = ['in', $childPromoteIds];
|
|
|
|
|
}else {
|
|
|
|
|
foreach ($rs as $rsKey => $rsValue) {
|
|
|
|
|
$id = $rsValue['id'];
|
|
|
|
|
$childPromoteIds .= $id.',';
|
|
|
|
|
}
|
|
|
|
|
$childPromoteIds = rtrim($childPromoteIds, ',');
|
|
|
|
|
$childPromoteIds .= ',' . PID;
|
|
|
|
|
$map['tab_user.promote_id'] = ['in', $childPromoteIds];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$promoteId = I('promote_id');//推广员账号
|
|
|
|
|
if (!empty($promoteId)) {
|
|
|
|
|
$hasPromotePermission = hasPromotePermission(PID, $promoteId);
|
|
|
|
|
if ($hasPromotePermission === false) {
|
|
|
|
|
$this->error('推广员权限异常');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$map['tab_user.promote_id'] = $promoteId;
|
|
|
|
|
$levelPromote = I('level_promote', []);
|
|
|
|
|
$promote = $this->getLoginPromote();
|
|
|
|
|
$queryPromote = $this->getQueryPromote($levelPromote);
|
|
|
|
|
$map2['chain'] = ['like', $queryPromote['chain'].$queryPromote['id'].'/%'];
|
|
|
|
|
$ids = M('promote', 'tab_')->where($map2)->getField('id', true);
|
|
|
|
|
if(empty($ids)) {
|
|
|
|
|
$ids = array();
|
|
|
|
|
}
|
|
|
|
|
if(empty($levelPromote)) {
|
|
|
|
|
array_push($ids,PID);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
array_push($ids,$queryPromote['id']);
|
|
|
|
|
if (!empty($ids)) {
|
|
|
|
|
$map['tab_user.promote_id'] = ['in',$ids];
|
|
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
$map['_string'] = '1<>1';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!empty(I('own_id'))) {
|
|
|
|
|
$map['tab_user.promote_id'] = I('own_id');//本账号
|
|
|
|
|
$map['tab_user.promote_id'] = $promote['id'];//本账号
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!empty(I('begtime')) && empty(I('endtime'))) {
|
|
|
|
|