mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-04 18:10:10 +08:00
电单车充满自停退款逻辑
This commit is contained in:
@@ -44,6 +44,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -522,13 +523,37 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
|
|||||||
dto.setOrderDetail(orderDetail);
|
dto.setOrderDetail(orderDetail);
|
||||||
transactionService.doUpdateOrder(dto);
|
transactionService.doUpdateOrder(dto);
|
||||||
|
|
||||||
// 充电时间大于30秒不退费
|
// 充满自停需要退款
|
||||||
int chargingTime = message.getChargingTime();
|
BigDecimal bigDecimal = new BigDecimal("5");
|
||||||
if (chargingTime < 30) {
|
if (bigDecimal.compareTo(orderBasicInfo.getPayAmount()) == 0) {
|
||||||
// 退款
|
// 计算电单车退款金额
|
||||||
|
calculateEBikeRefund(orderBasicInfo, orderDetail, message);
|
||||||
|
|
||||||
|
// 订单退款
|
||||||
|
refundOrder(orderBasicInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算电单车退款逻辑
|
||||||
|
* @param orderBasicInfo
|
||||||
|
*/
|
||||||
|
private void calculateEBikeRefund(OrderBasicInfo orderBasicInfo, OrderDetail orderDetail, EBikeMessageCmd03 message) {
|
||||||
|
// 耗电量
|
||||||
|
BigDecimal consumedEnergy = message.getConsumedEnergy();
|
||||||
|
|
||||||
|
// 计费模板
|
||||||
|
BigDecimal flatElectricityPrice = orderDetail.getFlatElectricityPrice(); // x元/每度
|
||||||
|
BigDecimal flatServicePrice = orderDetail.getFlatServicePrice(); // x元/每度
|
||||||
|
|
||||||
|
// 消费金额
|
||||||
|
BigDecimal consumeAmount = consumedEnergy.multiply(flatElectricityPrice);
|
||||||
|
|
||||||
|
// 更新退款金额 = 支付金额 - 优惠后总消费金额
|
||||||
|
BigDecimal refundAmount = orderBasicInfo.getPayAmount().subtract(consumeAmount).setScale(2, RoundingMode.DOWN);
|
||||||
|
orderBasicInfo.setRefundAmount(refundAmount);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 第三方平台结算订单(目前给华为用)
|
* 第三方平台结算订单(目前给华为用)
|
||||||
* @param data
|
* @param data
|
||||||
|
|||||||
Reference in New Issue
Block a user