update 重试运营商分账

This commit is contained in:
Guoqs
2025-10-11 10:42:15 +08:00
parent e6865a4f92
commit befffda063

View File

@@ -2,13 +2,18 @@ package com.jsowell.service;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.jsowell.adapay.service.AdapayService;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.util.DateUtils;
import com.jsowell.pile.dto.DebugOrderDTO;
import com.jsowell.pile.dto.QueryOrderSplitRecordDTO;
import com.jsowell.pile.service.OrderBasicInfoService;
import com.jsowell.pile.service.PileStationInfoService;
import com.jsowell.pile.service.SettleOrderReportService;
import com.jsowell.pile.vo.web.OrderPaymentDetailVO;
import com.jsowell.pile.vo.web.PileStationVO;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -17,6 +22,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Service
public class SplitBillService {
@@ -26,6 +32,12 @@ public class SplitBillService {
@Autowired
private OrderBasicInfoService orderBasicInfoService;
@Autowired
private PileStationInfoService pileStationInfoService;
@Autowired
private SettleOrderReportService settleOrderReportService;
@Autowired
private TempService tempService;
@@ -44,17 +56,14 @@ public class SplitBillService {
return;
}
// 获取 paymentIdList
// List<String> paymentIdList = recordList.stream()
// .map(OrderPaymentDetailVO::getPaymentId)
// .collect(Collectors.toList());
// 循环一次获得paymentIdList 与 Map
List<String> paymentIdList = Lists.newArrayList();
Map<String, OrderPaymentDetailVO> paymentIdMap = Maps.newHashMap();
Set<String> stationIdSet = Sets.newHashSet();
for (OrderPaymentDetailVO orderPaymentDetailVO : recordList) {
paymentIdList.add(orderPaymentDetailVO.getPaymentId());
paymentIdMap.put(orderPaymentDetailVO.getPaymentId(), orderPaymentDetailVO);
stationIdSet.add(orderPaymentDetailVO.getStationId());
}
// 判断订单是否已经成功分账, 将未分账的订单进行筛选、汇总
@@ -66,11 +75,6 @@ public class SplitBillService {
// 将 paymentIdList 与 recordList 进行匹配,筛选出 orderCodeList
List<String> orderCodeList = Lists.newArrayList();
// Set<String> paymentIdSet = new HashSet<>(unSplitPaymentIdList);
// List<String> orderCodeList = recordList.stream()
// .filter(record -> paymentIdSet.contains(record.getPaymentId()))
// .map(OrderPaymentDetailVO::getOrderCode)
// .collect(Collectors.toList());
for (String unSplitPaymentId : unSplitPaymentIdList) {
OrderPaymentDetailVO orderPaymentDetailVO = paymentIdMap.get(unSplitPaymentId);
if (orderPaymentDetailVO != null) {
@@ -92,5 +96,19 @@ public class SplitBillService {
}
}
// 获取日期区间内所有日期
List<String> dateList = DateUtils.getAllDatesInTheDateRange(dto.getStartTime(), dto.getEndTime());
// 重新计算站点订单日报
stationIdSet.parallelStream().forEach(stationId -> {
PileStationVO stationInfo = pileStationInfoService.getStationInfo(stationId);
for (String tradeDate : dateList) {
settleOrderReportService.generateDailyOrderReports(stationInfo, tradeDate);
}
});
// 重新计算运营商日报
for (String tradeDate : dateList) {
orderBasicInfoService.generateMerchantBill(dto.getMerchantId(), tradeDate);
}
}
}