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

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
+3 -1
View File
@@ -629,7 +629,9 @@ def apply_air_quote(
fields = extract_air_collab_fields(text)
if fields:
flow.ledger.patch_collab_facts(work_order_no=no, facts=fields, sender_id=sender_id)
quote = injected_quote or extract_product_quote(text) or {}
quote = injected_quote or extract_product_quote(
text, business_line="AIR", transport_mode="空运"
) or {}
if not quote:
send_group_text(client, chat_id, copy.air_quote_not_recognized())
return "quote_empty"
@@ -152,7 +152,15 @@ def handle_multi_inbound(
ticket = _reload(flow, no) or ticket
segments = load_segments(ticket)
target = next((seg for seg in segments if seg.mode == mode), target)
quote = extract_product_quote(text or "", injected=injected_quote)
quote = extract_product_quote(
text or "",
injected=injected_quote,
business_line=str(mode or "").upper(),
transport_mode=(
"陆运" if str(mode or "").upper() == "LAND"
else ("空运" if str(mode or "").upper() == "AIR" else "海运")
),
)
if not quote:
if fields:
return "multi_collab_saved"
+48 -1
View File
@@ -929,7 +929,13 @@ def apply_product_quote(
merged = dict(sess.collab_facts)
merged.update(fields)
sess.collab_facts = merged
quote = extract_product_quote(text, injected=injected_quote)
line = str(view.get("business_line") or view.get("businessLine") or "").strip().upper()
quote = extract_product_quote(
text,
injected=injected_quote,
business_line=line,
transport_mode="陆运" if line == "LAND" else ("海运" if line == "SEA" else ""),
)
if not quote:
logger.info("产品报价未识别 wo=%s text=%s", no, (text or "")[:200])
send_group_text(client, chat_id, copy.group_quote_not_recognized())
@@ -941,7 +947,9 @@ def apply_product_quote(
send_group_text(client, chat_id, copy.group_ask_tms_or_product())
return "wait_tms_choice"
# 分档单价是完整人工价(含费率),禁止和旧错误行(如燃油附加费=2)相加。
# 旧错默认「海运费」的陆运产品价:重报时按本单默认运费对齐后再盖,避免海运费+陆运费并排。
if _quote_fee_rows(base) and not (quote.get("weightPrices") or []):
base = _align_wrong_default_freight(base, quote, business_line=line)
quote = merge_quote_fees(base, quote)
_save_product_quote(flow, no, quote, sess)
ticket2 = _reload(flow, chat_id, no) or ticket
@@ -1627,6 +1635,45 @@ def _merged_total(
return str(src.get("total") or ""), header_ccy
def _align_wrong_default_freight(
base: dict[str, Any] | None,
overlay: dict[str, Any] | None,
*,
business_line: str = "",
) -> dict[str, Any]:
"""
陆运/空运旧产品价若误落成别的运输方式默认费名,重报前改成与新报价同名,便于按行盖价。
只动「海运费/陆运费/空运费/运输费」这类主运费默认名,不碰操作费等真实分项。
"""
src = dict(base or {})
line = (business_line or "").strip().upper()
want = {"LAND": "陆运费", "AIR": "空运费", "SEA": "海运费"}.get(line, "")
if not want:
return src
new_names = {
str(x.get("name") or "").strip()
for x in (overlay or {}).get("fee_rows") or (overlay or {}).get("fee_lines") or []
if isinstance(x, dict)
}
if want not in new_names:
return src
mains = {"海运费", "陆运费", "空运费", "运输费"}
rows = _quote_fee_rows(src)
changed = False
for row in rows:
name = str(row.get("name") or "").strip()
if name in mains and name != want:
row["name"] = want
changed = True
if not changed:
return src
out = dict(src)
out["fee_rows"] = rows
out["fee_lines"] = rows
return out
def merge_quote_fees(base: dict[str, Any] | None, overlay: dict[str, Any] | None) -> dict[str, Any]:
"""
产品按行改价盖到原 TMS 明细上。没点名的费用原样保留。