落地陆运私聊文字询价:选项核对后再建单查价,并按线路拉产品进群。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -55,6 +55,8 @@ WSHOTO_ROOM_TICKET = "wshoto:room_ticket"
|
||||
QUOTE_FILE_READY = "quote_file_ready"
|
||||
# 产品刚报价、等选「在TMS上改 / 不用TMS」:短协调,不当六态
|
||||
PENDING_PRODUCT_QUOTE = "pending_product_quote"
|
||||
# 陆运核对卡已出、等确定查价:短协调,不当六态、不当工单号
|
||||
PENDING_LAND_CONFIRM = "pending_land_confirm"
|
||||
# 空运群同一句:BOT 与存档补听去重,不当六态
|
||||
AIR_INBOUND_MSG = "air_inbound_msg"
|
||||
AIR_INBOUND_TEXT = "air_inbound_text"
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
"""
|
||||
陆运核对卡待确定:等销售回复确定后再建单。
|
||||
|
||||
短协调,不当六态、不当 checkpoint。进程重启或双进程抢 inbox 后仍能读到刚才那份字段。
|
||||
禁止:把运输分类当已建单;写入现网 Redis 前缀。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from agent.redis_coord.keys import PENDING_LAND_CONFIRM
|
||||
from agent.redis_coord.runtime import get_redis_runtime
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
_TTL_SEC = 24 * 3600
|
||||
|
||||
|
||||
def save_pending_land_confirm(
|
||||
sender_id: str,
|
||||
*,
|
||||
facts: dict[str, str],
|
||||
immutable_text: str = "",
|
||||
wait_version: int = 1,
|
||||
phase: str = "wait_confirm",
|
||||
work_order_no: str = "",
|
||||
) -> None:
|
||||
"""出核对卡或查价失败时记下字段,等确定建单/重查。"""
|
||||
sid = (sender_id or "").strip()
|
||||
if not sid or not isinstance(facts, dict) or not facts:
|
||||
return
|
||||
payload = {
|
||||
"facts": {str(k): str(v) for k, v in facts.items() if str(v).strip()},
|
||||
"immutable_text": (immutable_text or "").strip(),
|
||||
"wait_version": int(wait_version or 1),
|
||||
"business_line": "LAND",
|
||||
"phase": (phase or "wait_confirm").strip() or "wait_confirm",
|
||||
"work_order_no": (work_order_no or "").strip(),
|
||||
}
|
||||
try:
|
||||
client = get_redis_runtime().client
|
||||
client.raw.set(
|
||||
client.key(PENDING_LAND_CONFIRM, sid),
|
||||
json.dumps(payload, ensure_ascii=False),
|
||||
ex=_TTL_SEC,
|
||||
)
|
||||
logger.info(
|
||||
"land.pending saved sender=%s phase=%s wo=%s keys=%s",
|
||||
sid,
|
||||
payload["phase"],
|
||||
payload["work_order_no"] or "-",
|
||||
sorted(payload["facts"]),
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("写陆运待确定失败 sender=%s", sid)
|
||||
|
||||
|
||||
def load_pending_land_confirm(sender_id: str) -> dict[str, Any]:
|
||||
"""取出待确定陆运字段。没有或过期返回空。"""
|
||||
sid = (sender_id or "").strip()
|
||||
if not sid:
|
||||
return {}
|
||||
try:
|
||||
client = get_redis_runtime().client
|
||||
raw = client.raw.get(client.key(PENDING_LAND_CONFIRM, sid))
|
||||
if not raw:
|
||||
return {}
|
||||
if isinstance(raw, bytes):
|
||||
raw = raw.decode("utf-8")
|
||||
data = json.loads(raw)
|
||||
return dict(data) if isinstance(data, dict) else {}
|
||||
except Exception:
|
||||
logger.exception("读陆运待确定失败 sender=%s", sid)
|
||||
return {}
|
||||
|
||||
|
||||
def clear_pending_land_confirm(sender_id: str) -> None:
|
||||
"""建单且查价成功后清掉。查价失败会改记 tms_tech,不要在失败路径调用。"""
|
||||
sid = (sender_id or "").strip()
|
||||
if not sid:
|
||||
return
|
||||
try:
|
||||
client = get_redis_runtime().client
|
||||
client.raw.delete(client.key(PENDING_LAND_CONFIRM, sid))
|
||||
except Exception:
|
||||
logger.exception("清陆运待确定失败 sender=%s", sid)
|
||||
Reference in New Issue
Block a user