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;