修复在线支付保险订单 payAmount 与 payRecordAmount 不一致

在线支付回调(adapayCallback)中主动将 payAmount 减去了 insuranceAmount 再传给回调,
但 order_pay_record 记录的是完整支付金额,导致校验时 payAmount(扣减后) ≠ payRecordAmount(完整)。

修复:
1. OrderService.adapayCallback: callbackDTO 传完整 amount,同时带上 insuranceAmount
2. payOrderSuccessCallback: 下发桩的启动金额用 payAmount - insuranceAmount 计算,
   订单主表 payAmount 仍为完整支付金额,与 payRecordAmount 一致
This commit is contained in:
Guoqs
2026-07-25 16:47:35 +08:00
parent de73b82f65
commit f11b781c27
2 changed files with 9 additions and 11 deletions

View File

@@ -1299,19 +1299,13 @@ public class OrderService {
} }
}, executor); }, executor);
// 初始化充电金额 // 支付订单成功
BigDecimal chargeAmount = amount;
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode); OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
BigDecimal insuranceAmount = orderBasicInfo.getInsuranceAmount(); BigDecimal insuranceAmount = orderBasicInfo.getInsuranceAmount();
if (insuranceAmount.compareTo(BigDecimal.ZERO) > 0) {
// 如果用户支付了保险金额,则充电金额需将保险金额减去
chargeAmount = amount.subtract(insuranceAmount).setScale(2, RoundingMode.HALF_UP);
}
// 支付订单成功
PayOrderSuccessCallbackDTO callbackDTO = PayOrderSuccessCallbackDTO.builder() PayOrderSuccessCallbackDTO callbackDTO = PayOrderSuccessCallbackDTO.builder()
.orderCode(orderCode) .orderCode(orderCode)
.payAmount(chargeAmount) // amount .payAmount(amount) // 完整支付金额(含保险),与 order_pay_record 汇总一致
// .payMode(OrderPayModeEnum.PAYMENT_OF_WECHATPAY.getValue()) .insuranceAmount(insuranceAmount) // 保险金额,回调中用于计算下发桩的充电金额
.payMode(payModel) .payMode(payModel)
.acquirer(AcquirerEnum.ADAPAY.getValue()) .acquirer(AcquirerEnum.ADAPAY.getValue())
.build(); .build();

View File

@@ -5406,8 +5406,12 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
return; return;
} }
// 获取启动金额 // 获取启动金额:保险金额不计入下发桩的充电额度
BigDecimal chargeAmount = computeChargeAmount(orderInfo.getMerchantId(), orderInfo.getStationId(), orderInfo.getMemberId(), dto.getPayAmount()); BigDecimal payAmountForPile = dto.getPayAmount();
if (dto.getInsuranceAmount() != null && dto.getInsuranceAmount().compareTo(BigDecimal.ZERO) > 0) {
payAmountForPile = dto.getPayAmount().subtract(dto.getInsuranceAmount());
}
BigDecimal chargeAmount = computeChargeAmount(orderInfo.getMerchantId(), orderInfo.getStationId(), orderInfo.getMemberId(), payAmountForPile);
// 发送启动指令 // 发送启动指令
if (StringUtils.equals(pileConnectorDetailVO.getChargePortType(), Constants.THREE)) { if (StringUtils.equals(pileConnectorDetailVO.getChargePortType(), Constants.THREE)) {