fix: 天河链测试环境联调修正(手工 multipart + GET body)与 seed 短码格式

- upload 改手工构造 multipart(userDto 无 filename 带 application/json),修复 undici Blob 强加 filename 导致的 500
- confirm 接口 9 改用 node:https 发送带 body 的 GET,appKey 移出 URL query 避免泄漏
- seed 追溯码短码改为 12 位纯数字,与 TRACE_CODE_PATTERN 一致,修复 C 端公开溯源判 INVALID
- 单测适配:https 模块 mock、手工 multipart 断言,27 测试全过
- 问题清单更新 T1-T8 联调结论,新增 F1(已修)/F2(待查)
This commit is contained in:
Nixevol
2026-07-09 19:34:02 +08:00
parent fa4215bd52
commit e037e460e2
4 changed files with 176 additions and 71 deletions
+10 -1
View File
@@ -12,6 +12,15 @@ const storageDir = resolve(process.env.STORAGE_LOCAL_DIR || './storage');
const ALPHABET = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
const shortId = customAlphabet(ALPHABET, 10);
const codeId = customAlphabet(ALPHABET, 18);
// 公开短码须为 12 位纯数字(与 TRACE_CODE_PATTERN=/^\d{12}$/ 一致),否则 C 端公开溯源会判 INVALID
const numericId = customAlphabet('0123456789', 12);
function uniqueShortCode(used: Set<string>): string {
let code = numericId();
while (used.has(code)) code = numericId();
used.add(code);
return code;
}
const usedShortCodes = new Set<string>();
const watermarkText = process.env.WATERMARK_TEXT || '仅供溯源核验使用';
const DEFAULT_TEMPLATE_FIELDS = [
{ fieldKey: 'craft', label: '工艺', type: 'TEXT', required: true, sortOrder: 0 },
@@ -208,7 +217,7 @@ async function ensureSampleData(): Promise<void> {
const artworkActive = artworkSeq < 2; // 前两款带激活码与查询记录
for (let k = 0; k < CODES_PER_ARTWORK; k++) {
const shortCode = shortId();
const shortCode = uniqueShortCode(usedShortCodes);
const isActive = artworkActive && k < 2; // 该款前两套已激活
const code = await prisma.traceCode.create({
data: {