fix(compare): 「已下单」从店级改按 trace_id 精确对齐 #224

Merged
guke merged 2 commits from fix/compare-ordered-attribution-by-trace-id into main 2026-08-07 18:16:57 +08:00

2 Commits

Author SHA1 Message Date
guke 89b2d5ed0c test(compare): 锁定「订单无 trace_id → 不进已下单」的无回退契约
老客户端/历史订单不带 trace_id,即使店名相同也不该标已下单。补这条回归测试,
防止将来有人把店名回退悄悄加回来。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-07 13:51:19 +08:00
guke d699c7c89c fix(compare): 「已下单」从店级改按 trace_id 精确对齐
下单上报带上本次比价的 trace_id 落 savings_record.trace_id,「已下单」筛选/打标改为
按 trace_id 精确对齐 comparison_record.trace_id —— 同店多次比价只标真正下单那条,失败/
未下单记录不再混入。没有 trace_id 的订单(历史/老客户端)不进「已下单」,不做回退/回填。

- savings_record 加 trace_id 列 + 索引 + Alembic 迁移
- OrderReportRequest 加 trace_id;create_from_report 落库
- comparison.list_records 过滤/打标 + helpers 改按 trace_id(删店名匹配)
- admin 列表/详情/看板下单数同口径改 trace_id
- 迁移既有测试到新语义 + 新增 test_records_ordered_by_trace_id

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-07 11:30:07 +08:00