Ver código fonte

refactor(store): 修改购物车数据查询方法以支持按购物车ID过滤

- 更新 StoreCartDao 中的 getCartEntityListByUidAndProductIdList 方法签名
- 添加 cartId 参数到数据访问层查询条件中
- 在 StoreCartRepository 中同步修改方法定义和调用
- 更新 StoreOrderRepository 中的相关方法调用以传递 cartId 参数
shichen 4 meses atrás
pai
commit
42cb81e207

+ 2 - 1
app/common/dao/store/order/StoreCartDao.php

@@ -247,7 +247,7 @@ class StoreCartDao extends BaseDao
247 247
         return $entityList;
248 248
     }
249 249
 
250
-    public function getCartEntityListByUidAndProductIdList(int $uid, array $productIdList): array
250
+    public function getCartEntityListByUidAndProductIdListAndCartId(int $uid, array $productIdList, int $cartId): array
251 251
     {
252 252
         $entityList = [];
253 253
         try {
@@ -255,6 +255,7 @@ class StoreCartDao extends BaseDao
255 255
             $model = $this->getModel();
256 256
             $dataListRes = $model::getDB()
257 257
                 ->where('uid', '=', $uid)
258
+                ->where('cart_id', '=', $cartId)
258 259
                 ->whereIn('product_id', $productIdList)
259 260
                 ->select()
260 261
                 ->toArray();

+ 2 - 2
app/common/repositories/store/order/StoreCartRepository.php

@@ -167,8 +167,8 @@ class StoreCartRepository extends BaseRepository
167 167
         return $this->dao->getCartEntityListByUidAndProductIdListAndIsPay($uid, $productIdList);
168 168
     }
169 169
 
170
-    public function getCartEntityListByUidAndProductIdList(int $uid, array $productIdList): array
170
+    public function getCartEntityListByUidAndProductIdListAndCartId(int $uid, array $productIdList, int $cartId): array
171 171
     {
172
-        return $this->dao->getCartEntityListByUidAndProductIdList($uid, $productIdList);
172
+        return $this->dao->getCartEntityListByUidAndProductIdListAndCartId($uid, $productIdList, $cartId);
173 173
     }
174 174
 }

+ 1 - 1
app/common/repositories/store/order/StoreOrderRepository.php

@@ -11739,7 +11739,7 @@ class StoreOrderRepository extends BaseRepository
11739 11739
             // 特定商品发放幸福币
11740 11740
             /** @var StoreCartRepository $storeCartRepository */
11741 11741
             $storeCartRepository = app()->make(StoreCartRepository::class);
11742
-            $storeCartEntity = $storeCartRepository->getCartEntityListByUidAndProductIdList($storeOrderEntity->getUid(), [90619]);
11742
+            $storeCartEntity = $storeCartRepository->getCartEntityListByUidAndProductIdListAndCartId($storeOrderEntity->getUid(), [90619], $storeOrderEntity->getCartId());
11743 11743
             if (!empty($storeCartEntity)) {
11744 11744
                 $xfbData = [
11745 11745
                     'uid' => $sharedProsperityUserEntity->getUserId(),