fix(pdd): 匹配诊断对齐 out_sku_sn,并加速拼多多订单号搜索
匹配测试/结构化规则补读商家编码,诊断日志标出缺失字段;订单/任务/工单关键词支持带连字符的 PDD order_sn 走索引快路径。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import test from 'node:test'
|
||||
|
||||
import { isPlatformOrderIdLookupKeyword } from './platform-order-id.js'
|
||||
|
||||
test('识别纯数字平台订单号', () => {
|
||||
assert.equal(isPlatformOrderIdLookupKeyword('20247230034021572'), true)
|
||||
assert.equal(isPlatformOrderIdLookupKeyword('123456'), true)
|
||||
assert.equal(isPlatformOrderIdLookupKeyword('12345'), false)
|
||||
})
|
||||
|
||||
test('识别拼多多带连字符的 order_sn', () => {
|
||||
assert.equal(isPlatformOrderIdLookupKeyword('260915-091435834962130'), true)
|
||||
assert.equal(isPlatformOrderIdLookupKeyword('260912-123456789012345'), true)
|
||||
})
|
||||
|
||||
test('拒绝普通关键词', () => {
|
||||
assert.equal(isPlatformOrderIdLookupKeyword('皮肤店'), false)
|
||||
assert.equal(isPlatformOrderIdLookupKeyword('安卓怒嚎3钻'), false)
|
||||
assert.equal(isPlatformOrderIdLookupKeyword('DT881aa66294cc'), false)
|
||||
assert.equal(isPlatformOrderIdLookupKeyword(''), false)
|
||||
})
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Detect platform order IDs that should use indexed equality/prefix lookup.
|
||||
* Covers pure numeric IDs (快手等) and PDD style `digits-digits` (e.g. 260915-091435834962130).
|
||||
*/
|
||||
export function isPlatformOrderIdLookupKeyword(value: unknown): boolean {
|
||||
const trimmed = String(value || '').trim()
|
||||
return /^\d{6,}(-\d{6,})?$/.test(trimmed)
|
||||
}
|
||||
Reference in New Issue
Block a user