打印日志

This commit is contained in:
Guoqs
2024-11-08 19:11:33 +08:00
parent b74aeb7c4d
commit 970a46b3b4
2 changed files with 2 additions and 69 deletions

View File

@@ -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";