feat(shipping-notice): 收敛订单处理状态与履约门禁

This commit is contained in:
hugo committed 2026-09-07 09:42:12 +08:00
1 parent bffcd55b40
commit 70dd0051b8
153 files changed
+10916 -4296

No files matched your search

@@ -97,12 +97,21 @@ def _task_failure_descriptor(task: ShippingNotice | None) -> dict[str, str] | No
if not task_no:
return None
review_status = _clean_text(getattr(task, "review_status", None)).lower()
match_status = _clean_text(getattr(task, "match_status", None)).lower()
pending_reason = _clean_text(getattr(task, "pending_human_reason", None)).lower()
upload_status = _clean_text(getattr(task, "upload_status", None)).lower()
owner = task
if isinstance(task, ShippingNotice) and getattr(task, 'order_task_id', None):
from app import db
from app.models import ShippingOrderTask
owner = db.session.get(ShippingOrderTask, int(task.order_task_id)) or task
review_status = _clean_text(getattr(owner, "review_status", None)).lower()
from app.services.shipping_notice.line_inventory_match_projection import aggregate_match_status_for_task
match_task_id = getattr(task, 'order_task_id', None) or getattr(task, 'id', None)
match_status = _clean_text(aggregate_match_status_for_task(match_task_id)).lower()
pending_reason = _clean_text(getattr(owner, "pending_human_reason", None)).lower()
from app.services.shipping_notice.upload_attempt_service import latest_upload_attempt
upload_attempt = latest_upload_attempt(task) if isinstance(task, ShippingNotice) else None
upload_status = _clean_text(getattr(upload_attempt, "status", None)).lower()
if match_status == "shortage" or pending_reason == "shortage" or getattr(task, "shortage_json", None):
if match_status == "shortage" or pending_reason == "shortage":
return {
"reason": "shortage",
"label": "异常:库存不足",
@@ -120,7 +129,7 @@ def _task_failure_descriptor(task: ShippingNotice | None) -> dict[str, str] | No
"label": "异常:上传失败",
"summary": f"{task_no} 上传失败",
}
if _clean_text(getattr(task, "error_message", None)):
if _clean_text(getattr(owner, "error_message", None)):
return {
"reason": "error",
"label": "异常:处理失败",