From 85831da2a56cfb304df5eaee7021e491d39ee55d Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期一, 14 九月 2026 12:29:36 +0800
Subject: [PATCH] fix(merchant): 提现失败后可重试,且不再丢掉通道流水号

---
 talent-card-server/src/main/java/com/talentcard/server/business/admin/MerchantSettlementAdminService.java |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/talent-card-server/src/main/java/com/talentcard/server/business/admin/MerchantSettlementAdminService.java b/talent-card-server/src/main/java/com/talentcard/server/business/admin/MerchantSettlementAdminService.java
index 126a829..419da1f 100644
--- a/talent-card-server/src/main/java/com/talentcard/server/business/admin/MerchantSettlementAdminService.java
+++ b/talent-card-server/src/main/java/com/talentcard/server/business/admin/MerchantSettlementAdminService.java
@@ -1,5 +1,6 @@
 package com.talentcard.server.business.admin;
 
+import java.time.LocalDate;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -7,7 +8,9 @@
 
 import com.talentcard.server.business.DatabaseRows;
 import com.talentcard.server.business.PageResult;
+import com.talentcard.server.business.merchant.AutoWithdrawalAggregationService;
 import com.talentcard.server.business.merchant.AutoWithdrawalResultService;
+import com.talentcard.server.business.merchant.AutoWithdrawalScheduler;
 import com.talentcard.server.common.BusinessException;
 import com.talentcard.server.common.ErrorCode;
 import com.talentcard.server.common.SensitiveDataCrypto;
@@ -28,7 +31,27 @@
     private final JdbcTemplate jdbc;
     private final SensitiveDataCrypto sensitiveDataCrypto;
     private final MerchantPaymentReadinessService readinessService;
-    public MerchantSettlementAdminService(JdbcTemplate jdbc, SensitiveDataCrypto sensitiveDataCrypto, MerchantPaymentReadinessService readinessService) { this.jdbc = jdbc; this.sensitiveDataCrypto = sensitiveDataCrypto; this.readinessService = readinessService; }
+    private final AutoWithdrawalScheduler autoWithdrawalScheduler;
+    public MerchantSettlementAdminService(JdbcTemplate jdbc, SensitiveDataCrypto sensitiveDataCrypto, MerchantPaymentReadinessService readinessService, AutoWithdrawalScheduler autoWithdrawalScheduler) { this.jdbc = jdbc; this.sensitiveDataCrypto = sensitiveDataCrypto; this.readinessService = readinessService; this.autoWithdrawalScheduler = autoWithdrawalScheduler; }
+
+    /**
+     * 按业务日补跑一次日汇总并立刻提交、收敛结果。
+     *
+     * <p>定时任务汇总的是「前一自然日」,当天核销的订单要等到第二天凌晨才会出账;排查和验收都等不起,
+     * 所以这里提供一次显式补跑。它不接受「不传日期」:隐式取当天容易误刷历史,日期必须由调用方给定。
+     */
+    public Map<String, Object> runAutoWithdrawalAggregation(LocalDate businessDate) {
+        if (businessDate == null) throw new BusinessException(ErrorCode.BAD_REQUEST, "请指定业务日 businessDate(yyyyMMdd)");
+        AutoWithdrawalAggregationService.Result result = autoWithdrawalScheduler.runForBusinessDate(businessDate);
+        Map<String, Object> view = new LinkedHashMap<>();
+        view.put("businessDate", result.businessDate());
+        view.put("merchantsAggregated", result.merchantsAggregated());
+        view.put("merchantsSkipped", result.merchantsSkipped());
+        view.put("merchantsFailed", result.merchantsFailed());
+        view.put("ordersAggregated", result.ordersAggregated());
+        view.put("amountCents", result.amountCents());
+        return view;
+    }
 
     @Transactional(readOnly = true)
     public PageResult<Map<String, Object>> onboardings(int page, int size, String merchantName, String contactMobile, String merchantType, String status, String startDate, String endDate) {

--
Gitblit v1.7.1