update 人工结算订单添加查询交易记录逻辑

This commit is contained in:
Lemon
2025-11-06 11:32:43 +08:00
parent 1068c4c5dd
commit 5c5f8c565c

View File

@@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@@ -775,22 +776,32 @@ public class OrderService {
// 充电度数
String chargingDegree = dto.getChargingDegree();
// 先查交易记录
LocalDateTime localDateTime = DateUtils.date2LocalDateTime(orderBasicInfo.getSettlementTime());
// 获取订单结算时间
Date settlementTime = orderBasicInfo.getSettlementTime();
// 获取订单停止充电时间
Date chargeEndTime = orderBasicInfo.getChargeEndTime();
// 如果订单结算时间与订单停止充电时间都为空,则打印错误信息并返回
if (settlementTime == null && chargeEndTime == null) {
log.error("人工结算订单 error -订单结算时间与订单停止充电时间都为空");
return false;
}
LocalDateTime localDateTime = DateUtils.date2LocalDateTime(settlementTime != null ? settlementTime : chargeEndTime);
// 开始时间为localDateTime减30秒
LocalDateTime startTime = localDateTime.minusSeconds(30);
// 结束时间为localDateTime加30秒
LocalDateTime endTime = localDateTime.plusSeconds(30);
// 查询这笔订单的交易记录原始数据
List<PileMsgRecord> pileFeedListV2 = pileMsgRecordService.getPileFeedListV2(orderBasicInfo.getPileSn(), "0x3B", startTime, endTime);
if (CollectionUtils.isEmpty(pileFeedListV2)) {
// 如果没有交易记录原始数据,则使用停止充电时间作为开始时间和结束时间再查一次
localDateTime = DateUtils.date2LocalDateTime(orderBasicInfo.getChargeEndTime());
startTime = localDateTime.minusSeconds(30);
endTime = localDateTime.plusSeconds(30);
pileFeedListV2 = pileMsgRecordService.getPileFeedListV2(orderBasicInfo.getPileSn(), "0x3B", startTime, endTime);
}
// if (CollectionUtils.isEmpty(pileFeedListV2)) {
// // 如果没有交易记录原始数据,则使用停止充电时间作为开始时间和结束时间再查一次
// localDateTime = DateUtils.date2LocalDateTime(chargeEndTime);
// startTime = localDateTime.minusSeconds(30);
// endTime = localDateTime.plusSeconds(30);
// pileFeedListV2 = pileMsgRecordService.getPileFeedListV2(orderBasicInfo.getPileSn(), "0x3B", startTime, endTime);
// }
for (PileMsgRecord pileMsgRecord : pileFeedListV2) {
TransactionRecordsData parse = JSONObject.parseObject(pileMsgRecord.getJsonMsg(), TransactionRecordsData.class);
if (StringUtils.equals(parse.getTransactionCode(), orderBasicInfo.getTransactionCode())) {