From 2941a39035e4c348f4c9dbbc44f102b09b713e66 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Fri, 26 Jan 2024 15:05:40 +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 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/common/dao/store/StoreActivityDao.php b/app/common/dao/store/StoreActivityDao.php index 8b311a7d..373965d0 100755 --- a/app/common/dao/store/StoreActivityDao.php +++ b/app/common/dao/store/StoreActivityDao.php @@ -143,11 +143,14 @@ class StoreActivityDao extends BaseDao { $orderProductIds = array_column($order->orderProduct->toArray(), 'product_id'); $productIds = CloudProduct::whereIn('product_id', $orderProductIds)->where('activity_id', $activityId)->column('product_id'); - $find = StoreActivityOrderProduct::where('user_id', $order['uid'])->where('status', 1)->find(); - if ($find && $activityId == 2) { - throw new ValidateException('活动商品限购1个'); + if (empty($productIds)) { + return; } + $find = StoreActivityOrderProduct::where('user_id', $order['uid'])->where('status', 1)->find(); foreach ($productIds as $productId) { + if (!empty($find['product_id']) && $find['product_id'] == $productId && $activityId == 2) { + throw new ValidateException('活动商品限购1个'); + } $model = new StoreActivityOrderProduct(); $model->user_id = $order['uid']; $model->activity_id = $activityId;