From 908968961c56506b2368fe9ec2bf1232977ba1ba Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Tue, 23 Jan 2024 11:47:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=B4=BB=E5=8A=A8=E5=95=86?= =?UTF-8?q?=E5=93=81=E9=99=90=E8=B4=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/order/StoreOrderCreateRepository.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index a6b3813a..fc91d364 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -77,6 +77,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository $order_extend = []; //检查商品类型, 活动商品只能单独购买 $allowDelivery = true; + $activityProductCount = 0; foreach ($merchantCartList as $merchantCart) { if (($merchantCart['type_id'] != Merchant::TypeSupplyChain) && $address) { if ($merchantCart['street_id'] != $address['street_code'] && $createOrder && !in_array($merchantCart['mer_id'], $takes)) { @@ -85,9 +86,15 @@ class StoreOrderCreateRepository extends StoreOrderRepository } foreach ($merchantCart['list'] as $cart) { $canBuy = (new StoreActivityDao())->canBuy($cart['uid'], $cart['product_id']); - if (!$canBuy || ($canBuy == 2 && $cart['cart_num'] > 1)){ + if (!$canBuy) { throw new ValidateException('活动商品限购1个'); } + if ($canBuy == 2) { + $activityProductCount += $cart['cart_num']; + if ($activityProductCount > 1){ + throw new ValidateException('活动商品限购1个'); + } + } if ($cart['product_type'] == 0) { if ($cart['product']['once_min_count'] > 0 && $cart['product']['once_min_count'] > $cart['cart_num']) throw new ValidateException('[低于起购数:' . $cart['product']['once_min_count'] . ']' . mb_substr($cart['product']['store_name'], 0, 10) . '...');