wesmiler преди 4 месеца
родител
ревизия
2864715e4d
променени са 1 файла, в които са добавени 2 реда и са изтрити 1 реда
  1. 2 1
      app/Services/Api/CartService.php

+ 2 - 1
app/Services/Api/CartService.php

@@ -63,6 +63,7 @@ class CartService extends BaseService
             $query = $this->getQuery($params)
                 ->orderBy('a.create_time', 'desc')
                 ->orderBy('a.id', 'desc');
+            $count = $query->count('a.id');
 
             $field = ["a.*"];
             $list = $query->select($field)
@@ -73,6 +74,7 @@ class CartService extends BaseService
                 $datas = [
                     'pageSize' => $pageSize,
                     'total' => isset($list['total']) ? $list['total'] : 0,
+                    'count' => $count,
                     'list' => isset($list['data']) ? $list['data'] : []
                 ];
 
@@ -100,7 +102,6 @@ class CartService extends BaseService
         }
 
         $model = $this->model->with(['store','cartGoods'])
-            ->withCount(['cartGoods'])
             ->from('carts as a')
             ->leftJoin('goods as b', 'b.id', '=', 'a.goods_id')
             ->where($where)