fix(pdd): 匹配诊断对齐 out_sku_sn,并加速拼多多订单号搜索

匹配测试/结构化规则补读商家编码,诊断日志标出缺失字段;订单/任务/工单关键词支持带连字符的 PDD order_sn 走索引快路径。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yml2213
2026-09-15 10:45:53 +08:00
co-authored by Cursor
parent 4a3b4ec14d
commit 5cbb977b96
11 changed files with 237 additions and 43 deletions
+14 -4
View File
@@ -7,6 +7,7 @@ import type {
OrderUpdateInput,
} from '../types/repository/inputs.js'
import type { OrderListQueryResult, OrderListRow, OrderRow } from '../types/repository/rows.js'
import { isPlatformOrderIdLookupKeyword } from '../utils/platform-order-id.js'
export type OrderQueryExecutor = <T extends QueryResultRow = QueryResultRow>(
text: string,
@@ -251,9 +252,9 @@ export async function listOrdersWithExecutor(
if (keyword) {
const trimmedKeyword = String(keyword).trim()
const isPureOrderNo = /^\d{6,}$/.test(trimmedKeyword)
const isOrderNoLookup = isPlatformOrderIdLookupKeyword(trimmedKeyword)
if (isPureOrderNo) {
if (isOrderNoLookup) {
params.push(trimmedKeyword)
const paramIndex = `$${params.length}`
filters.push(
@@ -299,8 +300,17 @@ export async function listOrdersWithExecutor(
}
if (platformOrderId) {
params.push(`%${platformOrderId}%`)
filters.push(`o.platform_order_id ILIKE $${params.length}`)
const trimmedPlatformOrderId = String(platformOrderId).trim()
if (isPlatformOrderIdLookupKeyword(trimmedPlatformOrderId)) {
params.push(trimmedPlatformOrderId)
const paramIndex = `$${params.length}`
filters.push(
`(o.platform_order_id = ${paramIndex} OR o.platform_order_id LIKE ${paramIndex} || '%')`,
)
} else {
params.push(`%${trimmedPlatformOrderId}%`)
filters.push(`o.platform_order_id ILIKE $${params.length}`)
}
}
if (payStatus) {