From 2ddb7c749fee28a11a2eb29b7985ba785cb5edc5 Mon Sep 17 00:00:00 2001 From: chenjiahe <763432473@qq.com> Date: 星期四, 01 八月 2024 21:22:09 +0800 Subject: [PATCH] 订单折扣-商品子单 --- phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java | 25 +++++++++++++++++++++---- 1 files changed, 21 insertions(+), 4 deletions(-) diff --git a/phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java b/phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java index d863a0d..f57afde 100644 --- a/phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java +++ b/phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java @@ -710,8 +710,11 @@ //涓�绾у瓙璁㈠崟:鍞环=鍟嗗搧鍞环*璐拱鏁伴噺*鎶樻墸 BigDecimal actualTotal = consumables.getPrice().multiply(vo.getDiscount().divide(new BigDecimal(100))); - //鎬昏鍗�:璁㈠崟浼樻儬閲戦=鍟嗗搧鍞环*璐拱鏁伴噺 鍑忓幓 涓�绾у瓙璁㈠崟鍞环 - discountTotal=discountTotal.add(consumables.getPrice().multiply(buyNum).subtract(actualTotal.multiply(buyNum))); + if(vo.getDiscountAlgorithm() == OrderItemConstants.DISCOUNT_ALGORITHM_TOTAL){ + actualTotal = consumables.getPrice(); + }else{ + actualTotal = consumables.getPrice().multiply(vo.getDiscount().divide(new BigDecimal(100),15,RoundingMode.HALF_UP)).setScale(2,RoundingMode.HALF_UP); + } //涓�绾у瓙璁㈠崟閲戦淇℃伅璁惧�� //璁剧疆鍘熶环锛屽師浠�=鍟嗗搧鐨勯攢鍞环鏍� @@ -720,8 +723,22 @@ vo.setProPrice(consumables.getPrice()); //璁剧疆鍞环, 鍞环=椤圭洰鐨勯攢鍞环鏍�*璐拱鏁伴噺*鎶樻墸 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); //浼樻儬绂忓埄鎬婚噾棰� -- Gitblit v1.8.0