feat(fulfillment): 增加 Clean Cutover,历史任务隔离到人工入口

- 新增 flow_version,存量任务回填 1,Cutover 后新任务写 2
- 迁移设置 clean_flow_started_at,按订单支付/创建时间判定
- 自动选号只处理 clean 任务
- 工作台新增历史任务 Tab,历史列表不受订单起算时间限制
- 历史任务不参与自动重试和预售台账同步
- 补充流程边界测试和计划文档
This commit is contained in:
yml
2026-11-24 23:11:13 +08:00
parent 7dec3c4c48
commit aafac6e536
15 changed files with 294 additions and 7 deletions
@@ -79,6 +79,7 @@ def _count_cache_key(
status: str,
queue_bucket: str,
sale_mode: str,
flow_version: int | None,
keyword: str,
) -> tuple[Any, ...]:
return (
@@ -86,6 +87,7 @@ def _count_cache_key(
status,
queue_bucket,
sale_mode,
flow_version,
keyword.strip(),
)
@@ -209,13 +211,18 @@ def list_tasks(
status: str = "",
queue_bucket: str = "",
sale_mode: str = "",
flow_version: int | None = None,
keyword: str = "",
page: int = 1,
page_size: int = 20,
) -> dict[str, Any]:
cutoff = _order_match_started_at(db)
query = db.query(PlatformFulfillmentTask)
query = _apply_order_match_cutoff(query, cutoff)
if flow_version is not None:
query = query.filter(PlatformFulfillmentTask.flow_version == flow_version)
# 历史任务不受订单起算时间限制,否则很多旧单在工作台里永远看不到。
if flow_version != 1:
query = _apply_order_match_cutoff(query, cutoff)
# 待映射队列本身就是要展示“还没有映射”的任务,不能再套映射存在条件。
if queue_bucket != "pending_mapping":
query = query.filter(
@@ -310,6 +317,7 @@ def list_tasks(
status=status,
queue_bucket=queue_bucket,
sale_mode=sale_mode,
flow_version=flow_version,
keyword=keyword,
),
)
@@ -426,6 +434,7 @@ def _task_out(
"goodsName": goods_name,
"requiredPoints": task.required_points,
"saleMode": sale_mode,
"flowVersion": int(task.flow_version or 1),
"campaignKey": task.campaign_key,
"campaignName": task.campaign_name,
"offerAvailableFrom": task.offer_available_from,