From 250f751e6406ab598c85c56334c89359feb69229 Mon Sep 17 00:00:00 2001 From: SongZhang <2064194730@qq.com> Date: Wed, 30 Oct 2024 09:38:49 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=9C=B8=E7=8E=8B=E9=A4=90=E6=89=A3?= =?UTF-8?q?=E5=87=8F=E4=BC=98=E6=83=A0=E5=88=B8=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/cashierservice/entity/vo/TbUserCouponVo.java | 3 +++ .../chaozhanggui/system/cashierservice/service/PayService.java | 2 ++ .../cashierservice/service/impl/TbShopCouponServiceImpl.java | 3 ++- src/main/resources/mapper/TbActivateInRecordMapper.xml | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TbUserCouponVo.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TbUserCouponVo.java index f6f07ec..6e0f865 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TbUserCouponVo.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/vo/TbUserCouponVo.java @@ -2,11 +2,14 @@ package com.chaozhanggui.system.cashierservice.entity.vo; import lombok.Data; +import java.math.BigDecimal; import java.util.Date; @Data public class TbUserCouponVo { private Integer id; + private BigDecimal fullAmount; + private BigDecimal discountAmount; private Integer couponId; private Integer proId; //优惠券名称 diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java index 150d0a1..20db318 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/PayService.java @@ -423,6 +423,8 @@ public class PayService { if (userCouponVo == null) { throw new MsgException("存在不可用优惠券"); } + + shouldPayAmount = shouldPayAmount.subtract(userCouponVo.getDiscountAmount()); ActivateInInfoVO activateInInfoVO = new ActivateInInfoVO() .setId(userCouponVo.getId()) .setCouponId(userCouponVo.getCouponId()) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java index 3484c52..9f0c9ae 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopCouponServiceImpl.java @@ -54,7 +54,8 @@ public class TbShopCouponServiceImpl implements TbShopCouponService { //券id 券使用描述 Map coupons = new HashMap<>(); for (TbUserCouponVo tbUserCouponVo : tbUserCouponVos) { - if (tbUserCouponVo.getType() != null && tbUserCouponVo.getType() == 1) { + if (tbUserCouponVo.getType() != null && tbUserCouponVo.getType() == 1 && + tbUserCouponVo.getFullAmount().compareTo(amount) <= 0) { if (!coupons.containsKey(tbUserCouponVo.getCouponId())) { setCouponInfo(coupons, tbUserCouponVo, amount, week, now, formatter); } diff --git a/src/main/resources/mapper/TbActivateInRecordMapper.xml b/src/main/resources/mapper/TbActivateInRecordMapper.xml index 6f431e4..06f38e3 100644 --- a/src/main/resources/mapper/TbActivateInRecordMapper.xml +++ b/src/main/resources/mapper/TbActivateInRecordMapper.xml @@ -38,6 +38,8 @@ id, vip_user_id, coupon_id, name, type, pro_id, full_amount, discount_amount, nu