From 566808e9d0942bd90ecc544ae4c555ce2c412911 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Tue, 23 Jan 2024 11:41:00 +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 --- app/common/dao/store/StoreActivityDao.php | 4 ++-- .../repositories/store/order/StoreOrderCreateRepository.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/common/dao/store/StoreActivityDao.php b/app/common/dao/store/StoreActivityDao.php index 66f21c0a..aea07da9 100644 --- a/app/common/dao/store/StoreActivityDao.php +++ b/app/common/dao/store/StoreActivityDao.php @@ -111,7 +111,7 @@ class StoreActivityDao extends BaseDao * 是否可购买活动商品 * @param $userId * @param $productId - * @return bool + * @return bool|int * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException @@ -123,7 +123,7 @@ class StoreActivityDao extends BaseDao if ($find && $activityId == 2) { return false; } - return true; + return $activityId; } /** diff --git a/app/common/repositories/store/order/StoreOrderCreateRepository.php b/app/common/repositories/store/order/StoreOrderCreateRepository.php index dcca4176..a6b3813a 100644 --- a/app/common/repositories/store/order/StoreOrderCreateRepository.php +++ b/app/common/repositories/store/order/StoreOrderCreateRepository.php @@ -85,7 +85,7 @@ class StoreOrderCreateRepository extends StoreOrderRepository } foreach ($merchantCart['list'] as $cart) { $canBuy = (new StoreActivityDao())->canBuy($cart['uid'], $cart['product_id']); - if (!$canBuy) { + if (!$canBuy || ($canBuy == 2 && $cart['cart_num'] > 1)){ throw new ValidateException('活动商品限购1个'); } if ($cart['product_type'] == 0) {