From 08aa2024f664d2c7e7eb60a25922a07d60aca2f2 Mon Sep 17 00:00:00 2001 From: KKSU <15274802129@163.com> Date: Fri, 19 Jan 2024 15:37:32 +0800 Subject: [PATCH] fapiao --- src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java | 36 +++++++++++++++++++++++------------- 1 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java index a38156f..7b70a02 100644 --- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java +++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java @@ -201,14 +201,6 @@ //卷是否和商品绑定 Long skuGoodsId = sku.getGoodsId(); Long couponId = mallMemberCoupon.getCouponId(); - List<CouponGoods> couponGoods = couponGoodsMapper.selectByGoodIdAndCouponId(skuGoodsId, couponId); - if(ObjectUtil.isEmpty(couponGoods)){ - throw new FebsException(sku.getGoodsName()+"无法使用"+mallMemberCoupon.getCouponName()); - } -// Long goodsId = mallMemberCoupon.getGoodsId(); -// if(goodsId != sku.getGoodsId()){ -// throw new FebsException(sku.getGoodsName()+"无法使用"+mallMemberCoupon.getCouponName()); -// } MallGoodsCoupon mallGoodsCoupon = mallGoodsCouponMapper.selectById(mallMemberCoupon.getCouponId()); if(ObjectUtil.isEmpty(mallGoodsCoupon)){ throw new FebsException(mallGoodsCoupon.getName()+"无法使用"); @@ -217,10 +209,26 @@ if(2 != stateCoupon){ throw new FebsException(mallGoodsCoupon.getName()+"无法使用"); } + List<CouponGoods> couponGoods = couponGoodsMapper.selectByGoodIdAndCouponId(skuGoodsId, couponId); + if(ObjectUtil.isEmpty(couponGoods)){ + throw new FebsException(sku.getGoodsName()+"无法使用"+mallMemberCoupon.getCouponName()); + } +// Long goodsId = mallMemberCoupon.getGoodsId(); +// if(goodsId != sku.getGoodsId()){ +// throw new FebsException(sku.getGoodsName()+"无法使用"+mallMemberCoupon.getCouponName()); +// } BigDecimal costAmount = mallGoodsCoupon.getCostAmount(); BigDecimal realAmount = mallGoodsCoupon.getRealAmount(); if(amount.compareTo(costAmount) >= 0){ - amount = (amount.subtract(realAmount).compareTo(BigDecimal.ZERO) > 0 ? amount.subtract(realAmount) : BigDecimal.ZERO); + Integer type = mallGoodsCoupon.getType(); + if(MallGoodsCoupon.TYPE_TWO == type){ + BigDecimal divideTime = amount.divide(costAmount, 0, BigDecimal.ROUND_DOWN);//累计减免次数 + BigDecimal multiply = divideTime.multiply(realAmount);//实际减免金额 + amount = (amount.subtract(multiply).compareTo(BigDecimal.ZERO) > 0 ? amount.subtract(multiply) : BigDecimal.ZERO); + } + if(MallGoodsCoupon.TYPE_ONE == type){ + amount = (amount.subtract(realAmount).compareTo(BigDecimal.ZERO) > 0 ? amount.subtract(realAmount) : BigDecimal.ZERO); + } orderItem.setMemberCouponId(memberCouponId); mallMemberCoupon.setState(2); mallMemberCouponMapper.updateById(mallMemberCoupon); @@ -280,6 +288,12 @@ //过期时间修改成24小时 agentProducer.sendOrderCancelDelayMsg(orderInfo.getId(), 24 * 60 * 60 * 1000L); return orderInfo.getId(); + } + + public static void main(String[] args) { + BigDecimal bigDecimal = new BigDecimal(980); + BigDecimal divide = bigDecimal.divide(new BigDecimal(100), 0, BigDecimal.ROUND_DOWN); + System.out.println(divide); } @@ -922,10 +936,6 @@ } return new FebsResponse().success(); - } - - public static void main(String[] args) { - System.out.print(AgentLevelEnum.ZERO_LEVEL.name()); } } -- Gitblit v1.9.1