feat(shipping-notice): 支持发货通知解析延后至 Dify 画布,优化任务创建流程
This commit is contained in:
1 parent
d46d61bfa1
commit
70e8f700ff
38 files changed
+3215
-714
No files matched your search
@@ -8,7 +8,7 @@ services/shipping_notice/match.py
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
from typing import Any, Callable
|
||||
|
||||
from app.services.shipping_notice.i18n import resolve_lang, t
|
||||
from app.services.shipping_notice.reservation_id import extract_reservation_id
|
||||
@@ -60,6 +60,8 @@ def _available_for_notice_line(
|
||||
def match_notice_lines(
|
||||
notice_lines: list[dict[str, Any]],
|
||||
inventory_lines: list[dict[str, Any]],
|
||||
*,
|
||||
progress_callback: Callable[[int, int], None] | None = None,
|
||||
) -> tuple[str, list[dict[str, Any]], dict[str, Any]]:
|
||||
"""
|
||||
将订单行与库存行按 (sku, reservation_id) 匹配,计算 fulfillable/partial/unfulfillable。
|
||||
@@ -78,7 +80,8 @@ def match_notice_lines(
|
||||
has_shortage = False
|
||||
|
||||
# [STEP 2] 逐订单行计算 ok/partial/shortage 并收集缺口明细。
|
||||
for line in notice_lines:
|
||||
total_lines = len(notice_lines)
|
||||
for index, line in enumerate(notice_lines, start=1):
|
||||
sku = _norm(line.get("sku"))
|
||||
reservation_id = _norm_reservation(line.get("reservation_id")) or None
|
||||
try:
|
||||
@@ -110,6 +113,8 @@ def match_notice_lines(
|
||||
line_results.append(result)
|
||||
if shortage > 0:
|
||||
shortages.append(result)
|
||||
if progress_callback is not None:
|
||||
progress_callback(index, total_lines)
|
||||
|
||||
# [STEP 3] 汇总整体 match_status(fulfillable / partial / unfulfillable)。
|
||||
if not notice_lines:
|
||||
|
||||
Reference in new issue
Block a user