mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-06 11:00:13 +08:00
根据paymentIdList查询分账信息
This commit is contained in:
@@ -7,7 +7,6 @@ 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;
|
||||
@@ -126,4 +125,82 @@ public class SplitBillService {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void retryMerchantSplitV2(QueryOrderSplitRecordDTO dto) throws BaseAdaPayException {
|
||||
String startTime = dto.getStartTime();
|
||||
String endTime = dto.getEndTime();
|
||||
// 首先根据 merchantId、startTime、endTime 查出日期区间内所有订单信息(包括 paymentId)
|
||||
List<OrderPaymentDetailVO> recordList = orderBasicInfoService.getSplitOrders(dto);
|
||||
if (CollectionUtils.isEmpty(recordList)) {
|
||||
log.info("重试运营商分账-根据参数未查询到符合条件的订单, param:{}", dto);
|
||||
return;
|
||||
}
|
||||
|
||||
// 循环一次,获得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());
|
||||
}
|
||||
|
||||
// 判断订单是否已经成功分账, 将未分账的订单进行筛选、汇总
|
||||
List<String> unSplitPaymentIdList = adapayService.getSplitInfoByPaymentIdList(paymentIdList);
|
||||
if (CollectionUtils.isEmpty(unSplitPaymentIdList)) {
|
||||
log.info("重试运营商分账-所有订单都已经成功分账");
|
||||
return;
|
||||
}
|
||||
|
||||
// 将 paymentIdList 与 recordList 进行匹配,筛选出 orderCodeList
|
||||
List<String> orderCodeList = Lists.newArrayList();
|
||||
for (String unSplitPaymentId : unSplitPaymentIdList) {
|
||||
OrderPaymentDetailVO orderPaymentDetailVO = paymentIdMap.get(unSplitPaymentId);
|
||||
if (orderPaymentDetailVO != null) {
|
||||
orderCodeList.add(orderPaymentDetailVO.getOrderCode());
|
||||
}
|
||||
}
|
||||
|
||||
// 调用 debugOrder 接口进行重新分账
|
||||
for (String orderCode : orderCodeList) {
|
||||
DebugOrderDTO debugOrderDTO = new DebugOrderDTO();
|
||||
debugOrderDTO.setOrderCode(orderCode);
|
||||
debugOrderDTO.setReSplitFlag(Constants.ONE);
|
||||
|
||||
try {
|
||||
Map<String, Object> stringObjectMap = tempService.debugOrder(debugOrderDTO);
|
||||
log.info("重试运营商分账-debugOrder接口调用成功, param:{}, result:{}", debugOrderDTO, stringObjectMap);
|
||||
} catch (Exception e) {
|
||||
log.error("重试运营商分账-debugOrder接口调用异常, param:{}", debugOrderDTO, e);
|
||||
}
|
||||
}
|
||||
|
||||
// 重新计算站点日报和运营商日报
|
||||
// 获取日期区间内所有日期
|
||||
List<String> dateList = DateUtils.getAllDatesInTheDateRange(startTime, endTime);
|
||||
stationIdSet.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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,8 +86,8 @@ public class PaymentTestController {
|
||||
@Test
|
||||
public void queryCreateConfirmReverseNew() throws BaseAdaPayException {
|
||||
List<String> paymentIdList = getPaymentIdList(); // 查询分账信息
|
||||
List<String> splitInfoByPaymentIdList = adapayService.getSplitInfoByPaymentIdList(paymentIdList);
|
||||
System.out.println("未分账paymentId:" + splitInfoByPaymentIdList);
|
||||
Map<String, List<String>> splitInfoMap = adapayService.getSplitInfoMapByPaymentIdList(paymentIdList);
|
||||
System.out.println("splitInfoMap:" + JSON.toJSONString(splitInfoMap));
|
||||
}
|
||||
|
||||
public List<String> getPaymentIdList() {
|
||||
|
||||
@@ -1,138 +1,3 @@
|
||||
002212025092522524610817300778411462656
|
||||
002212025092523381210817312211484381184
|
||||
002212025092601015510817333280098480128
|
||||
002212025092605040010817394205119447040
|
||||
002212025092606182910817412949334286336
|
||||
002212025092606283410817415485092900864
|
||||
002212025092606320010817416349857419264
|
||||
002212025092606472410817420223817416704
|
||||
002212025092606533410817421777744281600
|
||||
002212025092606551910817422215214215168
|
||||
002212025092607014510817423836484845568
|
||||
002212025092607103010817426039769513984
|
||||
002212025092607114710817426360587776000
|
||||
002212025092607181110817427970810130432
|
||||
002212025092607283610817430592267218944
|
||||
002212025092607330310817431714629267456
|
||||
002212025092607443110817434600184737792
|
||||
002212025092607470210817435231280394240
|
||||
002212025092607472410817435325526700032
|
||||
002212025092607555310817437459504242688
|
||||
002212025092608012310817438842039107584
|
||||
002212025092608235510817444513182859264
|
||||
002212025092608360110817447558478266368
|
||||
002212025092608403710817448716433309696
|
||||
002212025092609001210817453646720376832
|
||||
002212025092609075410817455582949519360
|
||||
002212025092609080710817455637798436864
|
||||
002212025092609122710817456726278885376
|
||||
002212025092609142010817457201518993408
|
||||
002212025092609345210817462370805583872
|
||||
002212025092609352610817462513231572992
|
||||
002212025092609392110817463499425542144
|
||||
002212025092610111110817471506553053184
|
||||
002212025092610300210817476250265186304
|
||||
002212025092610335810817477240380833792
|
||||
002212025092610461810817480345155649536
|
||||
002212025092610595510817483774011748352
|
||||
002212025092611014510817484233174491136
|
||||
002212025092611044910817485007464128512
|
||||
002212025092611194410817488758472126464
|
||||
002212025092611290110817491095056130048
|
||||
002212025092611433210817494747938410496
|
||||
002212025092611501610817496441996664832
|
||||
002212025092611550210817497643622821888
|
||||
002212025092611552910817497755774320640
|
||||
002212025092611560610817497912691621888
|
||||
002212025092611571910817498219530412032
|
||||
002212025092611585210817498606702268416
|
||||
002212025092612055210817500369916219392
|
||||
002212025092612081010817500949912817664
|
||||
002212025092612121410817501973256032256
|
||||
002212025092612122210817502004008525824
|
||||
002212025092612123510817502058383777792
|
||||
002212025092612141310817502469869862912
|
||||
002212025092612244110817505106405171200
|
||||
002212025092612251010817505225737605120
|
||||
002212025092612294310817506372015726592
|
||||
002212025092612294310817506373315964928
|
||||
002212025092612362710817508066912862208
|
||||
002212025092612415110817509424554536960
|
||||
002212025092612551310817512788558462976
|
||||
002212025092613015510817514474538635264
|
||||
002212025092613072010817515837700173824
|
||||
002212025092613082410817516108530429952
|
||||
002212025092613152310817517864551297024
|
||||
002212025092613251110817520328079802368
|
||||
002212025092613254110817520455683256320
|
||||
002212025092613593310817528977678508032
|
||||
002212025092614023410817529739422687232
|
||||
002212025092614083410817531247455178752
|
||||
002212025092614121810817532188845735936
|
||||
002212025092614135610817532597245259776
|
||||
002212025092614173410817533514787180544
|
||||
002212025092614195710817534110638387200
|
||||
002212025092614231710817534950858141696
|
||||
002212025092614463810817540826650083328
|
||||
002212025092614515110817542140159430656
|
||||
002212025092614582310817543784670380032
|
||||
002212025092615112110817547047977607169
|
||||
002212025092615175910817548716693590016
|
||||
002212025092615202310817549323123138560
|
||||
002212025092615403810817554419231866880
|
||||
002212025092615555710817558271821561856
|
||||
002212025092616030610817560070297030656
|
||||
002212025092616080310817561314822836224
|
||||
002212025092616120610817562335112290304
|
||||
002212025092616155210817563284652531712
|
||||
002212025092616225510817565056901156864
|
||||
002212025092616241910817565411214991360
|
||||
002212025092616304910817567047287300096
|
||||
002212025092616375510817568834597384192
|
||||
002212025092616394710817569303705116672
|
||||
002212025092616465110817571082945658880
|
||||
002212025092616540010817572881123618816
|
||||
002212025092616564710817573580108271616
|
||||
002212025092616574410817573821368836096
|
||||
002212025092617003610817574541266743296
|
||||
002212025092617061910817575980156436480
|
||||
002212025092617101510817576968808411136
|
||||
002212025092617134110817577835439538176
|
||||
002212025092617273710817581340678279168
|
||||
002212025092617321210817582495349186560
|
||||
002212025092617333510817582841446236160
|
||||
002212025092617345310817583167838580736
|
||||
002212025092617390310817584217526059008
|
||||
002212025092617445210817585681229406208
|
||||
002212025092617464610817586160675962880
|
||||
002212025092617560210817588492063064064
|
||||
002212025092617563610817588633004097536
|
||||
002212025092617584210817589163516604416
|
||||
002212025092618000010817589490299166720
|
||||
002212025092618061810817591074533781504
|
||||
002212025092618380910817599089915531264
|
||||
002212025092618483310817601709288038400
|
||||
002212025092618542510817603184256835584
|
||||
002212025092619023710817605249721016320
|
||||
002212025092619045110817605810038083584
|
||||
002212025092619062310817606195288961024
|
||||
002212025092619111010817607400782266368
|
||||
002212025092619193210817609505593061376
|
||||
002212025092619193710817609524907978752
|
||||
002212025092619225310817610349063557120
|
||||
002212025092619252610817610991110524928
|
||||
002212025092619264910817611337136558080
|
||||
002212025092619290210817611895289225216
|
||||
002212025092619490910817616958728646656
|
||||
002212025092619494110817617090832453632
|
||||
002212025092619551710817618501150556160
|
||||
002212025092620062310817621294707703808
|
||||
002212025092620135710817623198037028864
|
||||
002212025092620222510817625331318464512
|
||||
002212025092620272710817626597281337344
|
||||
002212025092620420310817630272376651776
|
||||
002212025092621112910817637676828954624
|
||||
002212025092621354910817643801028395008
|
||||
002212025092621413910817645268435312640
|
||||
002212025092621444910817646066690895872
|
||||
002212025092622084610817652092584701952
|
||||
|
||||
@@ -1643,10 +1643,6 @@ public class AdapayService {
|
||||
unSplitList.add(paymentId);
|
||||
}
|
||||
}
|
||||
// System.out.println("=================未分账:" + JSON.toJSONString(unSplitList) + ", 数量:" + unSplitList.size());
|
||||
// System.out.println("=================已分账:" + JSON.toJSONString(map) + ", 总分账:" + total + ", 数量:" + splitList.size());
|
||||
// System.out.println("===============金额明细:" + "总到账金额:" + totalWithdrawalAmt + ", 总手续费:" + totalFeeAmt);
|
||||
// System.out.println("===================自己:" + JSON.toJSONString(selfList) + ", 数量:" + selfList.size());
|
||||
log.info("\n入参paymentId数量:{}, 已分帐数量:{}, 未分帐数量:{}, 未分帐id:{} " +
|
||||
"\n已分帐:{}, 总分账:{}, 数量:{}" +
|
||||
"\n金额明细:[总到账金额:{}, 总手续费:{}] " +
|
||||
@@ -1657,4 +1653,100 @@ public class AdapayService {
|
||||
selfList, selfList.size());
|
||||
return unSplitList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据paymentIdList查询分账信息
|
||||
*/
|
||||
public Map<String, List<String>> getSplitInfoMapByPaymentIdList(List<String> paymentIdList) throws BaseAdaPayException {
|
||||
Map<String, List<String>> resultMap = Maps.newHashMap();
|
||||
if (CollectionUtils.isEmpty(paymentIdList)) {
|
||||
return resultMap;
|
||||
}
|
||||
List<String> unSplitList = Lists.newArrayList(); // 未分帐
|
||||
List<String> splitList = Lists.newArrayList(); // 已分帐
|
||||
List<String> selfList = Lists.newArrayList(); // 自己分帐
|
||||
|
||||
BigDecimal total = BigDecimal.ZERO; // 总分账金额
|
||||
BigDecimal totalWithdrawalAmt = BigDecimal.ZERO; // 实际到账金额汇总
|
||||
BigDecimal totalFeeAmt = BigDecimal.ZERO; // 手续费金额汇总
|
||||
|
||||
Map<String, BigDecimal> amountDetailMap = Maps.newHashMap();
|
||||
for (String paymentId : paymentIdList) {
|
||||
if (StringUtils.isBlank(paymentId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 根据paymentId查询支付确认情况
|
||||
QueryPaymentConfirmDTO dto = new QueryPaymentConfirmDTO();
|
||||
dto.setPaymentId(paymentId);
|
||||
dto.setWechatAppId(wechatAppId1);
|
||||
QueryPaymentConfirmDetailResponse response = this.queryPaymentConfirmList(dto);
|
||||
|
||||
if (response == null) {
|
||||
// 未查询到分账信息,add to unSplitList
|
||||
unSplitList.add(paymentId);
|
||||
continue;
|
||||
}
|
||||
|
||||
List<PaymentConfirmInfo> confirms = response.getPaymentConfirms();
|
||||
if (CollectionUtils.isEmpty(confirms)) {
|
||||
// confirms为空,add to unSplitList
|
||||
unSplitList.add(paymentId);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 添加到已分帐list
|
||||
splitList.add(paymentId);
|
||||
for (PaymentConfirmInfo confirm : confirms) {
|
||||
if (this.queryConfirmReverseStatus(confirm)) {
|
||||
log.info("支付确认id:" + confirm.getId() + "撤销了。。。");
|
||||
continue;
|
||||
}
|
||||
JSONObject jsonObject = JSON.parseObject(confirm.getDescription());
|
||||
String adapayMemberId = jsonObject.getString("adapayMemberId");
|
||||
if (StringUtils.isBlank(adapayMemberId)) {
|
||||
adapayMemberId = jsonObject.getString("adapayMemberIds");
|
||||
}
|
||||
|
||||
BigDecimal confirmAmt = new BigDecimal(confirm.getConfirmAmt()); // 本次确认金额
|
||||
BigDecimal confirmedAmt = new BigDecimal(confirm.getConfirmedAmt()); // 已确认金额
|
||||
BigDecimal feeAmt = new BigDecimal(confirm.getFeeAmt()); // 手续费
|
||||
|
||||
// 汇总已确认金额
|
||||
total = total.add(confirmedAmt);
|
||||
|
||||
// 汇总手续费金额
|
||||
totalFeeAmt = totalFeeAmt.add(feeAmt);
|
||||
|
||||
// 汇总可提现金额
|
||||
totalWithdrawalAmt = totalWithdrawalAmt.add(confirmAmt).subtract(feeAmt);
|
||||
|
||||
// confirm
|
||||
List<DivMember> divMembers = confirm.getDivMembers();
|
||||
// System.out.println("confirm:" + JSON.toJSONString(divMembers));
|
||||
for (DivMember divMember : divMembers) {
|
||||
// 放map
|
||||
amountDetailMap.merge(divMember.getMemberId(), new BigDecimal(divMember.getAmount()), BigDecimal::add);
|
||||
}
|
||||
|
||||
if (StringUtils.equals(adapayMemberId, "0")
|
||||
|| StringUtils.equals(adapayMemberId, "AM29102732")) {
|
||||
// 0为默认平台id, AM29102732为罗总账户
|
||||
selfList.add(paymentId);
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("\n入参paymentId数量:{}, 已分帐数量:{}, 未分帐数量:{}, 未分帐id:{} " +
|
||||
"\n已分帐:{}, 总分账:{}, 数量:{}" +
|
||||
"\n金额明细:[总到账金额:{}, 总手续费:{}] " +
|
||||
"\n自己:{}, 数量:{}",
|
||||
paymentIdList.size(), splitList.size(), unSplitList.size(), unSplitList,
|
||||
JSON.toJSONString(amountDetailMap), total, splitList.size(),
|
||||
totalWithdrawalAmt, totalFeeAmt,
|
||||
selfList, selfList.size());
|
||||
|
||||
resultMap.put("unSplitList", unSplitList);
|
||||
resultMap.put("splitList", splitList);
|
||||
return resultMap;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user