|
|
@@ -234,11 +234,15 @@ class MemberService extends BaseService
|
|
|
// 滑落节点
|
|
|
$pointId = 0;
|
|
|
$points = '';
|
|
|
+ $pointSorts = '';
|
|
|
if($rid>0){
|
|
|
- $pointId = $this->getPointParentId($rid);
|
|
|
+ $pointData = $this->getPointParentId($rid);
|
|
|
+ $pointId = isset($pointData['point_id'])?$pointData['point_id'] : 0;
|
|
|
+ $pointSort = isset($pointData['point_sort']) && $pointData['point_sort']?$pointData['point_sort'] : 0;
|
|
|
if($pointId){
|
|
|
- $pointParent = $this->model->where(['id'=> $pointId,'mark'=>1])->select(['id','points'])->first();
|
|
|
+ $pointParent = $this->model->where(['id'=> $pointId,'mark'=>1])->select(['id','points','point_sort'])->first();
|
|
|
$points = isset($pointParent['points']) && $pointParent['points']? $pointParent['points'].$pointId.',' : ($pointId ? $pointId . ',' : '');
|
|
|
+ $pointSorts = isset($pointParent['point_sort']) && $pointParent['point_sort']? $pointParent['point_sort'].''.$pointSort : $pointSort;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -254,6 +258,7 @@ class MemberService extends BaseService
|
|
|
'buy_type' => $areaId,
|
|
|
'area_id' => $areaId,
|
|
|
'points' => $points,
|
|
|
+ 'point_sort' => $pointSorts,
|
|
|
'code' => get_random_code(9, 'Q', $userId),
|
|
|
'password' => get_password('a123456'),
|
|
|
'login_ip' => get_client_ip(),
|
|
|
@@ -319,7 +324,25 @@ class MemberService extends BaseService
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
- $userList = $this->model->where(['mark'=> 1])->whereRaw('FIND_IN_SET(?,points)', $userId)->select(['id','point_id','points'])->orderBy('id','asc')->get();
|
|
|
+ // 上级
|
|
|
+ $parentId = $this->model->where(['id'=>$userId])->value('parent_id');
|
|
|
+
|
|
|
+ // 自己团队和平级用户
|
|
|
+ $userList = $this->model->where(['mark'=> 1])
|
|
|
+ ->whereNotIn('id',[$userId])
|
|
|
+ ->where(function($query) use($userId,$parentId){
|
|
|
+ $query->whereRaw('FIND_IN_SET(?,points)', $userId);
|
|
|
+
|
|
|
+ // 节点平级用户
|
|
|
+ if($parentId>0){
|
|
|
+ $query->orWhereRaw('point_id', $parentId);
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ ->select(['id','point_id','point_sort','points'])
|
|
|
+ ->orderBy('point_sort','asc')
|
|
|
+ ->orderBy('id','asc')
|
|
|
+ ->get();
|
|
|
$userList = $userList? $userList->toArray() : [];
|
|
|
if(count($userList) < 2){
|
|
|
return $userId;
|
|
|
@@ -329,7 +352,6 @@ class MemberService extends BaseService
|
|
|
foreach($userList as $item){
|
|
|
$points = isset($item['points']) && $item['points']? explode(',', $item['points']) : [];
|
|
|
$points = array_filter($points);
|
|
|
-
|
|
|
$users[$item['id']]['pointLen'] = count($points);
|
|
|
$users[$item['id']]['children'] = isset($users[$item['id']]['children'])? $users[$item['id']]['children'] : 0;
|
|
|
$users[$item['point_id']]['children'] = isset($users[$item['point_id']]['children'])? $users[$item['point_id']]['children'] + 1 : 1;
|
|
|
@@ -337,7 +359,7 @@ class MemberService extends BaseService
|
|
|
|
|
|
$pointId = 0;
|
|
|
$tempPointLen = 0;
|
|
|
- //$tempChildren = 0;
|
|
|
+ $tempChildren = 0;
|
|
|
foreach ($userList as $item) {
|
|
|
$id = isset($item['id'])? $item['id'] : 0;
|
|
|
$children = isset($users[$id]['children'])? $users[$id]['children'] : 0;
|
|
|
@@ -347,12 +369,12 @@ class MemberService extends BaseService
|
|
|
if($children < 2 && $pointId <= 0){
|
|
|
$pointId = $id;
|
|
|
$tempPointLen = $pointLen;
|
|
|
- //$tempChildren = $children;
|
|
|
+ $tempChildren = $children+1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- return $pointId;
|
|
|
+ return ['point_id'=>$pointId,'point_sort'=>$tempChildren];
|
|
|
}
|
|
|
|
|
|
|