mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
Merge branch 'dev' of https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web into dev
# Conflicts: # jsowell-admin/src/test/resources/payment_ids
This commit is contained in:
@@ -2,11 +2,11 @@ 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.domain.PileStationInfo;
|
||||
import com.jsowell.pile.dto.DebugOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryOrderSplitRecordDTO;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
@@ -22,7 +22,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class SplitBillService {
|
||||
@@ -32,41 +32,43 @@ public class SplitBillService {
|
||||
@Autowired
|
||||
private OrderBasicInfoService orderBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private PileStationInfoService pileStationInfoService;
|
||||
|
||||
@Autowired
|
||||
private SettleOrderReportService settleOrderReportService;
|
||||
|
||||
@Autowired
|
||||
private TempService tempService;
|
||||
|
||||
@Autowired
|
||||
private AdapayService adapayService;
|
||||
|
||||
@Autowired
|
||||
private PileStationInfoService pileStationInfoService;
|
||||
|
||||
@Autowired
|
||||
private SettleOrderReportService settleOrderReportService;
|
||||
|
||||
/**
|
||||
* 重试运营商分账
|
||||
* @param dto
|
||||
*/
|
||||
public void retryMerchantSplit(QueryOrderSplitRecordDTO dto) throws BaseAdaPayException {
|
||||
String startTime = dto.getStartTime();
|
||||
String endTime = dto.getEndTime();
|
||||
// 首先根据 merchantId、startTime、endTime 查出日期区间内所有订单信息(包括 paymentId)
|
||||
// 格式化 startTime 和 endTime
|
||||
dto.setStartTime(dto.getStartTime() + " 00:00:00");
|
||||
dto.setEndTime(dto.getEndTime() + " 23:59:59");
|
||||
List<OrderPaymentDetailVO> recordList = orderBasicInfoService.getSplitOrders(dto);
|
||||
if (CollectionUtils.isEmpty(recordList)) {
|
||||
log.info("重试运营商分账-根据参数未查询到符合条件的订单, param:{}", dto);
|
||||
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());
|
||||
}
|
||||
|
||||
// 判断订单是否已经成功分账, 将未分账的订单进行筛选、汇总
|
||||
@@ -78,6 +80,11 @@ 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) {
|
||||
@@ -99,19 +106,38 @@ public class SplitBillService {
|
||||
}
|
||||
}
|
||||
|
||||
// 重新计算站点日报和运营商日报
|
||||
// 获取日期区间内所有日期
|
||||
List<String> dateList = DateUtils.getAllDatesInTheDateRange(dto.getStartTime(), dto.getEndTime());
|
||||
// 重新计算站点订单日报
|
||||
stationIdSet.parallelStream().forEach(stationId -> {
|
||||
List<String> dateList = DateUtils.getAllDatesInTheDateRange(startTime, endTime);
|
||||
// 根据 merchantId 获取所有 stationId
|
||||
List<PileStationInfo> pileStationInfos = pileStationInfoService.selectStationListByMerchantId(Long.parseLong(dto.getMerchantId()));
|
||||
List<String> stationIdList = pileStationInfos.stream()
|
||||
.map(PileStationInfo::getId)
|
||||
.map(String::valueOf)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
stationIdList.parallelStream().forEach(stationId -> {
|
||||
PileStationVO stationInfo = pileStationInfoService.getStationInfo(stationId);
|
||||
for (String tradeDate : dateList) {
|
||||
try {
|
||||
settleOrderReportService.generateDailyOrderReports(stationInfo, tradeDate);
|
||||
log.info("重试运营商分账-生成站点日报成功, param:{}", tradeDate);
|
||||
}catch (Exception e) {
|
||||
log.error("重试运营商分账-生成站点日报异常, param:{}", tradeDate, e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 重新计算运营商日报
|
||||
for (String tradeDate : dateList) {
|
||||
try {
|
||||
orderBasicInfoService.generateMerchantBill(dto.getMerchantId(), tradeDate);
|
||||
}
|
||||
log.info("重试运营商分账-生成运营商日报成功, param:{}", tradeDate);
|
||||
}catch (Exception e) {
|
||||
log.error("重试运营商分账-生成运营商日报异常, param:{}", tradeDate, e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user