Merge pull request '调整活动商品限购' (#141) from dev into master

Reviewed-on: #141
This commit is contained in:
mkm 2024-01-26 15:06:13 +08:00
commit 66a30f717d

View File

@ -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;