diff --git a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java index ccdcac4..53b444c 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderCreateService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderCreateService.java @@ -78,7 +78,7 @@ public class OrderCreateService { if (goodsSpecs == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商品规格"); } - JSONObject businessObj = orderChild.getBusiness()==null? new JSONObject(): new JSONObject((Map) orderChild.getBusiness()); + JSONObject businessObj = orderChild.getBusiness()==null?new JSONObject(): new JSONObject((Map) orderChild.getBusiness()); if (businessObj.getLong("shopCartId") != null) { shoppingCartService.delete(businessObj.getLong("shopCartId")); } @@ -116,7 +116,7 @@ public class OrderCreateService { orderCoupon.setStatus(OrderChildStatusEnum.status1.getCode()); orderCouponService.editData(orderCoupon); - for (int i = 0; i < orderCoupon.getGoodsCount(); i++) { + for (int i = 0; i <= orderCoupon.getGoodsCount(); i++) { // 卡券订单卡密 BsOrderCouponNo orderCouponNo = new BsOrderCouponNo(); orderCouponNo.setCouponOrderId(orderCoupon.getId()); diff --git a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java index e0ec7fa..9131539 100644 --- a/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/order/impl/BsOrderServiceImpl.java @@ -202,13 +202,7 @@ public class BsOrderServiceImpl implements BsOrderService { childOrder.setSurplusRefundCount(childOrder.getProductCount()); // 计算 子订单 在交易订单金额中的占比 - BigDecimal ratio = childOrder.getProductTotalPrice().divide(order.getTotalPrice(), 2, BigDecimal.ROUND_DOWN).setScale(2); - // 计算子订单退款金额。 - if (order.getPayRealPrice().compareTo(new BigDecimal("0")) == 1) { - childOrder.setSurplusRefundPrice(order.getPayRealPrice().multiply(ratio).setScale(2, BigDecimal.ROUND_DOWN)); - } else { - childOrder.setSurplusRefundPrice(new BigDecimal("0")); - } + BigDecimal ratio = childOrder.getProductTotalPrice().divide(order.getTotalPrice(), 2, BigDecimal.ROUND_DOWN); // 计算子订单退款积分 if (order.getDeduction().getIntegralDiscountPrice() > 0) { @@ -217,10 +211,27 @@ public class BsOrderServiceImpl implements BsOrderService { childOrder.setSurplusRefundIntegral(0L); } + if (order.getDeduction().getCouponDiscountActualPrice().compareTo(BigDecimal.ZERO) == 1) { + // 计算子订单退款金额。 + if (order.getPayRealPrice().compareTo(BigDecimal.ZERO) == 1) { + // 计算实付金额中的占比 + childOrder.setSurplusRefundPrice(order.getPayRealPrice().multiply(ratio).setScale(2, BigDecimal.ROUND_DOWN)); + } else { + childOrder.setSurplusRefundPrice(new BigDecimal("0")); + } + } else { + childOrder.setSurplusRefundPrice( + // 商品总金额 - 积分抵扣金额 + childOrder.getProductTotalPrice().subtract( + new BigDecimal(childOrder.getSurplusRefundIntegral().toString()).multiply(new BigDecimal("100")) + )); + } + childOrder.setCouponDiscountPrice(childOrder.getProductTotalPrice().subtract(childOrder.getSurplusRefundPrice())); childOrder.setIntegralDiscountPrice(childOrder.getSurplusRefundIntegral()); childOrder.setTotalDeductionPrice( - childOrder.getCouponDiscountPrice().add(new BigDecimal(childOrder.getIntegralDiscountPrice().toString()).multiply(new BigDecimal("100"))) + childOrder.getCouponDiscountPrice() + .add(new BigDecimal(childOrder.getIntegralDiscountPrice().toString()).multiply(new BigDecimal("100"))) ); childOrder.setProductActualPrice(childOrder.getProductTotalPrice().subtract(childOrder.getTotalDeductionPrice())); orderChildService.editData(childOrder);