空运协同里手工改费用、有起运地、锁舱失败或缺参会被误判,报价单已出后再激活又重发模板。按销售侧口径收紧这些分支,并让价格卡和未成交回执带上真实工单号。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -106,6 +106,82 @@ class AirRouteOptionsTests(unittest.TestCase):
|
||||
self.assertEqual(sess.facts.get("起运港"), "深圳")
|
||||
self.assertIn("SZX-CRK", "\n".join(replies[-2:]))
|
||||
|
||||
def test_hangzhou_query_uses_airport_and_skips_other_cities(self) -> None:
|
||||
"""写了杭州就不能按目的地把南京、深圳、郑州拿来选。"""
|
||||
from agent.ledger.memory_ledger import MemoryLedger
|
||||
from agent.policy.air_text_flow import AirTextInquiryFlow
|
||||
from agent.schema.tms_air_query import assemble_air_query
|
||||
|
||||
ready = assemble_air_query({"起运港": "杭州", "目的港": "吉隆坡"})
|
||||
self.assertEqual(ready["facts"].get("originCode"), "HGH")
|
||||
self.assertEqual(ready["facts"].get("destinationCode"), "KUL")
|
||||
|
||||
class Ledger(MemoryLedger):
|
||||
def query_tms(self, **kwargs):
|
||||
out = super().query_tms(**kwargs)
|
||||
quote = out["quote"]
|
||||
quote["total"] = "1750.35"
|
||||
quote["currency"] = "CNY"
|
||||
quote["airOptions"] = [
|
||||
{"originAirportCode": "NKG", "destinationAirportCode": "KUL", "salePrice": 1750.35, "currency": "CNY"},
|
||||
{"originAirportCode": "SZX", "destinationAirportCode": "KUL", "salePrice": 1833.7, "currency": "CNY"},
|
||||
{"originAirportCode": "CGO", "destinationAirportCode": "KUL", "salePrice": 1833.7, "currency": "CNY"},
|
||||
]
|
||||
return out
|
||||
|
||||
flow = AirTextInquiryFlow(Ledger())
|
||||
replies: list[str] = []
|
||||
|
||||
def reply(text: str, extra=None) -> None:
|
||||
replies.append(text)
|
||||
_ = extra
|
||||
|
||||
facts = {
|
||||
"起运港": "杭州",
|
||||
"目的港": "吉隆坡",
|
||||
"品名": "化妆品",
|
||||
"件数": "12",
|
||||
"毛重": "21",
|
||||
"体积": "1",
|
||||
"包装方式": "散货",
|
||||
}
|
||||
self.assertEqual(
|
||||
flow.on_text(sender_id="u_hgh", text="空运", reply=reply, injected_facts=facts, injected_mode="AIR"),
|
||||
"wait_confirm",
|
||||
)
|
||||
phase = flow.on_text(sender_id="u_hgh", text="确定", reply=reply)
|
||||
self.assertEqual(phase, "tms_miss")
|
||||
self.assertFalse(any("条线路" in x for x in replies))
|
||||
self.assertEqual(flow.session_of("u_hgh").facts.get("originCode"), "HGH")
|
||||
|
||||
def test_stated_origin_quotes_directly(self) -> None:
|
||||
"""起运地已经是珠海时,即使 TMS 还带回别的城市,也不再让销售选线。"""
|
||||
from agent.ledger.memory_ledger import MemoryLedger
|
||||
from agent.policy.air_text_flow import AirTextInquiryFlow
|
||||
|
||||
flow = AirTextInquiryFlow(MemoryLedger())
|
||||
replies: list[str] = []
|
||||
|
||||
def reply(text: str, extra=None) -> None:
|
||||
replies.append(text)
|
||||
_ = extra
|
||||
|
||||
facts = {
|
||||
"起运港": "珠海",
|
||||
"目的港": "克拉克",
|
||||
"品名": "茶叶",
|
||||
"件数": "10",
|
||||
"毛重": "100",
|
||||
"体积": "2",
|
||||
"包装方式": "托盘",
|
||||
"tms_multi": "1",
|
||||
}
|
||||
flow.on_text(sender_id="u_zuh", text="空运", reply=reply, injected_facts=facts, injected_mode="AIR")
|
||||
phase = flow.on_text(sender_id="u_zuh", text="确定", reply=reply)
|
||||
self.assertEqual(phase, "wait_collab")
|
||||
self.assertFalse(any("条线路" in x for x in replies))
|
||||
self.assertEqual(flow.session_of("u_zuh").facts.get("起运港"), "珠海")
|
||||
|
||||
def test_reselect_after_adopt_voids_old_file(self) -> None:
|
||||
"""采用后再改选:旧报价单作废,回到方案卡重新采用。"""
|
||||
ledger = MemoryLedger()
|
||||
|
||||
Reference in New Issue
Block a user