落地海运协同群:测服靠会话存档听群话,报价单能带上协同字段。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -102,6 +102,15 @@ class HttpLedger:
|
||||
return {"ok": False, "found": False, "owned": False, "work_order_no": work_order_no}
|
||||
return out
|
||||
|
||||
def get_ticket(self, *, work_order_no: str) -> dict[str, Any] | None:
|
||||
"""用工单号读快照。给群入站在按房间反查时用。找不到返回 None。"""
|
||||
out = self.get_for_agent(work_order_no=work_order_no, sender_id="")
|
||||
if not out or (not out.get("found") and not out.get("work_order_no") and not out.get("ok")):
|
||||
return None
|
||||
if out.get("found") is False and out.get("ok") is False:
|
||||
return None
|
||||
return out
|
||||
|
||||
def query_tms(
|
||||
self,
|
||||
*,
|
||||
@@ -224,6 +233,7 @@ class HttpLedger:
|
||||
chat_id: str,
|
||||
member_ids: list[str],
|
||||
product_names: list[str] | None = None,
|
||||
product_ids: list[str] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
out = self._post(
|
||||
"/inquiry/agent/ticket/bindCollabGroup",
|
||||
@@ -232,6 +242,7 @@ class HttpLedger:
|
||||
"chatId": chat_id,
|
||||
"memberIds": member_ids,
|
||||
"productNames": product_names or [],
|
||||
"productIds": product_ids or [],
|
||||
},
|
||||
idem=f"bind-group:{work_order_no}",
|
||||
)
|
||||
@@ -261,3 +272,50 @@ class HttpLedger:
|
||||
if not out.get("found") and not out.get("work_order_no"):
|
||||
return None
|
||||
return out
|
||||
|
||||
def end_collab_group(self, *, work_order_no: str) -> dict[str, Any]:
|
||||
"""协同结束,这单不能再拉群。不改六态。"""
|
||||
return self._post(
|
||||
"/inquiry/agent/ticket/endCollabGroup",
|
||||
{"workOrderNo": work_order_no},
|
||||
idem=f"end-collab:{work_order_no}",
|
||||
)
|
||||
|
||||
def attach_file(
|
||||
self,
|
||||
*,
|
||||
work_order_no: str,
|
||||
file_name: str,
|
||||
object_key: str = "",
|
||||
content_type: str = "",
|
||||
sender_id: str = "",
|
||||
) -> dict[str, Any]:
|
||||
"""群附件元数据写入主账。"""
|
||||
return self._post(
|
||||
"/inquiry/agent/ticket/attachFile",
|
||||
{
|
||||
"workOrderNo": work_order_no,
|
||||
"fileName": file_name,
|
||||
"objectKey": object_key or file_name,
|
||||
"contentType": content_type,
|
||||
"senderId": sender_id,
|
||||
},
|
||||
)
|
||||
|
||||
def upsert_product_quote(
|
||||
self,
|
||||
*,
|
||||
work_order_no: str,
|
||||
quote: dict[str, Any],
|
||||
to_status: str = "已报价",
|
||||
) -> dict[str, Any]:
|
||||
"""产品报价写入主账并迁已报价。"""
|
||||
return self._post(
|
||||
"/inquiry/agent/ticket/upsertProductQuote",
|
||||
{
|
||||
"workOrderNo": work_order_no,
|
||||
"quote": quote,
|
||||
"toStatus": to_status,
|
||||
},
|
||||
idem=f"product-quote:{work_order_no}:{sorted((quote or {}).keys())}",
|
||||
)
|
||||
|
||||
@@ -36,6 +36,10 @@ class MemoryTicket:
|
||||
collab_chat_id: str = ""
|
||||
collab_facts: dict[str, str] = field(default_factory=dict)
|
||||
collab_member_ids: list[str] = field(default_factory=list)
|
||||
product_ids: list[str] = field(default_factory=list)
|
||||
product_names: list[str] = field(default_factory=list)
|
||||
collab_ended: bool = False
|
||||
attachments: list[dict[str, Any]] = field(default_factory=list)
|
||||
quote_file_ready: bool = False
|
||||
|
||||
|
||||
@@ -367,17 +371,64 @@ class MemoryLedger:
|
||||
chat_id: str,
|
||||
member_ids: list[str],
|
||||
product_names: list[str] | None = None,
|
||||
product_ids: list[str] | None = None,
|
||||
) -> dict[str, Any]:
|
||||
"""记下协同群,不改六态。"""
|
||||
_ = product_names
|
||||
"""记下协同群和产品姓名,不改六态。重启后群摘要还要靠这些名字 @ 到人。"""
|
||||
with self._lock:
|
||||
ticket = self._tickets.get(work_order_no)
|
||||
if ticket is None:
|
||||
return {"ok": False, "error": "ticket_not_found"}
|
||||
ticket.collab_chat_id = (chat_id or "").strip()
|
||||
ticket.collab_member_ids = [str(x) for x in member_ids]
|
||||
ticket.product_ids = [str(x) for x in (product_ids or [])]
|
||||
ticket.product_names = [str(x).strip() for x in (product_names or []) if str(x).strip()]
|
||||
return {"ok": True, "chat_id": ticket.collab_chat_id}
|
||||
|
||||
def end_collab_group(self, *, work_order_no: str) -> dict[str, Any]:
|
||||
"""协同结束:不改六态,这单不能再拉群。"""
|
||||
with self._lock:
|
||||
ticket = self._tickets.get(work_order_no)
|
||||
if ticket is None:
|
||||
return {"ok": False, "error": "ticket_not_found"}
|
||||
ticket.collab_ended = True
|
||||
ticket.collab_facts["__ended"] = "1"
|
||||
return {"ok": True, "collab_ended": True}
|
||||
|
||||
def attach_file(
|
||||
self,
|
||||
*,
|
||||
work_order_no: str,
|
||||
file_name: str,
|
||||
object_key: str = "",
|
||||
content_type: str = "",
|
||||
sender_id: str = "",
|
||||
) -> dict[str, Any]:
|
||||
"""把群附件记到工单。不改六态。"""
|
||||
with self._lock:
|
||||
ticket = self._tickets.get(work_order_no)
|
||||
if ticket is None:
|
||||
return {"ok": False, "error": "ticket_not_found"}
|
||||
row = {
|
||||
"file_name": file_name,
|
||||
"object_key": object_key or file_name,
|
||||
"content_type": content_type,
|
||||
"sender_id": sender_id,
|
||||
}
|
||||
ticket.attachments.append(row)
|
||||
return {"ok": True, "file_name": file_name}
|
||||
|
||||
def upsert_product_quote(
|
||||
self,
|
||||
*,
|
||||
work_order_no: str,
|
||||
quote: dict[str, Any],
|
||||
to_status: str = "已报价",
|
||||
) -> dict[str, Any]:
|
||||
"""产品报价盖 TMS 价。"""
|
||||
return self.upsert_quote(
|
||||
work_order_no=work_order_no, quote=quote, to_status=to_status
|
||||
)
|
||||
|
||||
def patch_collab_facts(
|
||||
self,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user