From faa2e16f7abe1d7ded3621aba78e0a44666d81ee Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Wed, 23 Aug 2023 16:05:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=87=87=E8=B4=AD=E5=95=86?= =?UTF-8?q?=E5=93=81=E7=BB=93=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/StoreOrderCreateRepository.php | 22 +++++++++++-------- .../store/order/StoreOrderRepository.php | 12 ++++++---- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 43d77f02..1918e21d 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -102,17 +102,21 @@ class StoreOrderCreateRepository extends StoreOrderRepository } $community = []; if ($order_type == 98) { - $communityIdArray = []; + $sourceIdArray = []; foreach($merchantCart['list'] as $prod){ - $communityIdArray[] = $prod['source_id'] ?? 0; + if ($prod['source_id'] > 0) { + $sourceIdArray[] = $prod['source_id']; + } } - if (count(array_unique($communityIdArray)) > 1) { - throw new ValidateException('转售商品数据异常'); - } - $community = Db::name('Community')->where('community_id', $communityIdArray[0] ?? 0)->field('community_id, title, image')->fetchSql(false)->find(); - if ($community) { - $deliverMethod = Db::name('resale')->where('community_id', $communityIdArray[0] ?? 0)->value('deliver_method'); - $deliverMethodArray = explode(',', $deliverMethod); + if (count($sourceIdArray)) { + if (count(array_unique($sourceIdArray)) > 1) { + throw new ValidateException('转售商品数据异常'); + } + $community = Db::name('Community')->where('community_id', $communityIdArray[0] ?? 0)->field('community_id, title, image')->fetchSql(false)->find(); + if ($community) { + $deliverMethod = Db::name('resale')->where('community_id', $communityIdArray[0] ?? 0)->value('deliver_method'); + $deliverMethodArray = explode(',', $deliverMethod); + } } } unset($merchantCart, $cart); diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 6f03dc5a..3a9acc52 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -527,11 +527,15 @@ class StoreOrderRepository extends BaseRepository return $cart['activeSku']['active_price']; // 更新调货价格 } else if ($cart['product_type'] == '98') { - $price = Db::name('resale')->where('community_id', $cart['source_id'])->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price'); - if ($price) { - return $price; + if ($cart['source_id'] > 0) { + $price = Db::name('resale')->where('community_id', $cart['source_id'])->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price'); + if ($price) { + return $price; + } else { + throw new ValidateException('转售商品数据异常'); + } } else { - throw new ValidateException('转售商品数据异常'); + return $cart['productAttr']['price']; } } else { return $cart['productAttr']['price'];