update 电单车

This commit is contained in:
Guoqs
2024-10-08 15:20:20 +08:00
parent 6aeded9d93
commit 6e5c3fb8bb

View File

@@ -517,18 +517,15 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
orderDetail.setFlatUsedElectricity(message.getConsumedEnergy()); orderDetail.setFlatUsedElectricity(message.getConsumedEnergy());
} }
// 充满自停需要退款 // 计算电单车退款金额
BigDecimal bigDecimal = new BigDecimal("5"); calculateEBikeRefund(orderBasicInfo, orderDetail, message);
if (bigDecimal.compareTo(orderBasicInfo.getPayAmount()) == 0) {
// 计算电单车退款金额
calculateEBikeRefund(orderBasicInfo, orderDetail, message);
// 订单退款
refundOrder(orderBasicInfo);
}
// 退款金额 // 退款金额
BigDecimal refundAmount = orderBasicInfo.getRefundAmount() == null ? BigDecimal.ZERO : orderBasicInfo.getRefundAmount(); BigDecimal refundAmount = orderBasicInfo.getRefundAmount() == null ? BigDecimal.ZERO : orderBasicInfo.getRefundAmount();
if (refundAmount.compareTo(BigDecimal.ZERO) > 0) {
// 订单退款, 退款金额大于0才退款
refundOrder(orderBasicInfo);
}
// 结算金额 = 支付金额 - 退款金额 // 结算金额 = 支付金额 - 退款金额
BigDecimal settleAmount = orderBasicInfo.getPayAmount().subtract(refundAmount).setScale(2, RoundingMode.DOWN); BigDecimal settleAmount = orderBasicInfo.getPayAmount().subtract(refundAmount).setScale(2, RoundingMode.DOWN);
@@ -547,25 +544,36 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
* @param orderBasicInfo * @param orderBasicInfo
*/ */
private void calculateEBikeRefund(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail, EBikeMessageCmd03 message) { private void calculateEBikeRefund(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail, EBikeMessageCmd03 message) {
// 耗电量 // 充满自停需要退款
BigDecimal consumedEnergy = message.getConsumedEnergy(); BigDecimal fullOfSelfStopping = new BigDecimal("5"); // 充满自停金额5元
// 计费模板 // 退款金额
BigDecimal flatElectricityPrice = orderDetail.getFlatElectricityPrice(); // x元/每度 BigDecimal refundAmount = BigDecimal.ZERO;
BigDecimal flatServicePrice = orderDetail.getFlatServicePrice(); // x元/每度 if (fullOfSelfStopping.compareTo(orderBasicInfo.getPayAmount()) == 0) {
// 耗电量
BigDecimal consumedEnergy = message.getConsumedEnergy();
if (consumedEnergy == null || flatElectricityPrice == null) { // 计费模板
logger.info("计算电单车退款逻辑,耗电量或计费模板为空,不执行退款逻辑, orderCode:{}, 耗电量:{}, 每度电费:{}", orderBasicInfo.getOrderCode(), consumedEnergy, flatElectricityPrice); BigDecimal flatElectricityPrice = orderDetail.getFlatElectricityPrice(); // x元/每度
return; BigDecimal flatServicePrice = orderDetail.getFlatServicePrice(); // x元/每度
if (consumedEnergy == null || flatElectricityPrice == null) {
logger.info("计算电单车退款逻辑,耗电量或计费模板为空,不执行退款逻辑, orderCode:{}, 耗电量:{}, 每度电费:{}", orderBasicInfo.getOrderCode(), consumedEnergy, flatElectricityPrice);
return;
}
// 消费金额
BigDecimal consumeAmount = consumedEnergy.multiply(flatElectricityPrice);
// 更新退款金额 = 支付金额 - 优惠后总消费金额
refundAmount = orderBasicInfo.getPayAmount().subtract(consumeAmount).setScale(2, RoundingMode.DOWN);
} }
// 消费金额 // 结算金额 = 支付金额 - 退款金额
BigDecimal consumeAmount = consumedEnergy.multiply(flatElectricityPrice); BigDecimal settleAmount = orderBasicInfo.getPayAmount().subtract(refundAmount).setScale(2, RoundingMode.DOWN);
// 更新退款金额 = 支付金额 - 优惠后总消费金额
BigDecimal refundAmount = orderBasicInfo.getPayAmount().subtract(consumeAmount).setScale(2, RoundingMode.DOWN);
orderBasicInfo.setRefundAmount(refundAmount); orderBasicInfo.setRefundAmount(refundAmount);
orderBasicInfo.setSettleAmount(settleAmount);
} }
/** /**