Commit 5692571a9c02c9801a5e2b1208463349e6c50365
1 parent
bb7e56e2
【功能优化】商城:价格计算时,增加“该优惠劵无法使用,原因:优惠金额超过订单金额”提示
Showing
3 changed files
with
5 additions
and
7 deletions
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java
| ... | ... | @@ -61,6 +61,7 @@ public interface ErrorCodeConstants { |
| 61 | 61 | ErrorCode PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER = new ErrorCode(1_011_003_004, "参与秒杀、拼团、砍价的营销商品,无法使用优惠劵"); |
| 62 | 62 | ErrorCode PRICE_CALCULATE_SECKILL_TOTAL_LIMIT_COUNT = new ErrorCode(1_011_003_005, "参与秒杀的商品,超过了秒杀总限购数量"); |
| 63 | 63 | ErrorCode PRICE_CALCULATE_DELIVERY_PRICE_TYPE_ILLEGAL = new ErrorCode(1_011_003_006, "计算快递运费异常,配送方式不匹配"); |
| 64 | + ErrorCode PRICE_CALCULATE_COUPON_PRICE_TOO_MUCH = new ErrorCode(1_011_003_007, "该优惠劵无法使用,原因:优惠金额超过订单金额"); | |
| 64 | 65 | |
| 65 | 66 | // ========== 物流 Express 模块 1-011-004-000 ========== |
| 66 | 67 | ErrorCode EXPRESS_NOT_EXISTS = new ErrorCode(1_011_004_000, "快递公司不存在"); | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java
| ... | ... | @@ -268,11 +268,6 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { |
| 268 | 268 | return false; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | - // 校验分佣模式:仅可后台手动设置推广员 | |
| 272 | - // if (BrokerageEnabledConditionEnum.ADMIN.getCondition().equals(tradeConfig.getBrokerageEnabledCondition())) { | |
| 273 | - // throw exception(BROKERAGE_BIND_CONDITION_ADMIN); | |
| 274 | - // } | |
| 275 | - | |
| 276 | 271 | // 校验分销关系绑定模式 |
| 277 | 272 | if (BrokerageBindModeEnum.REGISTER.getMode().equals(tradeConfig.getBrokerageBindMode())) { |
| 278 | 273 | // 判断是否为新用户:注册时间在 30 秒内的,都算新用户 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/price/calculator/TradeCouponPriceCalculator.java
| ... | ... | @@ -25,6 +25,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. |
| 25 | 25 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_NO_MATCH_MIN_PRICE; |
| 26 | 26 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.COUPON_NO_MATCH_SPU; |
| 27 | 27 | import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_COUPON_NOT_MATCH_NORMAL_ORDER; |
| 28 | +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.PRICE_CALCULATE_COUPON_PRICE_TOO_MUCH; | |
| 28 | 29 | |
| 29 | 30 | /** |
| 30 | 31 | * 优惠劵的 {@link TradePriceCalculator} 实现类 |
| ... | ... | @@ -65,8 +66,9 @@ public class TradeCouponPriceCalculator implements TradePriceCalculator { |
| 65 | 66 | |
| 66 | 67 | // 3.1 计算可以优惠的金额 |
| 67 | 68 | Integer couponPrice = getCouponPrice(coupon, totalPayPrice); |
| 68 | - Assert.isTrue(couponPrice < totalPayPrice, | |
| 69 | - "优惠劵({}) 的优惠金额({}),不能大于订单总金额({})", coupon.getId(), couponPrice, totalPayPrice); | |
| 69 | + if (couponPrice <= totalPayPrice) { | |
| 70 | + throw exception(PRICE_CALCULATE_COUPON_PRICE_TOO_MUCH); | |
| 71 | + } | |
| 70 | 72 | // 3.2 计算分摊的优惠金额 |
| 71 | 73 | List<Integer> divideCouponPrices = TradePriceCalculatorHelper.dividePrice(orderItems, couponPrice); |
| 72 | 74 | ... | ... |