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'];