陆运选定线路后,私聊明细补报价有效期,群摘要只用已选线路并不再重复标题。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1005,7 +1005,8 @@ def sea_quote_detail_text(
|
||||
"""
|
||||
完整价格明细文本:来源、工单号、费用行、总价。海运/陆运/空运共用。
|
||||
|
||||
陆运分段时效跟在各段费用后面,用 TMS 原文。海运时效、报价有效期仍只在卡片上。
|
||||
陆运分段时效跟在各段费用后面,用 TMS 原文;报价有效期写在总成本价下面。
|
||||
海运时效、报价有效期仍只在按钮卡副标题。
|
||||
空运:业务确认没有时效,总销售价下面只留报价有效期。
|
||||
不受卡片引用条字数限制。first_or_same 只兼容调用方。
|
||||
"""
|
||||
@@ -1025,7 +1026,8 @@ def sea_quote_detail_text(
|
||||
if land_line:
|
||||
lines.append(land_line)
|
||||
lines.append(quote_area_fee_text(src, business_line=business_line or "SEA"))
|
||||
if line == "AIR":
|
||||
# 空运、陆运的价格明细正文都要带有效期。海运仍放在按钮卡副标题,避免和原口径打架。
|
||||
if line in {"AIR", "LAND"}:
|
||||
lines.append(f"报价有效期:{tms_valid_until_display(src)}")
|
||||
return "\n".join(lines)
|
||||
|
||||
@@ -1698,6 +1700,40 @@ def resolve_tms_quote(sess: Any = None, ticket: Any = None) -> dict[str, Any]:
|
||||
return {}
|
||||
|
||||
|
||||
def _land_quote_is_selected(quote: dict[str, Any] | None) -> bool:
|
||||
"""已收成一条陆运线路:有选定段,或只剩一条且写了线路名。"""
|
||||
src = dict(quote or {})
|
||||
selected = src.get("selected_land_route")
|
||||
if isinstance(selected, dict) and list(selected.get("legs") or []):
|
||||
return True
|
||||
if not str(src.get("route_line") or "").strip():
|
||||
return False
|
||||
from agent.schema.land_route_options import needs_route_pick
|
||||
|
||||
return not needs_route_pick(src)
|
||||
|
||||
|
||||
def land_group_tms_quote(
|
||||
tms: dict[str, Any] | None,
|
||||
current: dict[str, Any] | None,
|
||||
) -> dict[str, Any]:
|
||||
"""
|
||||
群摘要陆运 TMS 段用已选线路,不用还没选的整包。
|
||||
|
||||
选定前书签里的 TMS 原价含全部备选费用,总成本价和时效都还没汇总。
|
||||
当前价已是选定投影时用当前价。当前价已是人工报价或调价时,仍用传入的 TMS 价。
|
||||
"""
|
||||
raw = dict(tms or {})
|
||||
cur = dict(current or {})
|
||||
if not quote_is_tms(cur) or not _land_quote_is_selected(cur):
|
||||
return raw
|
||||
from agent.schema.land_route_options import needs_route_pick
|
||||
|
||||
if _land_quote_is_selected(raw) and not needs_route_pick(raw):
|
||||
return raw
|
||||
return cur
|
||||
|
||||
|
||||
def sea_group_brief(
|
||||
*,
|
||||
work_order_no: str,
|
||||
@@ -1741,10 +1777,26 @@ def sea_group_brief(
|
||||
product_quote=product_quote,
|
||||
has_price=has_price,
|
||||
)
|
||||
if mode == "陆运":
|
||||
# 拉群时书签仍可能是整包。当前价已选定时换成那一条,和私聊明细对齐。
|
||||
tms = land_group_tms_quote(tms, quote)
|
||||
lines.append("")
|
||||
lines.append("TMS报价:")
|
||||
if tms and (tms.get("total") or quote_fee_lines(tms)):
|
||||
lines.extend(quote_detail_lines(tms, transport_mode=mode))
|
||||
if mode == "陆运":
|
||||
# 与私聊价格明细同一套:线路名、分段费用、各段时效、总成本价、有效期。
|
||||
# 不用 quote_detail_lines,那会再补一行合并时效,也会在未选定时摊开全部费用。
|
||||
# 群里已有「TMS报价:」,不要再叠「TMS标准报价」和「工单号价格明细」。
|
||||
detail = sea_quote_detail_text(
|
||||
work_order_no=no,
|
||||
quote=tms,
|
||||
business_line="LAND",
|
||||
).splitlines()
|
||||
source = str(tms.get("source_label") or "TMS标准报价").replace(" ", "")
|
||||
title = f"{no}价格明细"
|
||||
lines.extend(ln for ln in detail if ln.strip() not in {source, title, "TMS标准报价"})
|
||||
else:
|
||||
lines.extend(quote_detail_lines(tms, transport_mode=mode))
|
||||
lines.append(group_tms_confirm_hint())
|
||||
else:
|
||||
lines.append("TMS 暂无匹配报价")
|
||||
|
||||
Reference in New Issue
Block a user