From 5d61a9113cc6ce1fef363ad2118cd578792b4c92 Mon Sep 17 00:00:00 2001 From: wucongxing8150 <815046773@qq.com> Date: Thu, 18 Apr 2024 15:03:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=A4=84=E7=90=86=E6=97=A0?= =?UTF-8?q?=E9=97=A8=E6=A7=9B=E4=BC=98=E6=83=A0=E5=8D=B7=E9=87=91=E9=A2=9D?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/UserCouponService.php | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/app/Services/UserCouponService.php b/app/Services/UserCouponService.php index dfb77a0..658ee85 100644 --- a/app/Services/UserCouponService.php +++ b/app/Services/UserCouponService.php @@ -162,8 +162,8 @@ class UserCouponService extends BaseService } } - // 处理满减金额优惠卷 - if ($coupon['coupon_type'] == 2){ + // 处理满减金额/无门槛优惠卷 + if ($coupon['coupon_type'] == 2 || $coupon['coupon_type'] == 1){ // 可共用一个优惠卷的商品金额问题 $product_price = 0; @@ -185,9 +185,20 @@ class UserCouponService extends BaseService ); } - if ($coupon['with_amount'] > $product_price){ - // 此优惠卷因商品金额不足,无法使用 - $coupons[$key]['is_can_use'] = 0; + // 满减金额优惠卷 + if ($coupon['coupon_type'] == 2){ + if ($coupon['with_amount'] > $product_price){ + // 此优惠卷因商品金额不足,无法使用 + $coupons[$key]['is_can_use'] = 0; + } + } + + // 无门槛优惠卷 + if ($coupon['coupon_type'] == 1){ + if ($product_price <= 0){ + // 商品总金额已经为0,不使用优惠卷 + $coupons[$key]['is_can_use'] = 0; + } } }