落地海运私聊文字询价全流程,海运多项费用改走文本明细,避免企微卡片引用条截断。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-15 14:26:09 +08:00
co-authored by Cursor
parent 58b3c2f3e6
commit 0a3c74e3a1
41 changed files with 3702 additions and 48 deletions
@@ -14,10 +14,38 @@ from agent.channel.queue import get_message_store
from agent.channel.wecom.models import InboundMessage
from agent.policy import inquiry_copy as copy
from agent.policy.air_text_flow import get_air_text_flow
from agent.policy.sea_text_flow import get_sea_text_flow
logger = logging.getLogger(__name__)
def _pick_continue_flow(*, sender_id: str, work_order_no: str, flow=None):
"""
续办按工单选空运/海运流程。
海运书签或主账业务线是 SEA 必须走海运 Owner。
一律走空运会把已报价海运重放成空运协同卡(件数/毛重/包装)。
单测传入 flow 时不改选路,保持原断言。
"""
if flow is not None:
return flow
sea = get_sea_text_flow()
no = (work_order_no or "").strip()
hit = sea.session_by_ticket(sender_id, no) if no else None
if hit and (hit.business_line or "").upper() == "SEA":
return sea
getter = getattr(sea.ledger, "get_for_agent", None)
if callable(getter) and no:
try:
view = getter(work_order_no=no, sender_id=sender_id) or {}
except Exception:
logger.warning("continue_thread 读主账业务线失败 wo=%s", no)
view = {}
if str(view.get("business_line") or "").upper() == "SEA":
return sea
return get_air_text_flow()
def handle_continue_thread(
message: InboundMessage,
*,
@@ -34,7 +62,10 @@ def handle_continue_thread(
logger.warning("continue_thread 拒绝:无 sender_id")
return "reject_no_sender"
msg_store = store or get_message_store()
engine = flow or get_air_text_flow()
wo = (thread_id or "").strip() or copy.extract_work_order_no(message.content or "")
engine = _pick_continue_flow(
sender_id=message.sender_id, work_order_no=wo, flow=flow
)
replies: list[str] = []
def reply(text: str, extra: dict | None = None) -> str:
@@ -48,7 +79,6 @@ def handle_continue_thread(
logger.info("continue_thread 出站 ok=%s info=%s", ok, info)
return info if ok else ""
wo = (thread_id or "").strip() or copy.extract_work_order_no(message.content or "")
phase = engine.resume_historical(
sender_id=message.sender_id,
work_order_no=wo,