wesmiler 1 rok pred
rodič
commit
d4aecc0d4f

+ 1 - 0
app/Services/Api/PledgeOrderService.php

@@ -382,6 +382,7 @@ class PledgeOrderService extends BaseService
             $this->error =  $this->error = lang(4109,['uid'=> $userId,'round'=>$round]);
             RedisService::clear("caches:pledge:lock_{$userId}_{$round}");
             RedisService::clear("caches:pledgeOrder:total_{$userId}");
+            RedisService::clear("caches:pledge:check_{$userId}");
             RedisService::clear("caches:pledge:counts_{$userId}");
             return ['user_id'=>$userId,'round'=>$round,'money'=>$pledgeUsdt,'msg'=>'自动质押成功'];
         } catch (\Exception $exception){

+ 56 - 0
app/Services/Common/BalanceLogService.php

@@ -239,6 +239,62 @@ class BalanceLogService extends BaseService
     }
 
     /**
+     * 团队真实/上下分充提数据
+     * @param $userId 用户ID
+     * @param int $type
+     * @return array|int[]|mixed
+     */
+    public function getTeamTotalByUser($userId, $type=1)
+    {
+        $cacheKey = "caches:balanceLog:teamTotal_{$userId}_{$type}";
+        $data = RedisService::get($cacheKey);
+        if($data || RedisService::exists($cacheKey)){
+            return $data?$data:['recharge'=>0,'withdraw'=>0,'difference'=>0];
+        }
+
+        // 真实充提
+        if($type == 1){
+            $recharge = $this->model->from('balance_logs as a')
+                ->leftJoin('member as b','a.user_id','b.id')
+                ->where(function($query) use($userId){
+                    $query->whereRaw("FIND_IN_SET({$userId},lev_b.parent_ids)")->orWhere('a.user_id', $userId);
+                })
+                ->where(['a.type'=>1,'a.mark'=>1,'b.mark'=>1])
+                ->whereIn('a.status',[1,2])
+                ->sum('a.money');
+
+            $withdraw = $this->model->from('balance_logs as a')
+                ->leftJoin('member as b','a.user_id','b.id')
+                ->where(function($query) use($userId){
+                    $query->whereRaw("FIND_IN_SET({$userId},lev_b.parent_ids)")->orWhere('a.user_id', $userId);
+                })
+                ->where(['a.type'=>2,'a.mark'=>1,'b.mark'=>1])
+                ->whereIn('a.status',[1,2])
+                ->sum('a.money');
+        }else{
+            // 上下分
+            $recharge = AccountLogModel::from('account_log as a')
+                ->leftJoin('member as b','a.user_id','b.id')
+                ->where(function($query) use($userId){
+                    $query->whereRaw("FIND_IN_SET({$userId},lev_b.parent_ids)")->orWhere('a.user_id', $userId);
+                })
+                ->where(['a.type'=>5,'a.status'=>1,'a.mark'=>1,'b.mark'=>1])
+                ->sum('a.money');
+            $withdraw = AccountLogModel::from('account_log as a')
+                ->leftJoin('member as b','a.user_id','b.id')
+                ->where(function($query) use($userId){
+                    $query->whereRaw("FIND_IN_SET({$userId},lev_b.parent_ids)")->orWhere('a.user_id', $userId);
+                })
+                ->where(['a.type'=>6,'a.status'=>1,'a.mark'=>1,'b.mark'=>1])
+                ->sum('a.money');
+        }
+
+        $data = ['recharge'=>$recharge,'withdraw'=>$withdraw,'difference'=>round($recharge - $withdraw, 2)];
+        RedisService::set($cacheKey, $data, rand(5,10));
+        return $data;
+    }
+
+    /**
      * 提现审核
      * @param $params
      * @return bool

+ 5 - 0
app/Services/Common/MemberService.php

@@ -109,6 +109,11 @@ class MemberService extends BaseService
                 $item['is_pledge'] = $pledgeData? 1 : 0;
                 $item['recharge_total'] = BalanceLogService::make()->getTotalByUser($item['id']);
                 $item['withdraw_total'] = BalanceLogService::make()->getTotalByUser($item['id']);
+
+                $rechargeData = BalanceLogService::make()->getTeamTotalByUser($item['id'], 1);
+                $ptRechargeData = BalanceLogService::make()->getTeamTotalByUser($item['id'], 2);
+                $item['team_recharge'] = $rechargeData;
+                $item['pt_recharge'] = $ptRechargeData;
             }
 
             RedisService::set($cacheKey, $list, rand(3,5));