From 81f4b6bb09fd7327f138ce34c3ad3a1e6b4de856 Mon Sep 17 00:00:00 2001
From: yeg <1347747024@qq.com>
Date: 星期一, 14 九月 2026 16:32:20 +0800
Subject: [PATCH] chore(scratch): 新增斗拱子商户档案查询探针
---
.scratch/automatic-withdrawal/tools/MerchantInfoProbe.java | 77 ++++++++++++++++++++++++++++++++++++++
1 files changed, 77 insertions(+), 0 deletions(-)
diff --git a/.scratch/automatic-withdrawal/tools/MerchantInfoProbe.java b/.scratch/automatic-withdrawal/tools/MerchantInfoProbe.java
new file mode 100644
index 0000000..80f69bc
--- /dev/null
+++ b/.scratch/automatic-withdrawal/tools/MerchantInfoProbe.java
@@ -0,0 +1,77 @@
+import com.alibaba.fastjson.JSON;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
+import com.huifu.bspay.sdk.opps.client.BasePayClient;
+import com.huifu.bspay.sdk.opps.core.BasePay;
+import com.huifu.bspay.sdk.opps.core.config.MerConfig;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 读取斗拱子商户的完整档案(只读),用来确认它被登记成什么行业。
+ *
+ * <p>用法:java -cp "target/classes;<deps>;<tools>" MerchantInfoProbe <huifu_id>
+ */
+public class MerchantInfoProbe {
+
+ public static void main(String[] args) throws Exception {
+ System.setOut(new java.io.PrintStream(new java.io.FileOutputStream(java.io.FileDescriptor.out), true,
+ java.nio.charset.StandardCharsets.UTF_8));
+ String huifuId = args.length > 0 ? args[0] : "6666000226048687";
+ JsonNode huifu = new YAMLMapper().readTree(Files.newInputStream(
+ Path.of("src", "main", "resources", "application.yml")))
+ .path("app").path("payment").path("huifu");
+
+ BasePay.debug = false;
+ BasePay.prodMode = "prod".equalsIgnoreCase(text(huifu, "environment", "prod")) ? BasePay.MODE_PROD : BasePay.MODE_TEST;
+ MerConfig config = new MerConfig();
+ config.setSysId(text(huifu, "system-id", "").trim());
+ config.setProductId(text(huifu, "product-id", "").trim());
+ config.setRsaPrivateKey(text(huifu, "private-key", "").trim());
+ config.setRsaPublicKey(text(huifu, "platform-public-key", "").trim());
+ BasePay.initWithMerConfig(config);
+
+ Map<String, Object> request = new LinkedHashMap<>();
+ request.put("req_seq_id", "MI" + System.currentTimeMillis());
+ request.put("req_date", LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE));
+ request.put("huifu_id", huifuId.trim());
+
+ Map<String, Object> response = BasePayClient.request(request, "v2.merchant.basicdata.query", false);
+ Object raw = response.get("data");
+ Map<String, Object> data = raw instanceof Map<?, ?> map ? (Map<String, Object>) map
+ : raw instanceof String json && !json.isBlank() ? JSON.parseObject(json, Map.class) : response;
+
+ System.out.println("================ 子商户档案 " + huifuId + " ================");
+ for (Map.Entry<String, Object> entry : data.entrySet()) {
+ String key = entry.getKey();
+ Object value = entry.getValue();
+ if (value instanceof List<?> || value instanceof Map<?, ?>) continue;
+ String text = String.valueOf(value);
+ System.out.printf(" %-26s = %s%n", key, text.length() > 120 ? text.substring(0, 120) + "..." : text);
+ }
+ System.out.println();
+ System.out.println("== 行业相关字段 ==");
+ for (String key : List.of("mcc", "ent_type", "busi_type", "scene_type", "business_scope", "industry",
+ "reg_name", "short_name", "receipt_name", "mer_stat", "out_settle_flag")) {
+ if (data.containsKey(key)) System.out.printf(" %-26s = %s%n", key, data.get(key));
+ }
+ System.out.println("=========================================================");
+ }
+
+ private static String text(JsonNode node, String field, String fallback) {
+ String value = node.path(field).asText("");
+ if (value.isBlank()) return fallback;
+ if (value.startsWith("${") && value.endsWith("}")) {
+ String inner = value.substring(2, value.length() - 1);
+ int separator = inner.indexOf(':');
+ value = separator >= 0 ? inner.substring(separator + 1) : "";
+ }
+ return value.isBlank() ? fallback : value;
+ }
+}
--
Gitblit v1.7.1