fix(pdd): 停止旧单刷匹配日志,并修复订单列表商品显示为 0

同步时已有工单/匹配结果未变不再写日志;列表按 Number(order_id) 挂 items,并补齐 PDD goods_name 回退与嵌套商品解析。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
yml2213
2026-09-15 12:05:02 +08:00
co-authored by Cursor
parent 2e197f93e0
commit 8e996e01fb
7 changed files with 222 additions and 43 deletions
@@ -231,6 +231,27 @@ export async function createWorkProductMatchLog(input: {
return result.rows[0] || null
}
/** 同一订单项最近一条匹配日志(用于同步去重,避免旧单反复写入)。 */
export async function getLatestWorkProductMatchLogByOrderItemId(
orderItemId: number | string,
): Promise<WorkProductMatchLogRow | null> {
const id = Number(orderItemId)
if (!Number.isInteger(id) || id <= 0) {
return null
}
const result = await query<WorkProductMatchLogRow>(
`
SELECT *
FROM work_product_match_logs
WHERE order_item_id = $1
ORDER BY id DESC
LIMIT 1
`,
[id],
)
return result.rows[0] || null
}
/** 匹配日志分页查询:表本身全量保留,可按结果状态、关键词(商品/SKU/店铺)与日期范围筛选。 */
export async function listWorkProductMatchLogs({
page = 1,