mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
手动结算电单车订单逻辑update
This commit is contained in:
@@ -28,6 +28,12 @@ public class EBikeMessageCmd03 extends AbsEBikeMessage2 {
|
||||
// private String timestamp; // 时间戳 上发指令当时的时间,有时候不准确,该字段属于调试使用,服务器无需关心此字段
|
||||
// private String placeholderDuration; // 占位时长 充电柜专用,其他设备忽略此字段 表示充满后占用设备的时长,单位为分钟
|
||||
|
||||
// 构造方法, 使用consumedEnergy stopReason字段构造对象
|
||||
public EBikeMessageCmd03(BigDecimal consumedEnergy, int stopReason) {
|
||||
this.consumedEnergy = consumedEnergy;
|
||||
this.stopReason= stopReason;
|
||||
}
|
||||
|
||||
public EBikeMessageCmd03(byte[] messageBytes) {
|
||||
super(messageBytes);
|
||||
|
||||
|
||||
@@ -535,18 +535,22 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
|
||||
OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(orderBasicInfo.getOrderCode());
|
||||
// 订单消费金额, 除了充满自停是需要计算实际消费, 其他金额都是按次收费
|
||||
BigDecimal orderAmount;
|
||||
// 耗电量
|
||||
BigDecimal consumedEnergy = message.getConsumedEnergy();
|
||||
if (fullOfSelfStopping.compareTo(orderBasicInfo.getPayAmount()) == 0) {
|
||||
// 耗电量
|
||||
BigDecimal consumedEnergy = message.getConsumedEnergy();
|
||||
// 计费模板
|
||||
BigDecimal flatElectricityPrice = orderDetail.getFlatElectricityPrice(); // x元/每度
|
||||
BigDecimal flatServicePrice = orderDetail.getFlatServicePrice(); // x元/每度
|
||||
if (consumedEnergy == null || flatElectricityPrice == null) {
|
||||
logger.info("计算电单车退款逻辑,耗电量或计费模板为空,不执行退款逻辑, orderCode:{}, 耗电量:{}, 每度电费:{}", orderBasicInfo.getOrderCode(), consumedEnergy, flatElectricityPrice);
|
||||
return;
|
||||
}
|
||||
// 计费模板, 只取平时段的价格
|
||||
BigDecimal flatElectricityPrice = orderDetail.getFlatElectricityPrice() != null ? orderDetail.getFlatElectricityPrice() : BigDecimal.ZERO; // x元/每度
|
||||
// BigDecimal flatServicePrice = orderDetail.getFlatServicePrice() != null ? orderDetail.getFlatServicePrice() : BigDecimal.ZERO; // x元/每度
|
||||
BigDecimal flatServicePrice = BigDecimal.ZERO; // x元/每度 服务费默认0
|
||||
// 单价 = 电费单价 + 服务费单价
|
||||
BigDecimal price = flatElectricityPrice.add(flatServicePrice);
|
||||
// 如果耗电量或单价为空或者为0,则订单消费为0
|
||||
// if (consumedEnergy == null || consumedEnergy.compareTo(BigDecimal.ZERO) == 0 || price.compareTo(BigDecimal.ZERO) == 0) {
|
||||
// logger.info("计算电单车退款逻辑,耗电量或计费模板为空,不执行退款逻辑, orderCode:{}, 耗电量:{}, 每度电费:{}", orderBasicInfo.getOrderCode(), consumedEnergy, price);
|
||||
// return;
|
||||
// }
|
||||
// 计算实际消费
|
||||
orderAmount = consumedEnergy.multiply(flatElectricityPrice);
|
||||
orderAmount = consumedEnergy.multiply(price);
|
||||
} else {
|
||||
// 其他金额都是按次收费, 不退款
|
||||
orderAmount = orderBasicInfo.getPayAmount();
|
||||
@@ -579,8 +583,8 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
|
||||
|
||||
// 更新订单详情
|
||||
if (orderDetail != null) {
|
||||
orderDetail.setTotalUsedElectricity(message.getConsumedEnergy());
|
||||
orderDetail.setFlatUsedElectricity(message.getConsumedEnergy());
|
||||
orderDetail.setTotalUsedElectricity(consumedEnergy);
|
||||
orderDetail.setFlatUsedElectricity(consumedEnergy);
|
||||
orderDetail.setTotalElectricityAmount(orderAmount); // 电费总金额
|
||||
orderDetail.setTotalServiceAmount(BigDecimal.ZERO); // 服务费总金额
|
||||
orderDetail.setTotalOrderAmount(orderDetail.getTotalElectricityAmount().add(orderDetail.getTotalServiceAmount())); // 总消费金额
|
||||
|
||||
Reference in New Issue
Block a user