优化结算订单逻辑

This commit is contained in:
Guoqs
2025-03-26 16:25:52 +08:00
parent 738854e2a6
commit 99a39bce5f
2 changed files with 17 additions and 10 deletions

View File

@@ -430,11 +430,15 @@ public abstract class AbstractProgramLogic implements InitializingBean {
orderCode, price, electricityPrice, servicePrice, valleyUsedElectricity, amount, electricityAmount, serviceAmount, data.getValleyPrice(), data.getValleyAmount());
}
// 平台计算的总消费金额 平台计算总电费金额 + 平台计算总服务费金额
BigDecimal computeTotalAmount = totalElectricityAmount.add(totalServiceAmount);
// 如果算出来的 电费金额 + 服务费金额 != 总消费金额,则电费金额等于总消费金额 - 服务费金额
if (totalElectricityAmount.add(totalServiceAmount).compareTo(orderAmount) != 0) {
if (computeTotalAmount.compareTo(orderAmount) != 0) {
// 2025年3月26日15点50分, 订单金额以平台计算为主,所以注释掉, 并打印日志说明
// totalElectricityAmount = orderAmount.subtract(totalServiceAmount);
logger.info("平台计算出电费金额:{}, 服务费金额:{}, 汇总:{}, 交易记录传来的金额:{}", totalElectricityAmount, totalServiceAmount, totalElectricityAmount.add(totalServiceAmount), orderAmount);
logger.info("平台计算出电费金额:{}, 服务费金额:{}, 汇总:{}, 交易记录传来的金额:{}", totalElectricityAmount, totalServiceAmount, computeTotalAmount, orderAmount);
orderAmount = computeTotalAmount;
}
// 电费总金额
@@ -449,6 +453,9 @@ public abstract class AbstractProgramLogic implements InitializingBean {
orderDetail.setTotalUsedElectricity(totalElectricity.max(sumUsedElectricity));
// 订单总金额
orderDetail.setTotalOrderAmount(orderAmount);
// 更新订单主表中的总消费金额和退款金额
orderBasicInfo.setOrderAmount(orderAmount);
orderBasicInfo.setRefundAmount(orderBasicInfo.getPayAmount().subtract(orderAmount));
logger.info("end更新订单详情:【{}】, 电费总金额:{}, 服务费总金额:{}, 总用电量:{}, 订单总金额:{}", orderCode, totalElectricityAmount, totalServiceAmount, orderDetail.getTotalUsedElectricity(), orderAmount);
} catch (Exception e) {
logger.error("orderCode:{}, 设置订单详情参数发生异常", orderCode, e);

View File

@@ -493,14 +493,14 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
.orderCode(orderBasicInfo.getOrderCode())
.merchantId(orderBasicInfo.getMerchantId())
.stationId(orderBasicInfo.getStationId())
.orderPayAmount(orderBasicInfo.getPayAmount())
.orderConsumeAmount(orderBasicInfo.getOrderAmount())
.orderSettleAmount(orderBasicInfo.getSettleAmount())
.orderElectricityAmount(orderDetail.getTotalElectricityAmount())
.orderElectricityDiscountAmount(orderDetail.getDiscountElectricityAmount())
.orderServiceAmount(orderDetail.getTotalServiceAmount())
.orderServiceDiscountAmount(orderDetail.getDiscountServiceAmount())
.orderRefundAmount(orderBasicInfo.getRefundAmount())
.orderPayAmount(orderBasicInfo.getPayAmount()) // 支付金额
.orderConsumeAmount(orderBasicInfo.getOrderAmount()) // 消费金额
.orderSettleAmount(orderBasicInfo.getSettleAmount()) // 结算金额
.orderElectricityAmount(orderDetail.getTotalElectricityAmount()) // 电费金额
.orderElectricityDiscountAmount(orderDetail.getDiscountElectricityAmount()) // 电费折扣金额
.orderServiceAmount(orderDetail.getTotalServiceAmount()) // 服务费金额
.orderServiceDiscountAmount(orderDetail.getDiscountServiceAmount()) // 服务费折扣金额
.orderRefundAmount(orderBasicInfo.getRefundAmount()) // 退款金额
.build();
rabbitTemplate.convertAndSend(RabbitConstants.YKC_EXCHANGE_NAME, RabbitConstants.QUEUE_CHARGE_ORDER_DATA, afterSettleOrderDTO);