From 5364ba7487eb7abe0d4adc67f3393f511ed123a7 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期一, 14 九月 2026 12:29:27 +0800
Subject: [PATCH] feat(payment): 延迟入账的支付改为核销后确认资金

---
 talent-card-server/src/main/java/com/talentcard/server/business/merchant/MerchantWorkService.java |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/talent-card-server/src/main/java/com/talentcard/server/business/merchant/MerchantWorkService.java b/talent-card-server/src/main/java/com/talentcard/server/business/merchant/MerchantWorkService.java
index a7be502..969b158 100644
--- a/talent-card-server/src/main/java/com/talentcard/server/business/merchant/MerchantWorkService.java
+++ b/talent-card-server/src/main/java/com/talentcard/server/business/merchant/MerchantWorkService.java
@@ -16,6 +16,7 @@
 import com.talentcard.server.business.PageResult;
 import com.talentcard.server.business.merchant.auth.MerchantPrincipal;
 import com.talentcard.server.business.order.OrderFundBoundaryService;
+import com.talentcard.server.business.payment.PaymentFundConfirmationService;
 import com.talentcard.server.business.portal.ProductPriceCalculator;
 import com.talentcard.server.common.BusinessException;
 import com.talentcard.server.common.ErrorCode;
@@ -34,12 +35,14 @@
 	private final JdbcTemplate jdbcTemplate;
 	private final ManualConsumptionService manualConsumptionService;
 	private final OrderFundBoundaryService orderFundBoundary;
+	private final PaymentFundConfirmationService fundConfirmation;
 
 	public MerchantWorkService(JdbcTemplate jdbcTemplate, ManualConsumptionService manualConsumptionService,
-			OrderFundBoundaryService orderFundBoundary) {
+			OrderFundBoundaryService orderFundBoundary, PaymentFundConfirmationService fundConfirmation) {
 		this.jdbcTemplate = jdbcTemplate;
 		this.manualConsumptionService = manualConsumptionService;
 		this.orderFundBoundary = orderFundBoundary;
+		this.fundConfirmation = fundConfirmation;
 	}
 
 	@Transactional(readOnly = true)
@@ -202,6 +205,9 @@
 		if (updated != 1) {
 			throw new BusinessException(ErrorCode.CONFLICT, "订单已核销");
 		}
+		// 核销通过后把钱放给商户:延迟入账的支付此前停在通道「待确认」,确认成功商户才真正拿到钱。
+		// 确认失败不会回滚核销(用户的服务已经核销掉了),资金保持待确认并留下记录供重试。
+		fundConfirmation.confirmForOrder(locked.orderId());
 		return order(orderNo, principal.merchantId(), principal.storeId());
 	}
 

--
Gitblit v1.7.1