diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/AbstractProgramLogic.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/AbstractProgramLogic.java index b08181196..25ed21a3f 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/AbstractProgramLogic.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/programlogic/AbstractProgramLogic.java @@ -709,74 +709,74 @@ public abstract class AbstractProgramLogic implements InitializingBean { * @param orderBasicInfo 订单主表 * @param orderDetail 订单详情 */ - protected void calculateOrderDiscounts(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail) { - String memberId = orderBasicInfo.getMemberId(); // 会员id - String merchantId = orderBasicInfo.getMerchantId(); // 运营商id - String stationId = orderBasicInfo.getStationId(); // 站点id - - // 电费折扣金额 - BigDecimal discountElectricityAmount = BigDecimal.ZERO; - // 服务费折扣金额 - BigDecimal discountServiceAmount = BigDecimal.ZERO; - // 优惠后服务费金额 初始值为优惠前金额 - BigDecimal afterServiceAmountDiscount = orderDetail.getTotalServiceAmount(); - // 优惠后电费金额 初始值为优惠前金额 - BigDecimal afterElectricityAmountDiscount = orderDetail.getTotalElectricityAmount(); - - // 查询会员在此站点会员折扣 - MemberDiscountVO memberDiscountVO = memberGroupService.queryMemberDiscount(merchantId, stationId, memberId); - if (memberDiscountVO != null) { - BigDecimal discount = memberDiscountVO.getDiscount(); // 折扣率 - String groupType = memberDiscountVO.getGroupType(); // 类型(1-服务费折扣,2-电费折扣 ,3-电费和服务费一起折扣) - BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount(); // 电费 - BigDecimal totalServiceAmount = orderDetail.getTotalServiceAmount(); // 服务费 - - // 未进行打折前 - afterServiceAmountDiscount = totalServiceAmount; - afterElectricityAmountDiscount = totalElectricityAmount; - if (Constants.ONE.equals(groupType)) { - // 服务费折扣 - afterServiceAmountDiscount = totalServiceAmount.multiply(discount).setScale(4, RoundingMode.DOWN); - discountServiceAmount = totalServiceAmount.subtract(afterServiceAmountDiscount); - } else if (Constants.TWO.equals(groupType)) { - // 电费折扣 - afterElectricityAmountDiscount = totalElectricityAmount.multiply(discount).setScale(4, RoundingMode.DOWN); - discountElectricityAmount = totalElectricityAmount.subtract(afterElectricityAmountDiscount); - } else { - // BigDecimal afterServiceAmountDiscount = totalServiceAmount.multiply(discount).setScale(2, RoundingMode.DOWN); - // discountServiceAmount = totalServiceAmount.subtract(afterServiceAmountDiscount); - // BigDecimal afterElectricityAmountDiscount = totalElectricityAmount.multiply(discount).setScale(2, RoundingMode.DOWN); - // discountElectricityAmount = totalElectricityAmount.subtract(afterElectricityAmountDiscount); - - // 电费和服务费一起折扣 - afterServiceAmountDiscount = totalServiceAmount.multiply(discount).setScale(4, RoundingMode.DOWN); - afterElectricityAmountDiscount = totalElectricityAmount.multiply(discount).setScale(4, RoundingMode.DOWN); - - discountServiceAmount = totalServiceAmount.subtract(afterServiceAmountDiscount); - discountElectricityAmount = totalElectricityAmount.subtract(afterElectricityAmountDiscount); - } - orderBasicInfo.setGroupCode(memberDiscountVO.getGroupCode()); - } - // 订单折扣金额 - BigDecimal discountAmount = discountServiceAmount.add(discountElectricityAmount); - orderBasicInfo.setDiscountAmount(discountAmount); - - // 更新结算金额 结算金额 = 消费金额 - 虚拟金额 - 优惠金额 - BigDecimal newSettleAmount = orderBasicInfo.getSettleAmount().subtract(discountAmount); - orderBasicInfo.setSettleAmount(newSettleAmount); - - // 总消费金额 = 折扣后电费 + 折扣后服务费 - BigDecimal totalConsumeAmount = afterServiceAmountDiscount.add(afterElectricityAmountDiscount); - - // 更新退款金额 - BigDecimal refundAmount = orderBasicInfo.getPayAmount().subtract(totalConsumeAmount).setScale(2, RoundingMode.DOWN); - orderBasicInfo.setRefundAmount(refundAmount); - - orderDetail.setDiscountElectricityAmount(discountElectricityAmount); - orderDetail.setDiscountServiceAmount(discountServiceAmount); - logger.info("计算订单折扣, orderCode:{}, memberId:{}, discountAmount:{}, discountElectricityAmount:{}, discountServiceAmount:{}, totalConsumeAmount:{}", - orderBasicInfo.getOrderCode(), memberId, discountAmount, discountElectricityAmount, discountServiceAmount, totalConsumeAmount); - } + // protected void calculateOrderDiscounts(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail) { + // String memberId = orderBasicInfo.getMemberId(); // 会员id + // String merchantId = orderBasicInfo.getMerchantId(); // 运营商id + // String stationId = orderBasicInfo.getStationId(); // 站点id + // + // // 电费折扣金额 + // BigDecimal discountElectricityAmount = BigDecimal.ZERO; + // // 服务费折扣金额 + // BigDecimal discountServiceAmount = BigDecimal.ZERO; + // // 优惠后服务费金额 初始值为优惠前金额 + // BigDecimal afterServiceAmountDiscount = orderDetail.getTotalServiceAmount(); + // // 优惠后电费金额 初始值为优惠前金额 + // BigDecimal afterElectricityAmountDiscount = orderDetail.getTotalElectricityAmount(); + // + // // 查询会员在此站点会员折扣 + // MemberDiscountVO memberDiscountVO = memberGroupService.queryMemberDiscount(merchantId, stationId, memberId); + // if (memberDiscountVO != null) { + // BigDecimal discount = memberDiscountVO.getDiscount(); // 折扣率 + // String groupType = memberDiscountVO.getGroupType(); // 类型(1-服务费折扣,2-电费折扣 ,3-电费和服务费一起折扣) + // BigDecimal totalElectricityAmount = orderDetail.getTotalElectricityAmount(); // 电费 + // BigDecimal totalServiceAmount = orderDetail.getTotalServiceAmount(); // 服务费 + // + // // 未进行打折前 + // afterServiceAmountDiscount = totalServiceAmount; + // afterElectricityAmountDiscount = totalElectricityAmount; + // if (Constants.ONE.equals(groupType)) { + // // 服务费折扣 + // afterServiceAmountDiscount = totalServiceAmount.multiply(discount).setScale(4, RoundingMode.DOWN); + // discountServiceAmount = totalServiceAmount.subtract(afterServiceAmountDiscount); + // } else if (Constants.TWO.equals(groupType)) { + // // 电费折扣 + // afterElectricityAmountDiscount = totalElectricityAmount.multiply(discount).setScale(4, RoundingMode.DOWN); + // discountElectricityAmount = totalElectricityAmount.subtract(afterElectricityAmountDiscount); + // } else { + // // BigDecimal afterServiceAmountDiscount = totalServiceAmount.multiply(discount).setScale(2, RoundingMode.DOWN); + // // discountServiceAmount = totalServiceAmount.subtract(afterServiceAmountDiscount); + // // BigDecimal afterElectricityAmountDiscount = totalElectricityAmount.multiply(discount).setScale(2, RoundingMode.DOWN); + // // discountElectricityAmount = totalElectricityAmount.subtract(afterElectricityAmountDiscount); + // + // // 电费和服务费一起折扣 + // afterServiceAmountDiscount = totalServiceAmount.multiply(discount).setScale(4, RoundingMode.DOWN); + // afterElectricityAmountDiscount = totalElectricityAmount.multiply(discount).setScale(4, RoundingMode.DOWN); + // + // discountServiceAmount = totalServiceAmount.subtract(afterServiceAmountDiscount); + // discountElectricityAmount = totalElectricityAmount.subtract(afterElectricityAmountDiscount); + // } + // orderBasicInfo.setGroupCode(memberDiscountVO.getGroupCode()); + // } + // // 订单折扣金额 + // BigDecimal discountAmount = discountServiceAmount.add(discountElectricityAmount); + // orderBasicInfo.setDiscountAmount(discountAmount); + // + // // 更新结算金额 结算金额 = 消费金额 - 虚拟金额 - 优惠金额 + // BigDecimal newSettleAmount = orderBasicInfo.getSettleAmount().subtract(discountAmount); + // orderBasicInfo.setSettleAmount(newSettleAmount); + // + // // 总消费金额 = 折扣后电费 + 折扣后服务费 + // BigDecimal totalConsumeAmount = afterServiceAmountDiscount.add(afterElectricityAmountDiscount); + // + // // 更新退款金额 + // BigDecimal refundAmount = orderBasicInfo.getPayAmount().subtract(totalConsumeAmount).setScale(2, RoundingMode.DOWN); + // orderBasicInfo.setRefundAmount(refundAmount); + // + // orderDetail.setDiscountElectricityAmount(discountElectricityAmount); + // orderDetail.setDiscountServiceAmount(discountServiceAmount); + // logger.info("计算订单折扣, orderCode:{}, memberId:{}, discountAmount:{}, discountElectricityAmount:{}, discountServiceAmount:{}, totalConsumeAmount:{}", + // orderBasicInfo.getOrderCode(), memberId, discountAmount, discountElectricityAmount, discountServiceAmount, totalConsumeAmount); + // } /** * 计算订单折扣V2 @@ -809,7 +809,10 @@ public abstract class AbstractProgramLogic implements InitializingBean { afterDiscountServiceAmount = orderDetail.getTotalServiceAmount(); afterDiscountElectricityAmount = orderDetail.getTotalElectricityAmount(); } else { + // 集团会员的订单,记录集团编号 orderBasicInfo.setGroupCode(memberDiscountVO.getGroupCode()); + + // 集团会员的优惠计费模板 BillingTemplateVO billingTemplateVO = memberDiscountVO.getBillingTemplateVO(); // 尖时段用电量