diff --git a/jsowell-admin/src/test/java/SpringBootTestController.java b/jsowell-admin/src/test/java/SpringBootTestController.java index 76e30fd89..e1f1015fb 100644 --- a/jsowell-admin/src/test/java/SpringBootTestController.java +++ b/jsowell-admin/src/test/java/SpringBootTestController.java @@ -529,75 +529,6 @@ public class SpringBootTestController { } - @Test - public void testDiscount() { - OrderBasicInfo orderBasicInfo = new OrderBasicInfo(); - orderBasicInfo.setMemberId("12345678"); - orderBasicInfo.setMerchantId("1"); - orderBasicInfo.setStationId("19"); - orderBasicInfo.setPayAmount(new BigDecimal("200")); - - OrderDetail orderDetail = new OrderDetail(); - orderDetail.setTotalElectricityAmount(new BigDecimal("3")); - orderDetail.setTotalServiceAmount(new BigDecimal("0.18")); - - - 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 = BigDecimal.ZERO; - BigDecimal afterElectricityAmountDiscount = BigDecimal.ZERO; - - // 查询会员在此站点会员折扣 - 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); - } - } - // 订单折扣金额 - BigDecimal discountAmount = discountServiceAmount.add(discountElectricityAmount); - orderBasicInfo.setDiscountAmount(discountAmount); - // 更新退款金额 = 退款金额 - 折扣金额 - // BigDecimal refundAmount = orderBasicInfo.getRefundAmount().subtract(discountAmount); - - // 总消费金额 = 折扣后电费 + 折扣后服务费 - BigDecimal totalConsumeAmount = afterServiceAmountDiscount.add(afterElectricityAmountDiscount); - // 更新退款金额 - BigDecimal refundAmount = orderBasicInfo.getPayAmount().subtract(totalConsumeAmount).setScale(2, RoundingMode.DOWN); - orderBasicInfo.setRefundAmount(refundAmount); - - orderDetail.setDiscountElectricityAmount(discountElectricityAmount); - orderDetail.setDiscountServiceAmount(discountServiceAmount); - } - @Test public void queryPaymentByOrderNoTest() { String orderNo = "C88850447008_20240415083226"; diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberGroupServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberGroupServiceImpl.java index d1f2aa20a..4960bb139 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberGroupServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/MemberGroupServiceImpl.java @@ -189,6 +189,7 @@ public class MemberGroupServiceImpl implements MemberGroupService { return MemberDiscountVO; } + @Override public MemberDiscountVO queryMemberDiscountV2(String merchantId, String stationId, String memberId) { String groupCode = memberGroupMapper.queryMemberGroupCode(merchantId, stationId, memberId); if (StringUtils.isBlank(groupCode)) { @@ -205,6 +206,7 @@ public class MemberGroupServiceImpl implements MemberGroupService { .groupCode(groupCode) .billingTemplateVO(billingTemplate) .build(); + log.info("查询会员:{}, 在运营商:{}, 下面站点:{}, 折扣信息:{}", memberId, merchantId, stationId, memberDiscountVOBuilder); return memberDiscountVOBuilder; }