陆运产品价无费名时默认陆运费;看板指标与工单列表共用起止日,趋势按日铺点。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
linmianxun
2026-10-12 14:57:27 +08:00
co-authored by Cursor
parent 739ba401aa
commit 428548c390
10 changed files with 219 additions and 44 deletions
+35 -5
View File
@@ -961,7 +961,32 @@ def _parse_fee_rows(text: str) -> list[dict[str, str]]:
return rows
def extract_product_quote(text: str, *, injected: Optional[dict[str, Any]] = None) -> dict[str, Any]:
def _default_product_fee_name(business_line: str = "", transport_mode: str = "") -> str:
"""
产品文字未点费用名时的默认费目。
必须跟本单运输方式走:陆运→陆运费、空运→空运费、其余→海运费。
禁止陆运单无费名时硬编码「海运费」(WO202610090118「价格为1RMB/KG」)。
"""
line = (business_line or "").strip().upper()
mode = (transport_mode or "").strip()
if line == "LAND" or mode in {"陆运", "LAND", "land"}:
return "陆运费"
if line == "AIR" or mode in {"空运", "AIR", "air"}:
return "空运费"
if line == "SEA" or mode in {"海运", "SEA", "sea"}:
return "海运费"
# 未传业务线时保持旧默认,避免海运调用方漏参后费名变空。
return "海运费"
def extract_product_quote(
text: str,
*,
injected: Optional[dict[str, Any]] = None,
business_line: str = "",
transport_mode: str = "",
) -> dict[str, Any]:
"""
产品文字报价:先按费用行抽,再退回合计/币别。注入优先。
@@ -970,6 +995,7 @@ def extract_product_quote(text: str, *, injected: Optional[dict[str, Any]] = Non
「空运费 单价…金额…」必须保留空运费,金额用「金额」后面的数,不用单价。
陆运集拼:「2-500KG 单价CNY990,燃油附加费率1%,税率6%」走分档单价+费率,
禁止把公斤档下限「2」当成燃油附加费金额(WO021)。
无费用名时按 business_line/transport_mode 默认陆运费/空运费/海运费,禁止陆运硬套海运费。
"""
if isinstance(injected, dict) and (injected.get("total") or injected.get("fee_rows")):
out = dict(injected)
@@ -1015,15 +1041,19 @@ def extract_product_quote(text: str, *, injected: Optional[dict[str, Any]] = Non
if not amount:
return {}
ccy = _currency_of(raw)
default_fee = _default_product_fee_name(business_line, transport_mode)
# 句里已经点了费用名(空运费)时,不能退回默认海运费。
named = re.search(
r"([\u4e00-\u9fffA-Za-z][\u4e00-\u9fffA-Za-z0-9/()()++\--]{0,24}费)",
scrubbed or raw,
)
fee_name = (named.group(1) if named else "") or "海运费"
if fee_name in {"费用", "燃油附加费"}:
# 「燃油附加费率」里的「燃油附加费」不是费用行名;无其它费名时用运费。
fee_name = "海运费" if fee_name == "费用" else "陆运费"
fee_name = (named.group(1) if named else "") or default_fee
if fee_name == "费用":
# 句里只有「费用」没有运输方式前缀时,跟本单默认运费。
fee_name = default_fee
elif fee_name == "燃油附加费":
# 「燃油附加费率」误抽成费名时:陆运/空运用本单默认;海运旧行为落陆运费,避免当海运费金额。
fee_name = default_fee if default_fee != "海运费" else "陆运费"
out = {
"total": amount,
"currency": ccy,