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