APPLE 3 лет назад
Родитель
Сommit
cfb54c5cf3
1 измененных файлов с 9 добавлено и 7 удалено
  1. 9 7
      app/Services/Common/TradeService.php

+ 9 - 7
app/Services/Common/TradeService.php

@@ -332,20 +332,22 @@ class TradeService extends BaseService
      */
     public function getUserTradeTotal($userId, $status = 0, $time = 0)
     {
-        $where = ['user_id' => $userId, 'mark' => 1];
-        return $this->model->where($where)
+        $where = ['a.user_id' => $userId, 'a.mark' => 1,'b.status'=>1];
+        return $this->model->from('trade as a')
+            ->leftJoin('member as b','b.id','=','a.user_id')
+            ->where($where)
             ->where(function ($query) use ($status, $time) {
-                $query->whereIn('status', is_array($status) ? $status : [$status]);
+                $query->whereIn('a.status', is_array($status) ? $status : [$status]);
 
                 // 本月
                 if ($time == 1) {
-                    $query->where('pay_time', '>=', strtotime(date('Y-m-01')));
+                    $query->where('a.pay_time', '>=', strtotime(date('Y-m-01')));
                 } // 今日
                 else if ($time == 2) {
-                    $query->where('pay_time', '>=', strtotime(date('Y-m-d')));
+                    $query->where('a.pay_time', '>=', strtotime(date('Y-m-d')));
                 }
             })
-            ->sum('real_price');
+            ->sum('a.real_price');
     }
 
     /**
@@ -357,7 +359,7 @@ class TradeService extends BaseService
      */
     public function getTeamTradeTotal($userId, $status = 0, $time = 0)
     {
-        $where = ['b.parent_id' => $userId, 'a.mark' => 1];
+        $where = ['b.parent_id' => $userId, 'a.mark' => 1,'b.status'=>1];
         return $this->model->from('trade as a')
             ->leftJoin('member as b', 'b.id', '=', 'a.user_id')
             ->where($where)