refactor(shipping-notice): 收紧通知单与导出上传事实边界
This commit is contained in:
1 parent
b5d894a923
commit
8ec028e6a3
12 files changed
+312
-318
No files matched your search
@@ -3,8 +3,10 @@ services/shipping_notice/lifecycle_projection.py
|
||||
|
||||
用途:为批次进度、任务详情与订单生命周期工作台裁决同一份五阶段业务生命周期。
|
||||
依赖:process_gate_contract 的阻断原因归属;调用方提供正式 Gate、Case/Candidate 或已核验成功事实。
|
||||
逻辑:正式 Process Gate 优先,其次是可解释阻断原因;无正式事实时保持未分类。
|
||||
本模块只做只读业务投影,不授权任何写操作;阶段入口与实际动作权限必须分开。
|
||||
逻辑:已核验上传成功 → 已持久化处理阶段 → 正式 Process Gate → 可解释阻断原因;
|
||||
[B''] 处理阶段是阶段唯一权威,正式 Gate 不再覆盖/升降阶段,仅在处理阶段缺失时
|
||||
兜底;无正式事实时保持未分类。本模块只做只读业务投影,不授权任何写操作;
|
||||
阶段入口与实际动作权限必须分开。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -36,6 +38,9 @@ LIFECYCLE_STAGE_BY_GATE: dict[str, str] = {
|
||||
'duplicate_detection': 'order_review',
|
||||
'field_conflict_resolution': 'order_review',
|
||||
'order_freeze_readiness': 'order_review',
|
||||
# 建单前已存在当前有效 Candidate 的未确认 Review Case 仍属「订单复核」工作面:
|
||||
# 用户在复核并决定标记非订单/修订草稿之前,订单尚未正式创建。
|
||||
'order_review_build': 'order_review',
|
||||
'task_creation': 'order_review',
|
||||
'inventory_source_routing': 'fulfillment_prep',
|
||||
'inventory_preparation': 'fulfillment_prep',
|
||||
@@ -49,8 +54,8 @@ LIFECYCLE_STAGE_BY_GATE: dict[str, str] = {
|
||||
}
|
||||
|
||||
# 已持久化的 Processing 技术阶段到五阶段业务工作面的唯一映射。它只用于
|
||||
# 读模型展示,不推进订单、不创建任务,也不授予任何动作。正式 Gate 仍在
|
||||
# 技术阶段缺失时提供兜底,避免历史数据被无条件覆盖。
|
||||
# 读模型展示,不推进订单、不创建任务,也不授予任何动作。[B''] 它是阶段的唯一
|
||||
# 权威;正式 Gate 仅在技术阶段缺失时提供兜底,不能覆盖有效处理阶段。
|
||||
LIFECYCLE_STAGE_BY_PROCESSING_STAGE: dict[str, str] = {
|
||||
'upload_received': 'intake_parse',
|
||||
'email_parsing': 'intake_parse',
|
||||
@@ -60,7 +65,7 @@ LIFECYCLE_STAGE_BY_PROCESSING_STAGE: dict[str, str] = {
|
||||
'waiting_review': 'order_review',
|
||||
'customer_resolving': 'order_review',
|
||||
'duplicate_checking': 'order_review',
|
||||
'inventory_source_resolving': 'order_review',
|
||||
'inventory_source_resolving': 'fulfillment_prep',
|
||||
'order_creating': 'fulfillment_prep',
|
||||
'inventory_fetching': 'fulfillment_prep',
|
||||
'inventory_preparation': 'fulfillment_prep',
|
||||
@@ -114,11 +119,12 @@ def project_lifecycle(
|
||||
verified_upload_success: bool = False,
|
||||
processing_stage: str | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""按成功事实 → Gate → 已持久化阶段 → 阻断归属的固定优先级裁决生命周期。
|
||||
"""按成功事实 → 已持久化阶段 → 正式 Gate → 阻断归属的固定优先级裁决生命周期。
|
||||
|
||||
``processing_stage`` 是订单处理流程已写入的事实,仅映射展示工作面;它不能
|
||||
授权动作或推进流程。``authority`` 仅用于诊断/迁移观测;前端不得据此再计算
|
||||
阶段或放开按钮。
|
||||
[B''] 阶段唯一权威:只要 ``processing_stage``(OT.stage / Run.processing_stage)是合法
|
||||
15 阶成员,就直接映射五阶段,正式 Gate 不能覆盖或升降它。``gate_code`` 只在处理
|
||||
阶段缺失时兜底(如任务详情无 OT.stage 上下文),且仅用于「订单检查」面板诊断;
|
||||
它不再能改变阶段。``authority`` 仅用于诊断/迁移观测;前端不得据此再计算阶段或放开按钮。
|
||||
"""
|
||||
gate = current_gate if isinstance(current_gate, dict) else {}
|
||||
gate_code = str(gate.get('gate_code') or gate.get('code') or '').strip().lower()
|
||||
@@ -127,14 +133,16 @@ def project_lifecycle(
|
||||
if verified_upload_success:
|
||||
lifecycle_stage = 'upload_complete'
|
||||
authority = 'verified_upload_success'
|
||||
elif gate_code in LIFECYCLE_STAGE_BY_GATE:
|
||||
lifecycle_stage = LIFECYCLE_STAGE_BY_GATE[gate_code]
|
||||
authority = 'process_gate'
|
||||
# [B''] 处理阶段是阶段唯一权威。合法 15 阶直接映射五阶段;Gate 不再覆盖它。
|
||||
elif str(processing_stage or '').strip().lower() in LIFECYCLE_STAGE_BY_PROCESSING_STAGE:
|
||||
lifecycle_stage = LIFECYCLE_STAGE_BY_PROCESSING_STAGE[
|
||||
str(processing_stage or '').strip().lower()
|
||||
]
|
||||
authority = 'processing_stage'
|
||||
# [B''] 正式 Gate 仅在处理阶段缺失时兜底,用于「订单检查」面板,不改变阶段。
|
||||
elif gate_code in LIFECYCLE_STAGE_BY_GATE:
|
||||
lifecycle_stage = LIFECYCLE_STAGE_BY_GATE[gate_code]
|
||||
authority = 'process_gate'
|
||||
else:
|
||||
reason = blocking_reason if isinstance(blocking_reason, dict) else {}
|
||||
reason_code = str(reason.get('code') or reason.get('blocking_reason_code') or '').strip()
|
||||
|
||||
Reference in new issue
Block a user