feat(shipping-notice): 新增订单行与字段冲突管理功能,支持字段冲突查询与解决
This commit is contained in:
1 parent
4fbaed2b4c
commit
9da0481fc3
74 files changed
+4861
-375
No files matched your search
@@ -0,0 +1,43 @@
|
||||
"""
|
||||
backend/app/services/shipping_notice/reservation_gate.py
|
||||
|
||||
用途:为库存、RPA、匹配、导出和上传入口提供统一的订单侧 Reservation ID 门禁判断。
|
||||
依赖:reservation_id.is_valid_reservation_id。
|
||||
逻辑:各推进服务在产生外部或下游副作用前调用本模块,确保任何直接入口都不能绕过订单字段门禁。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from app.services.shipping_notice.reservation_id import is_valid_reservation_id
|
||||
|
||||
|
||||
def reservation_gate_issues(lines: list[Any] | None) -> list[dict[str, Any]]:
|
||||
"""
|
||||
返回缺失或格式非法的订单行 Reservation ID 问题。
|
||||
|
||||
Args:
|
||||
lines: ShippingTask 订单行数组。
|
||||
|
||||
Returns:
|
||||
含行号、SKU、原值和原因的 blocking issue;全部合法时返回空列表。
|
||||
"""
|
||||
issues: list[dict[str, Any]] = []
|
||||
for index, raw_line in enumerate(lines or []):
|
||||
if not isinstance(raw_line, dict):
|
||||
continue
|
||||
raw_value = str(raw_line.get("reservation_id") or "").strip()
|
||||
if is_valid_reservation_id(raw_value):
|
||||
continue
|
||||
issues.append(
|
||||
{
|
||||
"line_index": index,
|
||||
"sku": str(raw_line.get("sku") or "").strip(),
|
||||
"field": "reservation_id",
|
||||
"reason": "invalid_format" if raw_value else "missing",
|
||||
"severity": "blocking",
|
||||
"raw_value": raw_value,
|
||||
}
|
||||
)
|
||||
return issues
|
||||
Reference in new issue
Block a user