From c46ef64cd3cc90da78bc7946a9a0666d035a680e Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期四, 17 九月 2026 17:23:41 +0800
Subject: [PATCH] fix(payment): 取消意图落库自动落地,对账间隔回到设计的一分钟
---
talent-card-server/src/test/java/com/talentcard/server/business/payment/PaymentSchedulingConfigurationTests.java | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/talent-card-server/src/test/java/com/talentcard/server/business/payment/PaymentSchedulingConfigurationTests.java b/talent-card-server/src/test/java/com/talentcard/server/business/payment/PaymentSchedulingConfigurationTests.java
index 4762c1c..7d5ab2e 100644
--- a/talent-card-server/src/test/java/com/talentcard/server/business/payment/PaymentSchedulingConfigurationTests.java
+++ b/talent-card-server/src/test/java/com/talentcard/server/business/payment/PaymentSchedulingConfigurationTests.java
@@ -4,6 +4,8 @@
import java.lang.reflect.Field;
import java.nio.charset.StandardCharsets;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import com.talentcard.server.business.payment.huifu.HuifuPaymentProperties;
import org.junit.jupiter.api.Test;
@@ -28,16 +30,14 @@
String yml = configurationFile();
assertThat(yml)
.as("对账间隔要写进配置,不能只靠注解默认值")
- .contains("fixed-delay-ms: ${HUIFU_RECONCILIATION_FIXED_DELAY_MS:300000}");
+ .contains("fixed-delay-ms: ${HUIFU_RECONCILIATION_FIXED_DELAY_MS:")
+ .contains("enabled: ${HUIFU_RECONCILIATION_ENABLED:true}");
assertThat(yml)
.as("交易确认补偿的开关要真的存在且可读")
.contains("enabled: ${FUND_CONFIRMATION_RETRY_ENABLED:true}");
assertThat(yml)
.as("悬账自动退款的开关要真的存在且可读")
.contains("enabled: ${STRANDED_REFUND_ENABLED:true}");
- assertThat(yml)
- .as("定时对账的开关默认与代码一致(删掉配置行不会让兜底静默消失)")
- .contains("enabled: ${HUIFU_RECONCILIATION_ENABLED:true}");
}
@Test
@@ -47,7 +47,12 @@
.isEqualTo("${app.payment.huifu.reconciliation.enabled:true}");
assertThat(PaymentReconciliationScheduler.class.getMethod("reconcilePendingTransactions")
.getAnnotation(Scheduled.class).fixedDelayString())
- .isEqualTo("${app.payment.huifu.reconciliation.fixed-delay-ms:300000}");
+ .as("注解默认值必须与配置里的默认值一致:两边不一致时,删掉配置行就会悄悄改变行为")
+ .isEqualTo("${app.payment.huifu.reconciliation.fixed-delay-ms:" + configuredReconciliationDelay() + "}");
+ assertThat(configuredReconciliationDelay())
+ .as("扫描间隔同时是关单补偿的重试间隔(快车道的资格窗口是 1 分钟,见 CLOSE_RETRY_MINUTES):"
+ + "比它长,设计里那句「关单每分钟重试一次、最多三次」就不成立,用户看到的是点了取消一直卡着")
+ .isEqualTo("60000");
}
@Test
@@ -80,6 +85,13 @@
return field.getAnnotation(Value.class).value();
}
+ /** 配置里写的对账间隔默认值(毫秒),供「两处默认值必须一致」的断言使用。 */
+ private String configuredReconciliationDelay() throws Exception {
+ Matcher matcher = Pattern.compile("HUIFU_RECONCILIATION_FIXED_DELAY_MS:(\\d+)").matcher(configurationFile());
+ assertThat(matcher.find()).as("配置里要给出对账间隔的默认值").isTrue();
+ return matcher.group(1);
+ }
+
private String configurationFile() throws Exception {
try (var stream = getClass().getResourceAsStream("/application.yml")) {
assertThat(stream).as("application.yml 必须在类路径上").isNotNull();
--
Gitblit v1.7.1