| | |
| | | |
| | | //计算订单金额信息 |
| | | //一级子订单:售价=商品售价*购买数量*折扣 |
| | | BigDecimal actualTotal = consumables.getPrice().multiply(vo.getDiscount().divide(new BigDecimal(100))); |
| | | BigDecimal actualTotal; |
| | | |
| | | if(vo.getDiscountAlgorithm() == OrderItemConstants.DISCOUNT_ALGORITHM_TOTAL){ |
| | | actualTotal = consumables.getPrice(); |
| | |
| | | |
| | | //计算订单卡项金额信息 |
| | | //一级子订单:售价=卡项售价*折扣 |
| | | BigDecimal actualTotal = cardItem.getTotal().multiply(vo.getDiscount().divide(new BigDecimal(100))).setScale(2,RoundingMode.HALF_UP); |
| | | BigDecimal actualTotal; |
| | | if(vo.getDiscountAlgorithm() == OrderItemConstants.DISCOUNT_ALGORITHM_TOTAL){ |
| | | actualTotal = cardItem.getTotal(); |
| | | }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))); |
| | |
| | | vo.setProPrice(cardItem.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); |
| | | //优惠福利总金额 |