调整活动商品限购

This commit is contained in:
luofei 2024-01-23 11:41:00 +08:00
parent cc8562411c
commit 566808e9d0
2 changed files with 3 additions and 3 deletions

View File

@ -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;
}
/**

View File

@ -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) {