KKSU
2024-01-03 78e1ed981dcabb519fbc56bc27171a7af44b9494
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());
    }
}