落地陆运私聊文字询价:选项核对后再建单查价,并按线路拉产品进群。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-17 16:23:30 +08:00
co-authored by Cursor
parent 83b907c4b8
commit be95d823a2
52 changed files with 4534 additions and 76 deletions
+37 -9
View File
@@ -121,8 +121,19 @@ class SeaTextInquiryFlow(AirTextInquiryFlow):
if mode != "SEA":
if mode == "LAND":
reply(copy.ASK_LAND_SUBTYPE)
return "need_land_subtype"
from agent.policy.land_text_flow import get_land_text_flow
return get_land_text_flow().on_text(
sender_id=sender_id,
text=text,
reply=reply,
injected_facts=facts,
injected_mode=mode,
b_result=b_result,
allow_b=allow_b,
chat_fn=chat_fn,
inbound_raw=inbound_raw,
)
# 空运交给空运 Owner,避免海运流程半做空运
from agent.policy.air_text_flow import get_air_text_flow
@@ -272,20 +283,22 @@ class SeaTextInquiryFlow(AirTextInquiryFlow):
*,
facts: dict[str, str],
current_no: str,
business_line: str = "SEA",
) -> tuple[str, str]:
history = str(created.get("similar_work_order_no") or "").strip()
first = str(created.get("first_or_same") or "first")
if first == "same" and history and history != current_no:
return "same", history
finder = getattr(self._ledger, "find_similar_open", None)
line = (business_line or "SEA").strip() or "SEA"
if not callable(finder):
return "first", ""
try:
similar = finder(
facts=facts, business_line="SEA", exclude_work_order_no=current_no
facts=facts, business_line=line, exclude_work_order_no=current_no
) or {}
except TypeError:
similar = finder(facts=facts, business_line="SEA") or {}
similar = finder(facts=facts, business_line=line) or {}
except Exception:
logger.warning("find_similar 失败,按首次询价展示 current=%s", current_no)
return "first", ""
@@ -308,9 +321,9 @@ class SeaTextInquiryFlow(AirTextInquiryFlow):
def _session_from_ledger(self, *, sender_id: str, view: dict[str, Any]) -> FlowSession:
sess = super()._session_from_ledger(sender_id=sender_id, view=view)
if sess.business_line == "SEA" and sess.phase == "wait_collab":
if sess.business_line in {"SEA", "LAND"} and sess.phase == "wait_collab":
sess.allowed = (copy.BTN_PULL_COLLAB, copy.BTN_SKIP_COLLAB)
if sess.business_line == "SEA" and sess.phase == "tms_miss":
if sess.business_line in {"SEA", "LAND"} and sess.phase == "tms_miss":
sess.allowed = (copy.BTN_PULL_COLLAB,)
sess.collab_chat_id = str(view.get("collab_chat_id") or "")
sess.collab_facts = dict(view.get("collab_facts") or {})
@@ -452,7 +465,7 @@ class SeaTextInquiryFlow(AirTextInquiryFlow):
staff = self._match_sea_staff(sess)
if not staff:
reply(copy.sea_group_no_staff())
reply(self._group_no_staff_copy())
return sess.phase or "wait_collab"
userids = [sess.sender_id]
@@ -469,7 +482,7 @@ class SeaTextInquiryFlow(AirTextInquiryFlow):
product_ids.append(uid)
product_names.append(name)
if not product_ids:
reply(copy.sea_group_no_staff())
reply(self._group_no_staff_copy())
return sess.phase or "wait_collab"
# 销售 + 产品之后,必须再拉会话存档账号;没有也不挡建群。
@@ -509,12 +522,18 @@ class SeaTextInquiryFlow(AirTextInquiryFlow):
sales_name=sales_name,
product_names=product_names,
has_price=bool(sess.quote and sess.status == "已报价"),
transport_mode=self._group_brief_mode(sess),
)
client.send_group(chat_id=chat_id, content=brief)
sess.collab_chat_id = chat_id
from agent.policy.sea_group_ops import send_filled_sheet
send_filled_sheet(flow=self, ticket=None, sess=sess)
send_filled_sheet(
flow=self,
ticket=None,
sess=sess,
business_line=(sess.business_line or "SEA"),
)
sess.invited_userids = tuple(userids)
sess.invited_sales_name = sales_name
sess.invited_product_names = tuple(product_names)
@@ -547,6 +566,15 @@ class SeaTextInquiryFlow(AirTextInquiryFlow):
return []
return [dict(x) for x in rows if isinstance(x, dict)]
def _group_no_staff_copy(self) -> str:
"""没人可拉时的私聊。海运用海运岗话术;陆运覆盖成陆运岗。"""
return copy.sea_group_no_staff()
def _group_brief_mode(self, sess: FlowSession) -> str:
"""群摘要运输方式展示。"""
_ = sess
return "海运"
def _archive_seat_userids(self) -> list[str]:
"""
会话存档账号 userid 列表。