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:
@@ -1,29 +1,34 @@
|
||||
package com.jsowell.service;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||
import com.jsowell.adapay.service.AdapayService;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.pile.domain.OrderSplitRecord;
|
||||
import com.jsowell.pile.dto.DebugOrderDTO;
|
||||
import com.jsowell.pile.dto.QueryOrderSplitRecordDTO;
|
||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
||||
import com.jsowell.pile.vo.web.OrderPaymentDetailVO;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class SplitBillService {
|
||||
|
||||
private final Logger log = LoggerFactory.getLogger(SplitBillService.class);
|
||||
|
||||
@Autowired
|
||||
private OrderBasicInfoService orderBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private TempService tempService;
|
||||
|
||||
@Autowired
|
||||
private AdapayService adapayService;
|
||||
|
||||
@@ -33,20 +38,45 @@ public class SplitBillService {
|
||||
*/
|
||||
public void retryMerchantSplit(QueryOrderSplitRecordDTO dto) throws BaseAdaPayException {
|
||||
// 首先根据 merchantId、startTime、endTime 查出日期区间内所有订单信息(包括 paymentId)
|
||||
List<OrderSplitRecord> recordList = orderBasicInfoService.getSplitOrders(dto);
|
||||
List<OrderPaymentDetailVO> recordList = orderBasicInfoService.getSplitOrders(dto);
|
||||
if (CollectionUtils.isEmpty(recordList)) {
|
||||
log.info("重试运营商分账-根据参数未查询到符合条件的订单, param:{}", dto);
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取 paymentIdList
|
||||
List<String> paymentIdList = recordList.stream()
|
||||
.map(OrderSplitRecord::getPaymentId)
|
||||
.collect(Collectors.toList());
|
||||
// 判断订单是否已经成功分账
|
||||
// 将未分账的订单进行筛选、汇总
|
||||
// List<String> paymentIdList = recordList.stream()
|
||||
// .map(OrderPaymentDetailVO::getPaymentId)
|
||||
// .collect(Collectors.toList());
|
||||
|
||||
// 循环一次,获得paymentIdList 与 Map
|
||||
List<String> paymentIdList = Lists.newArrayList();
|
||||
Map<String, OrderPaymentDetailVO> paymentIdMap = Maps.newHashMap();
|
||||
for (OrderPaymentDetailVO orderPaymentDetailVO : recordList) {
|
||||
paymentIdList.add(orderPaymentDetailVO.getPaymentId());
|
||||
paymentIdMap.put(orderPaymentDetailVO.getPaymentId(), orderPaymentDetailVO);
|
||||
}
|
||||
|
||||
// 判断订单是否已经成功分账, 将未分账的订单进行筛选、汇总
|
||||
List<String> unSplitPaymentIdList = adapayService.getSplitInfoByPaymentIdList(paymentIdList);
|
||||
if (CollectionUtils.isEmpty(unSplitPaymentIdList)) {
|
||||
log.info("重试运营商分账-所有订单都已经成功分账");
|
||||
return;
|
||||
}
|
||||
|
||||
// 将 paymentIdList 与 recordList 进行匹配,筛选出 orderCodeList
|
||||
Set<String> paymentIdSet = new HashSet<>(unSplitPaymentIdList);
|
||||
List<String> orderCodeList = recordList.stream()
|
||||
.filter(record -> paymentIdSet.contains(record.getPaymentId()))
|
||||
.map(OrderSplitRecord::getOrderCode)
|
||||
.collect(Collectors.toList());
|
||||
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) {
|
||||
orderCodeList.add(orderPaymentDetailVO.getOrderCode());
|
||||
}
|
||||
}
|
||||
|
||||
// 调用 debugOrder 接口进行重新分账
|
||||
for (String orderCode : orderCodeList) {
|
||||
@@ -54,7 +84,11 @@ public class SplitBillService {
|
||||
debugOrderDTO.setOrderCode(orderCode);
|
||||
debugOrderDTO.setReSplitFlag(Constants.ONE);
|
||||
|
||||
tempService.debugOrder(debugOrderDTO);
|
||||
try {
|
||||
tempService.debugOrder(debugOrderDTO);
|
||||
} catch (Exception e) {
|
||||
log.error("重试运营商分账-debugOrder接口调用异常, param:{}", debugOrderDTO, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.jsowell.adapay.service.AdapayService;
|
||||
import com.jsowell.adapay.vo.OrderSplitResult;
|
||||
import com.jsowell.adapay.vo.PaymentInfo;
|
||||
import com.jsowell.common.annotation.CostTime;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.constant.RabbitConstants;
|
||||
import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
|
||||
import com.jsowell.common.core.redis.RedisCache;
|
||||
@@ -1107,7 +1108,7 @@ public class TempService {
|
||||
// 是否重新计算
|
||||
String reCalculateFlag = dto.getReCalculateFlag();
|
||||
String reCalculateFlagResult = orderCode + "本次未重新计算订单";
|
||||
if (StringUtils.equals(reCalculateFlag, "1")) {
|
||||
if (StringUtils.equals(reCalculateFlag, Constants.ONE)) {
|
||||
LocalDateTime localDateTime = DateUtils.date2LocalDateTime(orderBasicInfo.getSettlementTime());
|
||||
// 开始时间为localDateTime减30秒
|
||||
LocalDateTime startTime = localDateTime.minusSeconds(30);
|
||||
@@ -1179,7 +1180,7 @@ public class TempService {
|
||||
// 是否重新退款
|
||||
String reRefundFlag = dto.getReRefundFlag();
|
||||
String reRefundFlagResult = orderCode + "本次未重新退款";
|
||||
if (StringUtils.equals(reRefundFlag, "1")) {
|
||||
if (StringUtils.equals(reRefundFlag, Constants.ONE)) {
|
||||
// 订单退款,汇付退款
|
||||
try {
|
||||
orderBasicInfoService.refundMethod(afterSettleOrderDTO);
|
||||
@@ -1194,7 +1195,7 @@ public class TempService {
|
||||
// 是否重新分账
|
||||
String reSplitFlag = dto.getReSplitFlag();
|
||||
String reSplitFlagResult = orderCode + "本次未重新分账";
|
||||
if (StringUtils.equals(reSplitFlag, "1")) {
|
||||
if (StringUtils.equals(reSplitFlag, Constants.ONE)) {
|
||||
try {
|
||||
orderBasicInfoService.splittingMethod(afterSettleOrderDTO);
|
||||
} catch (Exception e) {
|
||||
|
||||
Reference in New Issue
Block a user