checkpoint: 提交当前工作区代码(同义词配置初版 + 既有流程改动)
- 新增 inq_synonym 表、62组同义词种子与智能体只读接口 - Python 同义词加载/归一化与 1板/2箱 机读 - 同步当前分支既有协作、报价识别、陆运等改动
This commit is contained in:
@@ -565,9 +565,15 @@ class QuoteAdjustTests(unittest.TestCase):
|
||||
detail = copy.sea_tms_hit_wecom_payload(
|
||||
work_order_no="WO202609200005", quote=q, business_line="LAND"
|
||||
)
|
||||
self.assertEqual(detail["template_card"]["source"]["desc"], "TMS标准报价")
|
||||
self.assertIn("费用合计:CNY 121.00", detail["template_card"]["quote_area"]["quote_text"])
|
||||
self.assertNotIn("总销售价", detail["template_card"]["quote_area"]["quote_text"])
|
||||
card = detail["template_card"]
|
||||
self.assertEqual(card["source"]["desc"], "TMS标准报价")
|
||||
# 卡片不再放费用合计引用条,总价口径由文字明细保证。
|
||||
self.assertNotIn("quote_area", card)
|
||||
text = copy.sea_quote_detail_text(
|
||||
work_order_no="WO202609200005", quote=q, business_line="LAND"
|
||||
)
|
||||
self.assertIn("费用合计:CNY 121.00", text)
|
||||
self.assertNotIn("总销售价", text)
|
||||
scheme = copy.scheme_wecom_payload(
|
||||
work_order_no="WO202609200005",
|
||||
facts={"origin": "泉州市", "destination": "南京市"},
|
||||
@@ -575,7 +581,9 @@ class QuoteAdjustTests(unittest.TestCase):
|
||||
transport_mode="陆运",
|
||||
)
|
||||
self.assertEqual(scheme["template_card"]["source"]["desc"], "TMS标准报价")
|
||||
self.assertIn("费用合计:CNY 121.00", scheme["template_card"]["quote_area"]["quote_text"])
|
||||
# 方案卡不再放引用条或字段行,只留短标题和三个按钮。
|
||||
self.assertNotIn("quote_area", scheme["template_card"])
|
||||
self.assertNotIn("horizontal_content_list", scheme["template_card"])
|
||||
deal = copy.deal_horizontal_rows(quote=q, business_line="LAND")
|
||||
self.assertEqual(deal[0]["keyname"], "费用合计")
|
||||
|
||||
@@ -639,9 +647,14 @@ class QuoteAdjustTests(unittest.TestCase):
|
||||
detail = copy.sea_tms_hit_wecom_payload(
|
||||
work_order_no="WO202609200004", quote=q, business_line="LAND"
|
||||
)
|
||||
self.assertEqual(detail["template_card"]["source"]["desc"], "销售调价")
|
||||
self.assertIn("费用合计:CNY 121.00", detail["template_card"]["quote_area"]["quote_text"])
|
||||
self.assertNotIn("总成本价", detail["template_card"]["quote_area"]["quote_text"])
|
||||
card = detail["template_card"]
|
||||
self.assertEqual(card["source"]["desc"], "销售调价")
|
||||
self.assertNotIn("quote_area", card)
|
||||
text = copy.sea_quote_detail_text(
|
||||
work_order_no="WO202609200004", quote=q, business_line="LAND"
|
||||
)
|
||||
self.assertIn("费用合计:CNY 121.00", text)
|
||||
self.assertNotIn("总成本价", text)
|
||||
scheme = copy.scheme_wecom_payload(
|
||||
work_order_no="WO202609200004",
|
||||
facts={"origin": "泉州市", "destination": "南京市"},
|
||||
@@ -649,7 +662,8 @@ class QuoteAdjustTests(unittest.TestCase):
|
||||
transport_mode="陆运",
|
||||
)
|
||||
self.assertEqual(scheme["template_card"]["source"]["desc"], "销售调价")
|
||||
self.assertIn("费用合计:CNY 121.00", scheme["template_card"]["quote_area"]["quote_text"])
|
||||
self.assertNotIn("quote_area", scheme["template_card"])
|
||||
self.assertNotIn("horizontal_content_list", scheme["template_card"])
|
||||
|
||||
def test_private_eligibility(self) -> None:
|
||||
self.assertEqual(private_session_can_adjust("已报价", True, ""), "")
|
||||
@@ -775,6 +789,93 @@ class QuoteAdjustTests(unittest.TestCase):
|
||||
self.assertTrue(copy.quote_is_tms(sess.tms_quote))
|
||||
self.assertFalse(copy.quote_is_tms(sess.quote))
|
||||
|
||||
def _private_adjust_sess(self):
|
||||
class _Sess:
|
||||
status = "已报价"
|
||||
phase = "wait_collab"
|
||||
work_order_no = "WO202611230001"
|
||||
business_line = "LAND"
|
||||
collab_chat_id = ""
|
||||
wait_version = 1
|
||||
first_or_same = "first"
|
||||
history_work_order_no = ""
|
||||
quote = _quote(("运输费", "1700.00", "CNY"), total="1700.00")
|
||||
tms_quote = {}
|
||||
|
||||
class _Flow:
|
||||
def __init__(self) -> None:
|
||||
class _Ledger:
|
||||
def upsert_product_quote(self, **kwargs):
|
||||
return {"ok": True}
|
||||
|
||||
self.ledger = _Ledger()
|
||||
|
||||
def _save(self, sess) -> None:
|
||||
pass
|
||||
|
||||
def _emit_sea_hit(self, reply, **kwargs) -> None:
|
||||
pass
|
||||
|
||||
return _Sess(), _Flow()
|
||||
|
||||
def test_private_adjust_waits_for_confirm(self) -> None:
|
||||
"""产品 2026-11-24:调价先回识别回执,回「确认」后才改价。"""
|
||||
import os
|
||||
|
||||
os.environ["QUOTE_CONFIRM_ENABLED"] = "true"
|
||||
try:
|
||||
from agent.policy.quote_adjust_ops import try_private_adjust
|
||||
|
||||
sess, flow = self._private_adjust_sess()
|
||||
sess.sender_id = "u_sales"
|
||||
replies: list[str] = []
|
||||
out = try_private_adjust(flow, sess, "运输费提升到150", replies.append)
|
||||
self.assertEqual(out, "adjust_confirm_pending")
|
||||
self.assertIn("我识别内容为", "\n".join(replies))
|
||||
self.assertEqual(float(str(sess.quote.get("total"))), 1700.0)
|
||||
replies2: list[str] = []
|
||||
out2 = try_private_adjust(flow, sess, "确认", replies2.append)
|
||||
self.assertEqual(out2, "wait_collab")
|
||||
self.assertEqual(float(str(sess.quote.get("total"))), 150.0)
|
||||
finally:
|
||||
os.environ["QUOTE_CONFIRM_ENABLED"] = "false"
|
||||
|
||||
def test_private_adjust_partial_recognized_prompts_format(self) -> None:
|
||||
"""「运输费上调」没说幅度:回「我识别内容为…」并给调价格式。"""
|
||||
from agent.policy.quote_adjust_ops import try_private_adjust
|
||||
|
||||
sess, flow = self._private_adjust_sess()
|
||||
replies: list[str] = []
|
||||
out = try_private_adjust(flow, sess, "运输费上调", replies.append)
|
||||
self.assertEqual(out, "adjust_partial_recognized")
|
||||
body = "\n".join(replies)
|
||||
self.assertIn("我识别内容为", body)
|
||||
self.assertIn("费用名:运输费", body)
|
||||
self.assertIn("调整方式:上调", body)
|
||||
self.assertIn("调整幅度或目标金额", body)
|
||||
self.assertIn("海运费上调10%", body)
|
||||
|
||||
def test_private_adjust_none_recognized_prompts_format(self) -> None:
|
||||
"""「报价调整一下」完全没信息:回无法识别 + 调价格式。"""
|
||||
from agent.policy.quote_adjust_ops import try_private_adjust
|
||||
|
||||
sess, flow = self._private_adjust_sess()
|
||||
replies: list[str] = []
|
||||
out = try_private_adjust(flow, sess, "报价调整一下", replies.append)
|
||||
self.assertEqual(out, "adjust_not_recognized")
|
||||
self.assertIn("我无法识别您的内容", replies[-1])
|
||||
self.assertIn("海运费上调10%", replies[-1])
|
||||
|
||||
def test_private_adjust_chatter_still_falls_through(self) -> None:
|
||||
"""「这个价格再谈谈」不是调价,不能乱回调价提示。"""
|
||||
from agent.policy.quote_adjust_ops import try_private_adjust
|
||||
|
||||
sess, flow = self._private_adjust_sess()
|
||||
replies: list[str] = []
|
||||
out = try_private_adjust(flow, sess, "这个价格再谈谈", replies.append)
|
||||
self.assertIsNone(out)
|
||||
self.assertEqual(replies, [])
|
||||
|
||||
def test_private_air_adjust_emits_facts_so_cargo_not_blank(self) -> None:
|
||||
"""空运私聊调价出卡必须带 sess.facts,否则起运地/品名会整段变「-」。"""
|
||||
from agent.policy.quote_adjust_ops import try_private_adjust
|
||||
|
||||
Reference in New Issue
Block a user