chenjiahe
2024-08-01 d85b49d23d643ff266ee04e26d30c042c4749789
订单折扣-促销子单
1个文件已修改
31 ■■■■■ 已修改文件
phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java
@@ -961,11 +961,12 @@
    //计算订单金额信息
        //一级子订单:售价=促销销售价格*折扣
        BigDecimal actualTotal = promotion.getTotal().multiply(vo.getDiscount().divide(new BigDecimal(100),15,BigDecimal.ROUND_HALF_UP)).setScale(2,BigDecimal.ROUND_HALF_UP);
        //总订单:订单优惠金额=商品的销售单价*数量 减去 一级子订单售价 * 购买数量;
        discountTotal=discountTotal.add(promotion.getTotal().multiply(buyNum).subtract(actualTotal.multiply(buyNum)));
        BigDecimal actualTotal;
        if(vo.getDiscountAlgorithm() == OrderItemConstants.DISCOUNT_ALGORITHM_TOTAL){
            actualTotal = promotion.getTotal();
        }else{
            actualTotal = promotion.getTotal().multiply(vo.getDiscount().divide(new BigDecimal(100),15,BigDecimal.ROUND_HALF_UP)).setScale(2,BigDecimal.ROUND_HALF_UP);
        }
    //一级子订单金额信息设值
        //设置原价,原价=促销的销售价格
@@ -974,8 +975,21 @@
        vo.setProPrice(promotion.getTotal());
        //设置一级子订单售价, 售价=项目的销售价格*购买数量*折扣
        vo.setCurPrice(actualTotal);
        //设置一级子订单优惠前小计,优惠前小计=售价* 商品数量
        vo.setTotal(vo.getCurPrice().multiply(buyNum));
        if(vo.getDiscountAlgorithm() == OrderItemConstants.DISCOUNT_ALGORITHM_TOTAL){
            //设置优惠前小计,优惠前小计=售价* 商品数量
            vo.setTotal(vo.getCurPrice().multiply(buyNum));
            vo.setTotal(vo.getTotal().multiply(vo.getDiscount().divide(new BigDecimal(100),15,RoundingMode.HALF_UP)).setScale(2,RoundingMode.HALF_UP));
            vo.setDiscountMoney(vo.getTotal().divide(buyNum,4,RoundingMode.HALF_UP));
        }else{
            //设置优惠前小计,优惠前小计=售价* 商品数量
            vo.setTotal(vo.getCurPrice().multiply(buyNum));
            vo.setDiscountMoney(vo.getCurPrice());
        }
        //计算折扣金额
        vo.setDiscountOrderPrice(vo.getProPrice().multiply(BigDecimal.valueOf(vo.getBuyNum()).setScale(2,RoundingMode.HALF_UP)).subtract(vo.getTotal()));
        //折扣金额汇总
        discountTotal=discountTotal.add(vo.getDiscountOrderPrice()).setScale(2,RoundingMode.HALF_UP);
        //设置一级子订单优惠券抵扣金额,开单不知道是否使用优惠券,默认为0
        vo.setCouponTotal(BigDecimal.ZERO);
        //优惠福利总金额
@@ -1075,9 +1089,6 @@
        }else{
            actualTotal = cardItem.getTotal().multiply(vo.getDiscount().divide(new BigDecimal(100),15,RoundingMode.HALF_UP)).setScale(2,RoundingMode.HALF_UP);
        }
        //总订单:订单优惠金额=商品的售价*数量 减去 一级子订单售价*购买数量;
        discountTotal=discountTotal.add(cardItem.getTotal().multiply(buyNum).subtract(actualTotal.multiply(buyNum)));
        //一级子订单卡项金额信息设值
        //设置原价,原价=卡项的销售价格