From 7217e095eda8326e24aaef7b72c11d16f88e8742 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期一, 14 九月 2026 13:14:22 +0800
Subject: [PATCH] feat(payment): 进件时自动开启结算并配置好资金能力

---
 talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuEnterpriseOnboardingGateway.java |   20 ++++++++++++++++++++
 talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuIndividualOnboardingGateway.java |    2 ++
 2 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuEnterpriseOnboardingGateway.java b/talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuEnterpriseOnboardingGateway.java
index 59049c3..ed8d2b9 100644
--- a/talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuEnterpriseOnboardingGateway.java
+++ b/talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuEnterpriseOnboardingGateway.java
@@ -94,6 +94,7 @@
         putIfPresent(request, "settle_cert_front_pic", command.settlementCertificateFrontPictureId());
         putIfPresent(request, "settle_cert_back_pic", command.settlementCertificateBackPictureId());
         request.put("cash_config", JSON.toJSONString(List.of(cash)));
+        request.put("settle_config", JSON.toJSONString(settleConfig()));
         putIfPresent(request, "async_return_url", properties.getMerchantOnboardingNotifyUrl());
         try {
             synchronized (SDK_LOCK) {
@@ -110,6 +111,25 @@
         }
     }
 
+    /**
+     * 结算配置:进件即打开自动结算,让核销确认后的钱由斗拱按结算周期自动划到结算卡,
+     * 商户和平台都不需要再手工发起出款。
+     *
+     * <p>不设起结金额与留存金额:一笔 1 分钱也要能结出去。结算周期由渠道商开通的业务类型决定,
+     * 当前可用的是 D1(次自然日到账)。
+     */
+    static Map<String, Object> settleConfig() {
+        Map<String, Object> settle = new LinkedHashMap<>();
+        settle.put("settle_status", "1");
+        settle.put("settle_cycle", "D1");
+        settle.put("settle_pattern", "P0");
+        settle.put("min_amt", "0.00");
+        settle.put("remained_amt", "0.00");
+        settle.put("out_settle_flag", "2");
+        settle.put("fee_rate", "0.00");
+        return settle;
+    }
+
     private void ensureConfigured() {
         if (!properties.isEnabled()) throw new BusinessException(ErrorCode.CONFLICT, "Huifu payment is disabled");
         if (blank(properties.getSystemId()) || blank(properties.getProductId()) || blank(properties.getOnboardingUpperHuifuId()) || blank(properties.getPrivateKey()) || blank(properties.getPlatformPublicKey())) throw new BusinessException(ErrorCode.CONFLICT, "Huifu merchant onboarding configuration is incomplete");
diff --git a/talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuIndividualOnboardingGateway.java b/talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuIndividualOnboardingGateway.java
index a7a8833..3d7c5ef 100644
--- a/talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuIndividualOnboardingGateway.java
+++ b/talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuIndividualOnboardingGateway.java
@@ -71,6 +71,8 @@
         request.put("card_info", JSON.toJSONString(card));
         request.put("settle_card_front_pic", command.settlementCardFrontPictureId());
         request.put("cash_config", JSON.toJSONString(List.of(cash)));
+        // 与商户主体一致:进件即打开自动结算,核销确认后的钱由斗拱按结算周期自动划到结算卡。
+        request.put("settle_config", JSON.toJSONString(HuifuEnterpriseOnboardingGateway.settleConfig()));
         putIfPresent(request, "async_return_url", properties.getMerchantOnboardingNotifyUrl());
         try {
             synchronized (SDK_LOCK) {

--
Gitblit v1.7.1