插件
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
// 根因验证:后端 customers.customer_id 是 VARCHAR(64)(spec §6.1),
|
||||
// 而插件对无真 customerId 的询盘用 sec_ + secTradeId 兜底(75 字符)。
|
||||
// 本脚本推两条测试数据对比:超长 sec_ vs 短 id,看后端 ingest 的实际反应。
|
||||
// 用法: node scripts/test-cid-length.mjs
|
||||
import { buildIngestPayload } from '../push/payload.js';
|
||||
|
||||
const SERVER = process.env.SERVER || 'http://219.157.255.213:23010';
|
||||
const TOKEN = process.env.TOKEN || '688cbb4b6e880b340b2360559c4ad29d01a39ccbb3c31c4d';
|
||||
|
||||
async function push(label, customerId) {
|
||||
const record = {
|
||||
inquiryId: `TEST-CID-${label}`,
|
||||
customerId,
|
||||
detailBuyerName: 'Test Buyer', detailCountry: 'US', company: 'Test Co',
|
||||
createTimeFromApi: '2026-07-20T00:00:00Z', updateTimeFromApi: '2026-07-20T00:00:00Z',
|
||||
behavior: { productViews: '1' },
|
||||
};
|
||||
const payload = buildIngestPayload(record, []);
|
||||
const res = await fetch(`${SERVER}/api/ingest`, {
|
||||
method: 'POST',
|
||||
headers: { Authorization: `Bearer ${TOKEN}`, 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
let body = '';
|
||||
try { body = await res.text(); } catch (e) { body = '(no body)'; }
|
||||
console.log(`[${label}] customerId(len=${customerId.length}): status=${res.status}`);
|
||||
console.log(` body=${body.slice(0, 400)}`);
|
||||
console.log(` payload.customer.customerId = ${JSON.stringify(payload.customer && payload.customer.customerId)}`);
|
||||
}
|
||||
|
||||
const longCid = 'sec_MC1IDX1yqSSuFKld-CG7npDfPBic6Iv1S_ZJecxnw8b7kTejq_GNIDRuGTmXE-sjnZMUpze';
|
||||
console.log('=== longCid length:', longCid.length, '===');
|
||||
await push('LONG75', longCid);
|
||||
await push('SHORT5', '12345');
|
||||
console.log('\n说明:若 LONG75 失败(4xx)而 SHORT5 成功(200) → 证实后端因长度拒绝 sec_ customerId');
|
||||
Reference in New Issue
Block a user