diff --git a/app/Service/v3/Implementations/OrderOnlineService.php b/app/Service/v3/Implementations/OrderOnlineService.php index 1e8706c..1542b95 100644 --- a/app/Service/v3/Implementations/OrderOnlineService.php +++ b/app/Service/v3/Implementations/OrderOnlineService.php @@ -176,19 +176,6 @@ class OrderOnlineService implements OrderOnlineServiceInterface // $userAddr->lng = $market->lng; } - // 优惠券数据,当前订单可用个优惠券 - $couponRecs = $this->couponRecService->allForOnlineOrderAvailable($userId, $marketId); - $canRealUseCoupons = $couponRecs['available']; - $canRealUseCouponRecIds = array_values(array_column($canRealUseCoupons, 'id')); - if (!empty(array_diff($receiveCouponIds, $canRealUseCouponRecIds))) { - $this->log->event(LogLabel::ORDER_ONLINE_LOG, ['msg' => '订单中有不能使用优惠券的商品', 'data' => json_encode([ - 'all_user_coupons_rec' => json_encode($couponRecs), - 'can_real_user_coupons' => json_encode($canRealUseCoupons), - 'receive_coupon_ids' => json_encode($canRealUseCouponRecIds), - ])]); - throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_CANNOT_USE_COUPON); - } - // 处理购物车数据,计算订单金额、子订单数据处理等 $totalAmount = 0; # 实付金额 $orderAmount = 0; # 订单金额 @@ -294,6 +281,19 @@ class OrderOnlineService implements OrderOnlineServiceInterface $orderAmount = bcadd((string)$orderAmount, (string)$subAmount); } + // 优惠券数据,当前订单可用个优惠券 + $couponRecs = $this->couponRecService->allForOnlineOrderAvailable($userId, $marketId ,$shopcartIds); + $canRealUseCoupons = $couponRecs['available']; + $canRealUseCouponRecIds = array_values(array_column($canRealUseCoupons, 'id')); + if (!empty(array_diff($receiveCouponIds, $canRealUseCouponRecIds))) { + $this->log->event(LogLabel::ORDER_ONLINE_LOG, ['msg' => '订单中有不能使用优惠券的商品', 'data' => json_encode([ + 'all_user_coupons_rec' => json_encode($couponRecs), + 'can_real_user_coupons' => json_encode($canRealUseCoupons), + 'receive_coupon_ids' => json_encode($canRealUseCouponRecIds), + ])]); + throw new ErrorCodeException(ErrorCode::GOODS_ACTIVITY_CANNOT_USE_COUPON); + } + // 优惠券的使用 $couponMoney = 0; if (!empty($receiveCouponIds)) {