From c4baf2f1909ee78e610f371aad86df917839be5c Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期四, 17 九月 2026 18:13:53 +0800
Subject: [PATCH] feat(payment): 接通关单查询,作废中的凭证不再交回客户端
---
talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuMiniProgramPaymentGateway.java | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuMiniProgramPaymentGateway.java b/talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuMiniProgramPaymentGateway.java
index 17cc0a0..0cf4325 100644
--- a/talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuMiniProgramPaymentGateway.java
+++ b/talent-card-server/src/main/java/com/talentcard/server/business/payment/huifu/HuifuMiniProgramPaymentGateway.java
@@ -12,6 +12,7 @@
import com.huifu.bspay.sdk.opps.core.BasePay;
import com.huifu.bspay.sdk.opps.core.config.MerConfig;
import com.huifu.bspay.sdk.opps.core.request.V2TradePaymentScanpayCloseRequest;
+import com.huifu.bspay.sdk.opps.core.request.V2TradePaymentScanpayClosequeryRequest;
import com.huifu.bspay.sdk.opps.core.request.V3TradePaymentJspayRequest;
import com.huifu.bspay.sdk.opps.core.request.V3TradePaymentScanpayQueryRequest;
import com.talentcard.server.common.BusinessException;
@@ -133,6 +134,37 @@
}
}
+ /**
+ * 查一次关单的结论。
+ *
+ * <p>关单回执答「处理中」时,结论只能靠这条查询(汇付文档:关单处理中应继续调用关单查询确认结果)。
+ * 没有它,我们只能在后台扫描里反复发起关单——用户在前台等着,而那本可以是几秒。
+ */
+ public Map<String, Object> closeQueryMiniProgramPayment(HuifuPaymentCloseQueryCommand command) {
+ ensureConfigured();
+ ensureCollectingMerchant(command.huifuId());
+ initializeSdk();
+ V2TradePaymentScanpayClosequeryRequest request = new V2TradePaymentScanpayClosequeryRequest();
+ request.setReqDate(REQUEST_DATE.format(LocalDateTime.now()));
+ request.setReqSeqId(command.requestNo());
+ request.setHuifuId(command.huifuId().trim());
+ request.setOrgReqDate(command.requestDate());
+ Map<String, Object> extendInfo = new LinkedHashMap<>();
+ extendInfo.put("org_req_seq_id", command.paymentNo());
+ if (!blank(command.providerTransactionNo())) extendInfo.put("org_hf_seq_id", command.providerTransactionNo());
+ request.setExtendInfo(extendInfo);
+ try {
+ Map<String, Object> response = BasePayClient.request(request, false);
+ log.info("Huifu mini-program payment close-query response: paymentNo={}, response={}",
+ command.paymentNo(), logJson(response));
+ return response;
+ } catch (Exception exception) {
+ log.warn("Huifu mini-program payment close-query failed: paymentNo={}, type={}, message={}",
+ command.paymentNo(), exception.getClass().getSimpleName(), safeMessage(exception.getMessage()));
+ throw new HuifuPaymentGatewayException("汇付关单查询失败,请稍后重试", isOutcomeUnknown(exception), exception);
+ }
+ }
+
private void ensureConfigured() {
if (!properties.isEnabled()) throw new BusinessException(ErrorCode.CONFLICT, "汇付支付尚未启用");
if (blank(properties.getSystemId()) || blank(properties.getProductId()) || blank(properties.getMerchantId())
--
Gitblit v1.7.1