| | |
| | | OrderItemSon orderItemSon; |
| | | SqlSentence sqlSentence; |
| | | JSONArray jsonArray; |
| | | //已付积分 |
| | | //父类的应付总积分 |
| | | BigDecimal integralTotal = vo.getShouldTotalPoints(); |
| | | //父类的应付总金额 |
| | | BigDecimal infoTotal = vo.getActualTotal(); |
| | | //父类的总金额 |
| | | BigDecimal parentTotal = vo.getProPrice().multiply(new BigDecimal(vo.getBuyNum())).setScale(2,RoundingMode.HALF_UP); |
| | | |
| | | //比例 |
| | | BigDecimal proportion; |
| | | PromotionInfo promotionInfo; |
| | | |
| | | |
| | | for(int i= 0;i<promotionInfoList.size();i++){ |
| | | promotionInfo = promotionInfoList.get(i); |
| | | jsonArray=new JSONArray(); |
| | |
| | | orderItemSon.setDiscount(vo.getDiscount()); |
| | | orderItemSon.setDiscountAlgorithm(vo.getDiscountAlgorithm()); |
| | | |
| | | if(orderItemSon.getDiscountAlgorithm() == OrderItemConstants.DISCOUNT_ALGORITHM_TOTAL){ |
| | | /*if(orderItemSon.getDiscountAlgorithm() == OrderItemConstants.DISCOUNT_ALGORITHM_TOTAL){ |
| | | //订单售价=促销单价*订单折扣 |
| | | orderItemSon.setCurPrice(orderItemSon.getProPrice()); |
| | | }else{ |
| | | //订单售价=促销单价*订单折扣 |
| | | orderItemSon.setCurPrice(orderItemSon.getProPrice().multiply(orderItemSon.getDiscount().divide(new BigDecimal(100),15,RoundingMode.HALF_UP)).setScale(2,RoundingMode.HALF_UP)); |
| | | } |
| | | }*/ |
| | | |
| | | //优惠前小计=订单售价*数量 |
| | | //计算 |
| | | BigDecimal total = promotionInfo.getDiscountAfterPrice().multiply(new BigDecimal(vo.getBuyNum())).setScale(2,RoundingMode.HALF_UP); |
| | | if(orderItemSon.getDiscountAlgorithm() == OrderItemConstants.DISCOUNT_ALGORITHM_TOTAL){ |
| | | |
| | | if(i == (promotionInfoList.size()-1)){ |
| | | //是否最后一个 |
| | | orderItemSon.setTotal(infoTotal); |
| | | }else{ |
| | | if(parentTotal.compareTo(BigDecimal.ZERO) > 0){ |
| | | proportion = total.divide(parentTotal,15,RoundingMode.HALF_UP); |
| | | }else{ |
| | | proportion = BigDecimal.ZERO; |
| | | } |
| | | //根据比例算出积分 |
| | | orderItemSon.setTotal(vo.getActualTotal().multiply(proportion).setScale(2,RoundingMode.HALF_UP)); |
| | | if(orderItemSon.getTotal().compareTo(infoTotal) > 0){ |
| | | orderItemSon.setTotal(infoTotal); |
| | | } |
| | | } |
| | | infoTotal = infoTotal.subtract(orderItemSon.getTotal()); |
| | | |
| | | /*if(orderItemSon.getDiscountAlgorithm() == OrderItemConstants.DISCOUNT_ALGORITHM_TOTAL){ |
| | | orderItemSon.setTotal(promotionInfo.getDiscountAfterPrice().multiply(new BigDecimal(vo.getBuyNum())).setScale(2,RoundingMode.HALF_UP)); |
| | | orderItemSon.setTotal(orderItemSon.getTotal().multiply(vo.getDiscount().divide(new BigDecimal(100),15,RoundingMode.HALF_UP)).setScale(2,RoundingMode.HALF_UP)); |
| | | orderItemSon.setDiscountMoney(orderItemSon.getTotal().divide(new BigDecimal(orderItemSon.getBuyNum()),5,RoundingMode.HALF_UP)); |
| | | //折扣金额 |
| | | orderItemSon.setDiscountOrderPrice(total.subtract(orderItemSon.getTotal())); |
| | | }else{ |
| | | //优惠前小计=订单售价*数量 |
| | | orderItemSon.setTotal(total.multiply(orderItemSon.getDiscount().divide(new BigDecimal(100),15,RoundingMode.HALF_UP)).setScale(2,RoundingMode.HALF_UP)); |
| | | //折扣金额 |
| | | orderItemSon.setDiscountOrderPrice(total.subtract(orderItemSon.getTotal())); |
| | | orderItemSon.setDiscountMoney(orderItemSon.getTotal().divide(new BigDecimal(orderItemSon.getBuyNum()),5,RoundingMode.HALF_UP)); |
| | | } |
| | | }*/ |
| | | |
| | | //折扣金额 |
| | | orderItemSon.setDiscountOrderPrice(total.subtract(orderItemSon.getTotal())); |
| | | orderItemSon.setDiscountMoney(orderItemSon.getTotal().divide(new BigDecimal(orderItemSon.getBuyNum()),5,RoundingMode.HALF_UP)); |
| | | orderItemSon.setCurPrice(orderItemSon.getDiscountMoney().setScale(2,RoundingMode.HALF_UP)); |
| | | |
| | | //优惠券抵扣金额 |
| | | orderItemSon.setDiscountPrice(BigDecimal.ZERO); |