空运「货交」只记提货地址,不再当成起运地。舱位旧说法「释放」先问航线是否取消,陆运通关口岸示例改为友谊关。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-11 20:45:53 +08:00
co-authored by Cursor
parent b070a9b7a7
commit 185abbf45e
16 changed files with 533 additions and 49 deletions
@@ -0,0 +1,72 @@
"""
空运群取消舱位待确认。
航线说出和舱位有关的「释放」后先问一句,确认前不打 TMS。
短协调,不当六态、不当 checkpoint。按群记下工单号,双进程仍能读到。
两小时没人接话就过期,避免过后回一个「是」误取消。
"""
from __future__ import annotations
import json
import logging
from agent.redis_coord.keys import PENDING_CABIN_CANCEL
from agent.redis_coord.runtime import get_redis_runtime
logger = logging.getLogger(__name__)
# 问句只在这一阵有效。过期后「是」不再取消舱位。
_TTL_SECONDS = 2 * 60 * 60
def save_pending_cabin_cancel(chat_id: str, work_order_no: str) -> None:
"""记下本群正在等航线确认取消哪张单。"""
room = (chat_id or "").strip()
no = (work_order_no or "").strip()
if not room or not no:
return
payload = {"work_order_no": no}
try:
client = get_redis_runtime().client
client.raw.set(
client.key(PENDING_CABIN_CANCEL, room),
json.dumps(payload, ensure_ascii=False),
ex=_TTL_SECONDS,
)
logger.info("cabin.ask saved chat=%s wo=%s", room, no)
except Exception:
logger.exception("写取消舱位待确认失败 chat=%s", room)
def load_pending_cabin_cancel(chat_id: str) -> str:
"""本群正在等确认的工单号。没有则空串。"""
room = (chat_id or "").strip()
if not room:
return ""
try:
client = get_redis_runtime().client
raw = client.raw.get(client.key(PENDING_CABIN_CANCEL, room))
if not raw:
return ""
if isinstance(raw, bytes):
raw = raw.decode("utf-8")
data = json.loads(raw)
if not isinstance(data, dict):
return ""
return str(data.get("work_order_no") or "").strip()
except Exception:
logger.exception("读取消舱位待确认失败 chat=%s", room)
return ""
def clear_pending_cabin_cancel(chat_id: str) -> None:
"""确认、否认或改口办别的事时清掉。"""
room = (chat_id or "").strip()
if not room:
return
try:
client = get_redis_runtime().client
client.raw.delete(client.key(PENDING_CABIN_CANCEL, room))
except Exception:
logger.exception("清取消舱位待确认失败 chat=%s", room)