diff --git a/app/Controller/v3/OrderOnlineController.php b/app/Controller/v3/OrderOnlineController.php index d710b9a..c12bf72 100644 --- a/app/Controller/v3/OrderOnlineController.php +++ b/app/Controller/v3/OrderOnlineController.php @@ -206,15 +206,6 @@ class OrderOnlineController extends BaseController // 下单 $params = $request->validated(); - // TODO 校验当前用户今天是否超过了购买活动秒杀商品的(特定价格)的订单笔数 - if (!$this->orderOnlineService->checkIfBuyFlashGoodsToday($params['user_id'])) { - throw new ErrorCodeException( - ErrorCode::ORDER_ONLINE_LIMIT_BUY_COUNT, - '['.env('LIMIT_BUY_COUNT').']', - ['params' => $params, 'limit_prices' => env('LIMIT_BUY_COUNT_GOODS_PRICES')] - ); - } - $couponIds = isset($params['coupon_ids'])&&$params['coupon_ids'] ? explode(',', $params['coupon_ids']) : []; $data = $this->orderOnlineService->do( $params['market_id'], diff --git a/app/Controller/v3/ShopCartUpdateController.php b/app/Controller/v3/ShopCartUpdateController.php index 36f5d82..00e83a9 100644 --- a/app/Controller/v3/ShopCartUpdateController.php +++ b/app/Controller/v3/ShopCartUpdateController.php @@ -29,13 +29,15 @@ class ShopCartUpdateController extends BaseController $num = $this->request->input('num',0); $activityType = $this->request->input('activity_type',1); - // TODO 校验当前用户今天是否超过了购买活动秒杀商品的(特定价格)的订单笔数 - if (!$this->orderOnlineService->checkIfBuyFlashGoodsToday($userId)) { - throw new ErrorCodeException( - ErrorCode::ORDER_ONLINE_LIMIT_BUY_COUNT, - '['.env('LIMIT_BUY_COUNT').']', - ['params' => $this->request->all(), 'limit_prices' => env('LIMIT_BUY_COUNT_GOODS_PRICES')] - ); + if ($activityType == 2) { + // TODO 校验当前用户今天是否超过了购买活动秒杀商品的(特定价格)的订单笔数 + if (!$this->orderOnlineService->checkIfBuyFlashGoodsToday($userId)) { + throw new ErrorCodeException( + ErrorCode::ORDER_ONLINE_LIMIT_BUY_COUNT, + '[' . env('LIMIT_BUY_COUNT') . ']', + ['params' => $this->request->all(), 'limit_prices' => env('LIMIT_BUY_COUNT_GOODS_PRICES')] + ); + } } $res = $this->shopCarServiceUpdate->do($userId,$goodsId,$num,$activityType); diff --git a/app/Service/v3/Implementations/OrderOnlineService.php b/app/Service/v3/Implementations/OrderOnlineService.php index ca7b8a1..88cd0f8 100644 --- a/app/Service/v3/Implementations/OrderOnlineService.php +++ b/app/Service/v3/Implementations/OrderOnlineService.php @@ -267,6 +267,15 @@ class OrderOnlineService implements OrderOnlineServiceInterface } } + // TODO 校验当前用户今天是否超过了购买活动秒杀商品的(特定价格)的订单笔数 + if (!$this->checkIfBuyFlashGoodsToday($userId)) { + throw new ErrorCodeException( + ErrorCode::ORDER_ONLINE_LIMIT_BUY_COUNT, + '['.env('LIMIT_BUY_COUNT').']', + ['params' => $userId, 'limit_prices' => env('LIMIT_BUY_COUNT_GOODS_PRICES')] + ); + } + $check = $this->goodsActivityService->check($goods, $cart->num, $userId); if (true !== $check) { throw new ErrorCodeException($check, '['.$goods->name.']'); @@ -821,7 +830,7 @@ class OrderOnlineService implements OrderOnlineServiceInterface $goodsTable = ApplicationContext::getContainer()->get(OrderGoods::class)->getTable(); $limitPrices = explode(',', env('LIMIT_BUY_COUNT_GOODS_PRICES')); - $limitCount = env('LIMIT_BUY_COUNT'); + $limitCount = intval(env('LIMIT_BUY_COUNT')); $countToday = OrderMain::query() ->join($orderTable, $orderTable.'.order_main_id', '=', $mainTable.'.global_order_id')