import java.nio.charset.StandardCharsets;
|
import java.nio.file.Files;
|
import java.nio.file.Path;
|
import java.sql.Connection;
|
import java.sql.DriverManager;
|
import java.sql.ResultSet;
|
import java.sql.ResultSetMetaData;
|
import java.sql.SQLException;
|
import java.sql.Statement;
|
|
/** 只读探针二:看订单的过期时间与商户微信阶段快照,判断 90000000 那笔是不是「过期时间快到了」。 */
|
public class OrderExpiryProbe {
|
|
public static void main(String[] args) throws Exception {
|
Path out = Path.of(".scratch/payment-409-probe/out2.txt");
|
StringBuilder text = new StringBuilder();
|
String url = "jdbc:mysql://127.0.0.1:8134/talent_card2?useUnicode=true&characterEncoding=utf8"
|
+ "&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&useSSL=false";
|
try (Connection connection = DriverManager.getConnection(url, "root", "123456")) {
|
dump(text, connection, "涉事订单",
|
"select order_no, merchant_id, store_id, order_type, pay_amount, order_status, verify_status, "
|
+ "created_at, expires_at, collect_huifu_id from benefit_order "
|
+ "where order_no in ('P202609241252066893','P202609241307109556')");
|
dump(text, connection, "这些支付尝试的时间线(含请求日期与创建时间)",
|
"select payment_no, order_no, amount, status, created_at, closed_at, provider_response_code, provider_response_message "
|
+ "from payment_transaction where created_at >= '2026-09-24 12:00:00' order by id");
|
dump(text, connection, "商户与门店",
|
"select m.id, m.merchant_name, m.merchant_type, m.collect_huifu_id, s.store_name "
|
+ "from merchant m left join merchant_store s on s.merchant_id = m.id "
|
+ "where m.collect_huifu_id = '6666000241804122' or m.id in "
|
+ "(select merchant_id from benefit_order where order_no in ('P202609241252066893','P202609241307109556'))");
|
dump(text, connection, "商户进件阶段快照(微信/延迟/结算)",
|
"select application_id, sync_owner, last_synced_at, sync_error from merchant_onboarding_progress");
|
}
|
System.out.println(text);
|
Files.writeString(out, text.toString(), StandardCharsets.UTF_8);
|
System.out.println("written to " + out.toAbsolutePath());
|
}
|
|
private static void dump(StringBuilder text, Connection connection, String title, String sql) {
|
text.append("\n--- ").append(title).append(" ---\n");
|
try (Statement statement = connection.createStatement(); ResultSet rs = statement.executeQuery(sql)) {
|
ResultSetMetaData meta = rs.getMetaData();
|
int columns = meta.getColumnCount();
|
int rows = 0;
|
while (rs.next()) {
|
rows++;
|
for (int i = 1; i <= columns; i++) {
|
text.append(meta.getColumnLabel(i)).append('=').append(value(rs.getObject(i))).append(" ");
|
}
|
text.append('\n');
|
}
|
if (rows == 0) text.append("(空)\n");
|
} catch (SQLException exception) {
|
text.append("查询失败:").append(exception.getMessage()).append('\n');
|
}
|
}
|
|
private static String value(Object raw) {
|
if (raw == null) return "NULL";
|
String text = String.valueOf(raw).trim();
|
return text.isEmpty() ? "\"\"" : text;
|
}
|
}
|