wesmiler %!s(int64=2) %!d(string=hai) anos
pai
achega
0ce940d3d4
Modificáronse 2 ficheiros con 33 adicións e 7 borrados
  1. 22 0
      app/Models/MemberModel.php
  2. 11 7
      app/Services/Api/MemberService.php

+ 22 - 0
app/Models/MemberModel.php

@@ -57,6 +57,28 @@ class MemberModel extends BaseModel
     }
     }
 
 
     /**
     /**
+     * 滑落推荐人
+     * @return \Illuminate\Database\Eloquent\Relations\HasOne
+     */
+    public function point()
+    {
+        return $this->hasOne(MemberModel::class, 'id','point_id')
+            ->where(['mark'=>1])
+            ->select(['id','nickname','parent_id','point_id','balance','usdt','email','mobile','username','status']);
+    }
+
+    /**
+     * 等级
+     * @return \Illuminate\Database\Eloquent\Relations\HasOne
+     */
+    public function level()
+    {
+        return $this->hasOne(MemberLevelModel::class, 'id','member_level')
+            ->where(['mark'=>1])
+            ->select(['id','name','upgrade_usdt','upgrade_usdt_profit','power_multiple','box_num','score_rate','global_bonus_rate','status']);
+    }
+
+    /**
      * 获取会员信息
      * 获取会员信息
      * @param int $id 会员ID
      * @param int $id 会员ID
      * @return array|string
      * @return array|string

+ 11 - 7
app/Services/Api/MemberService.php

@@ -82,9 +82,9 @@ class MemberService extends BaseService
         }
         }
         $field = $field ? $field : $defaultField;
         $field = $field ? $field : $defaultField;
         if (is_array($where)) {
         if (is_array($where)) {
-            $info = $this->model->with(['merchant','acceptor','parent'])->where('mark',1)->where($where)->select($field)->first();
+            $info = $this->model->with(['merchant','acceptor','parent','point','level'])->where('mark',1)->where($where)->select($field)->first();
         } else {
         } else {
-            $info = $this->model->with(['merchant','acceptor','parent'])->where('mark',1)->where(['id' => (int)$where])->select($field)->first();
+            $info = $this->model->with(['merchant','acceptor','parent','point','level'])->where('mark',1)->where(['id' => (int)$where])->select($field)->first();
         }
         }
 
 
         $info = $info ? $info->toArray() : [];
         $info = $info ? $info->toArray() : [];
@@ -119,7 +119,9 @@ class MemberService extends BaseService
                 $info['live_open'] = $info['member_level']>=$liveOpenLevel? 1 : 0;
                 $info['live_open'] = $info['member_level']>=$liveOpenLevel? 1 : 0;
             }
             }
             else if ($type == 'team') {
             else if ($type == 'team') {
-
+                $info['team_count1'] = $this->getUserCountByType($info['id'], 1, 0); // 直推人数
+                $info['team_count2'] = $this->getUserCountByType($info['id'], 3, 0); // 滑落人数
+                $info['team_count'] = $this->getUserCountByType($info['id'], 1, 1); // 节点推荐人数
             }else {
             }else {
                 // 默认地址
                 // 默认地址
                 $info['addressData'] = MemberAddressService::make()->getBindInfo($info['id']);
                 $info['addressData'] = MemberAddressService::make()->getBindInfo($info['id']);
@@ -231,16 +233,18 @@ class MemberService extends BaseService
         $data = $this->model->where($where)
         $data = $this->model->where($where)
             ->where(function ($query) use ($type, $isPoint, $userId) {
             ->where(function ($query) use ($type, $isPoint, $userId) {
                 if($isPoint){
                 if($isPoint){
-                    if ($type == 1) {
+                    if ($type == 1) { // 滑落推荐
                         $query->where('point_id', $userId);
                         $query->where('point_id', $userId);
-                    }  else if($type == 2){
+                    }  else if($type == 2){ // 滑落团队人数
                         $query->whereRaw('FIND_IN_SET(?,points)', $userId);
                         $query->whereRaw('FIND_IN_SET(?,points)', $userId);
                     }
                     }
                 }else{
                 }else{
-                    if ($type == 1) {
+                    if ($type == 1) { // 直推人数
                         $query->where('parent_id', $userId);
                         $query->where('parent_id', $userId);
-                    }  else if($type == 2){
+                    }  else if($type == 2){  // 团队人数
                         $query->whereRaw('FIND_IN_SET(?,parents)', $userId);
                         $query->whereRaw('FIND_IN_SET(?,parents)', $userId);
+                    }  else if($type == 3){ // 滑落人数
+                        $query->where('parent_id', $userId)->where('point_id','!=', $userId);
                     }
                     }
                 }
                 }
             })->count('id');
             })->count('id');