落地空运单聊询价字段与线路选择。

必填核对后再建单;多条线路走 H5 点选;费用只展示该线路 TMS 回包,不套用整单空运费。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-22 15:02:32 +08:00
co-authored by Cursor
parent 8afe909230
commit cfbce2fd69
53 changed files with 3470 additions and 372 deletions
+30 -23
View File
@@ -27,6 +27,8 @@ STEP_LLM_NO_TICKET = copy.STEP_LLM_NO_TICKET
STEP_LLM = copy.STEP_LLM
STEP_TMS_QUOTE = copy.STEP_TMS_QUOTE
STEP_TMS_CABIN = copy.STEP_TMS_CABIN
STEP_TMS_LOCK = copy.STEP_TMS_LOCK
STEP_TMS_RELEASE = copy.STEP_TMS_RELEASE
STEP_GROUP = copy.STEP_GROUP
MAX_AUTO_RETRIES = 3
@@ -140,15 +142,6 @@ def _now_text(now: datetime | None) -> str:
return stamp.strftime("%Y-%m-%d %H:%M:%S")
def _test_prefix() -> bool:
try:
from agent.config import get_settings
return (get_settings().ytd_env or "").strip().lower() == "test"
except Exception: # noqa: BLE001
return False
def notify_app_ready() -> bool:
"""询价消息服务已配才推告警。"""
from agent.policy.deal_outcome import notify_app_ready as deal_ready
@@ -244,7 +237,6 @@ def confirm_system_exception(
users = _list_notify_users(ledger) if ledger is not None else []
if ready and users:
occurred = _now_text(now)
test_prefix = _test_prefix()
payload = copy.system_exception_alert_payload(
work_order_no=no,
exception_type=event.exception_type,
@@ -252,7 +244,6 @@ def confirm_system_exception(
error_code=event.error_code,
step=event.step,
occurred_at=occurred,
test_prefix=test_prefix,
)
text = copy.system_exception_alert_text(
work_order_no=no,
@@ -261,7 +252,6 @@ def confirm_system_exception(
error_code=event.error_code,
step=event.step,
occurred_at=occurred,
test_prefix=test_prefix,
)
sender = enqueue or _enqueue_default
for row in users:
@@ -626,7 +616,7 @@ def run_admin_retry(work_order_no: str, *, ledger: Any = None) -> dict[str, Any]
reply("请把刚才那句话再发一次。")
return {"ok": True, "step": step}
if step == STEP_TMS_CABIN:
if step in {STEP_TMS_CABIN, STEP_TMS_LOCK, STEP_TMS_RELEASE}:
return _resume_cabin_step(
ledger=book,
work_order_no=no,
@@ -634,6 +624,7 @@ def run_admin_retry(work_order_no: str, *, ledger: Any = None) -> dict[str, Any]
target=target,
status=status,
reply=reply,
step=step,
)
return {"ok": False, "error": "unknown_step", "step": step}
@@ -716,10 +707,14 @@ def _resume_tms_quote(
copy.remember_tms_quote(sess, quote)
flow._save(sess)
if biz == "AIR":
reply(
copy.tms_hit_card(work_order_no=no, quote=quote, status="已报价"),
copy.tms_hit_wecom_payload(work_order_no=no, quote=quote, status="已报价"),
)
emit_air = getattr(flow, "_emit_air_hit", None)
if callable(emit_air):
emit_air(reply, work_order_no=no, quote=quote, status="已报价")
else:
reply(
copy.tms_hit_card(work_order_no=no, quote=quote, status="已报价"),
copy.tms_hit_wecom_payload(work_order_no=no, quote=quote, status="已报价"),
)
return
emit = getattr(flow, "_emit_sea_hit", None)
if callable(emit):
@@ -742,13 +737,17 @@ def _resume_cabin_step(
target: str,
status: str,
reply: ReplyFn,
step: str = "",
) -> dict[str, Any]:
"""重试空运锁舱或释放:payload 里有 lock_id 就是释放。"""
no = (work_order_no or "").strip()
lock_id = str(extra.get("lock_id") or "").strip()
option_no = str(extra.get("option_no") or "").strip() or "AIR-OPT-01"
option_no = str(extra.get("option_no") or "").strip()
instruction = str(extra.get("instruction") or "")
sender = str(extra.get("sender_id") or target or "").strip()
cabin_step = STEP_TMS_RELEASE if lock_id else STEP_TMS_LOCK
if (step or "").strip() in {STEP_TMS_LOCK, STEP_TMS_RELEASE}:
cabin_step = (step or "").strip()
if lock_id:
releaser = getattr(ledger, "release_cabin", None)
out = call_with_retries(
@@ -782,10 +781,19 @@ def _resume_cabin_step(
service = "空运锁舱"
reason = "空运锁舱接口调用失败"
if not (out or {}).get("ok"):
why = copy.air_cabin_fail_reason(
tms_reason=str((out or {}).get("failReason") or (out or {}).get("error") or ""),
flight_date=str(extra.get("flight_date") or ""),
)
operator = str(extra.get("operator_name") or "同事").strip() or "同事"
if cabin_step == STEP_TMS_RELEASE or lock_id:
reply(copy.air_release_fail(work_order_no=no, operator=operator, reason=why))
else:
reply(copy.air_lock_fail(work_order_no=no, operator=operator, reason=why))
confirm_system_exception(
event=SystemExceptionEvent(
exception_type=TYPE_TMS,
step=STEP_TMS_CABIN,
step=cabin_step,
reason=reason,
service=service,
error_code=str((out or {}).get("failReason") or (out or {}).get("error") or "CABIN_FAIL"),
@@ -796,10 +804,9 @@ def _resume_cabin_step(
extra=dict(extra),
),
ledger=ledger,
reply=reply,
)
return {"ok": False, "error": "still_fail", "step": STEP_TMS_CABIN}
reply(copy.system_exception_recovery(STEP_TMS_CABIN))
return {"ok": False, "error": "still_fail", "step": cabin_step}
reply(copy.system_exception_recovery(cabin_step))
clear_system_exception(ledger=ledger, work_order_no=no)
if not lock_id:
exec_no = str((out or {}).get("lockId") or (out or {}).get("tmsRequestId") or "").strip()
@@ -813,4 +820,4 @@ def _resume_cabin_step(
reply(copy.air_lock_ok(work_order_no=no, operator="同事", option_no=option_no, exec_no=exec_no, quote_no=""))
else:
reply(copy.air_release_ok(work_order_no=no, operator="同事", option_no="", exec_no=str((out or {}).get("releaseId") or lock_id), quote_no=""))
return {"ok": True, "step": STEP_TMS_CABIN}
return {"ok": True, "step": cabin_step}