KKSU
2024-01-19 ad79260473d8ea5f67eda3a1bea30be42a440f08
src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallOrderInfoServiceImpl.java
@@ -85,6 +85,7 @@
    private final MallElectronicFenceMapper mallElectronicFenceMapper;
    private final MallMemberCouponMapper mallMemberCouponMapper;
    private final MallGoodsCouponMapper mallGoodsCouponMapper;
    private final CouponGoodsMapper couponGoodsMapper;
    @Override
    @Transactional(rollbackFor = Exception.class)
@@ -197,10 +198,9 @@
                        if(1 != state){
                            throw new FebsException(mallMemberCoupon.getCouponName()+"无法使用");
                        }
                        Long goodsId = mallMemberCoupon.getGoodsId();
                        if(goodsId != sku.getGoodsId()){
                            throw new FebsException(sku.getGoodsName()+"无法使用"+mallMemberCoupon.getCouponName());
                        }
                        //卷是否和商品绑定
                        Long skuGoodsId = sku.getGoodsId();
                        Long couponId = mallMemberCoupon.getCouponId();
                        MallGoodsCoupon mallGoodsCoupon = mallGoodsCouponMapper.selectById(mallMemberCoupon.getCouponId());
                        if(ObjectUtil.isEmpty(mallGoodsCoupon)){
                            throw new FebsException(mallGoodsCoupon.getName()+"无法使用");
@@ -209,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);
@@ -272,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);
    }
@@ -914,10 +936,6 @@
        }
        return new FebsResponse().success();
    }
    public static void main(String[] args) {
        System.out.print(AgentLevelEnum.ZERO_LEVEL.name());
    }
}