diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index 1ff34999..ee3a2e5d 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -102,18 +102,19 @@ class StoreOrderCreateRepository extends StoreOrderRepository } $community = []; if ($order_type == 98) { - $attrUniqueArray = []; + $communityIdArray = []; foreach($merchantCart['list'] as $prod){ - $attrUniqueArray[] = $prod['product_attr_unique']; + $communityIdArray[] = $prod['source_id'] ?? 0; } - $attrInfo = Db::name('Resale')->alias('r')->leftJoin('Community c','r.community_id = c.community_id')->whereIn('r.product_attr_unique', $attrUniqueArray)->distinct(true)->field('c.community_id, c.title, c.image')->fetchSql(false)->select(); - if (count($attrInfo) > 1) { + 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) { throw new ValidateException('转售商品数据异常'); } - $community = $attrInfo[0] ?? []; } unset($merchantCart, $cart); - $order_price = 0; $total_true_price = 0; $order_total_price = 0; diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 86df02ae..ae88a3e2 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -527,11 +527,11 @@ class StoreOrderRepository extends BaseRepository return $cart['activeSku']['active_price']; // 更新调货价格 } else if ($cart['product_type'] == '98') { - $price = Db::name('resale')->where('product_attr_unique', $cart['product_attr_unique'])->where('status', 0)->value('price'); + $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 { - return $cart['productAttr']['price']; + throw new ValidateException('转售商品数据异常'); } } else { return $cart['productAttr']['price'];