协同群改为智价通BOT接管对话,报价单按需生成;补客户名称、计费重与陆运报价条件

为什么改:应用建的协同群只能代答,销售在群里发文件、@人、问报价都对不上人;
本次把群对话交给智价通BOT,应用只负责拉群和解散群,并把几处销售已反馈的口径补齐。

群与身份:
- 新增 group_bot 短协调(Redis 带环境前缀):记录 BOT 已接管群、当前关联工单、
  @BOT 指令窗口与窗口外先到的附件,只做协调不当六态,六态仍在主账。
- 群里没有 @BOT 的文字不回;非 @ 文字断开当前单关联,之后必须重新 @BOT 带工单号。
- 先发文件再 @BOT 也认:窗口外附件先缓冲,等 @BOT 认领后补办。
- 会话存档只补附件、不重复办理 BOT 已办的同一句文字,避免同一条消息回两遍。
- 入站 from.userid 是加密 open_userid 时按官方接口换明文(带 Redis 缓存),
  否则与主账 sales_wecom_id 永远比不上,航线本人会被判成「不是本人」。
- 桥侧只认本群 req_id,不再借用别的群 req_id,避免测服把话发进别的群。

报价单:
- 建群后只发字段摘要和成交卡,Excel/PDF 等群里 @BOT 说「生成报价单」再出;
  多段逐段出,没价出空白表;出表后补推成交跟进不涨 deal_version、不重置等待计时。
- 陆运转人工先选业务类型和报价场景再建群,按选定模板名直取,不再靠关键词猜。
- 空运舱位只回一条时直接出该条报价,不再发选择卡。

字段与金额:
- 客户名称改为海/空/陆询价非必填,有值写回工单列,后台列表、报价单与 factsJson 一致。
- 空运新增计费重投影:体积重=CBM×166.7,计费重=max(毛重,体积重);
  TMS 无价、航线手工按 KG 报价时按计费重×单价算整票金额,群摘要与报价单同公式。
- 陆运报价附加条件统一到 land_quote_condition:未含税/含0税/未含燃油/含燃油费,
  燃油只乘主运费,不乘提货送货报关等杂费;跨境整车无备注列时追加到底部备注事项。
- 海运拼柜不适用箱型箱量:不进必填、不进补问、不出站,改回整柜可再用。
- 海运提货地址/派送地址改为非必填,写了才出站(placeOfReceipt/deliveryAddress),
  禁止从港口或贸易条款反推地址;TMS 查不到价时把 TMS 原话透给销售。
- 中港集拼与跨境集拼同口径:按体积+毛重,不采车型数量;修正被国内拼车别名抢单。
- 报关费区只收报关类费目;口岸海关监管费+接驳费按车型列回填固定行。

主账与后台:
- 看板处理量按协同群处理人统计;下线「平均报价销售额」;处理人搜索先把姓名换回企微 id。
- 「转人工」筛选同时兼容旧六态与新 collab_mode=handoff,新版单不再漏。
- 报价单客户名称、提货/派送地址、空运计费重、拼柜空箱型按新口径填表。
- 新增协同成员查询支持与 AIR_NEED_WO v2 迁移脚本。

文档:04 补海运/空运/陆运必填与地址口径,10 补地址出站规则,12 补测服独立应用 1000015 的部署与切换记录。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
linmianxun
2026-11-23 14:18:22 +08:00
co-authored by Cursor
parent b3637f3fc4
commit d9b2029c47
102 changed files with 11216 additions and 870 deletions
+158 -3
View File
@@ -266,7 +266,8 @@ class QuoteAdjustTests(unittest.TestCase):
self.assertEqual(str(got.quote["total"]), "2000")
self.assertTrue(got.currency_hint)
def test_multi_currency_line_does_not_change_total(self) -> None:
def test_multi_currency_same_ccy_line_updates_total(self) -> None:
"""总价是 CNY 时,改 CNY 行可以进合计;外币行才需要提示不做汇率。"""
src = _quote(
("提货费", "100", "USD"),
("空运费", "2000", "CNY"),
@@ -279,8 +280,8 @@ class QuoteAdjustTests(unittest.TestCase):
names = {r["name"]: r["amount"] for r in got.quote["fee_rows"]}
self.assertEqual(names["空运费"], "2200.00")
self.assertEqual(names["提货费"], "100")
self.assertEqual(str(got.quote["total"]), "2000")
self.assertTrue(got.currency_hint)
self.assertEqual(str(got.quote["total"]), "2200.00")
self.assertFalse(got.currency_hint)
def test_multi_currency_total_only_changes_total(self) -> None:
src = _quote(
@@ -344,6 +345,61 @@ class QuoteAdjustTests(unittest.TestCase):
self.assertEqual(names["箱单费"], "210.00")
self.assertEqual(got.quote["fee_total_polCostItems"], "1344.00")
def test_sea_bucket_lines_recompute_subtotals_and_total(self) -> None:
"""海运混币种:改美元海运费后,人民币小计与合计都要自动增长。"""
src = {
"currency": "CNY",
"total": "6952.77",
"fee_lines": [
{"name": "订舱费(DCF)", "amount": "500.00", "currency": "CNY"},
{"name": "操作费", "amount": "520.00", "currency": "CNY"},
{"name": "舱单", "amount": "50.00", "currency": "CNY"},
{"name": "海运费", "amount": "1250.00", "currency": "USD"},
{"name": "文件费", "amount": "450.00", "currency": "CNY"},
{"name": "设备费", "amount": "30.00", "currency": "CNY"},
],
"polCostItems": [
{"name": "订舱费(DCF)", "amount": "500.00", "currency": "CNY"},
{"name": "操作费", "amount": "520.00", "currency": "CNY"},
{"name": "舱单", "amount": "50.00", "currency": "CNY"},
],
"oceanCostItems": [
{"name": "海运费", "amount": "1250.00", "currency": "USD"},
],
"podCostItems": [
{"name": "文件费", "amount": "450.00", "currency": "CNY"},
{"name": "设备费", "amount": "30.00", "currency": "CNY"},
],
"fee_total_polCostItems": "1070.00",
# TMS 口径:USD 1250 × 7.023 = 8778.75 CNY
"fee_total_oceanCostItems": "8778.75",
"fee_total_podCostItems": "480.00",
}
ext = AdjustExtract(
is_adjust=True,
items=[
AdjustItem("订舱费(DCF)", "target", "set", 585),
AdjustItem("海运费", "target", "set", 1330),
],
)
got = apply_adjust(src, ext, business_line="SEA")
self.assertTrue(got.ok)
self.assertEqual(got.quote["fee_total_polCostItems"], "1155.00")
self.assertEqual(got.quote["fee_total_oceanCostItems"], "9340.59")
self.assertEqual(got.quote["fee_total_podCostItems"], "480.00")
self.assertEqual(got.quote["total"], "7599.61")
self.assertFalse(got.currency_hint)
def test_local_extract_accepts_currency_before_target_amount(self) -> None:
"""「提高到CNY 585.00」本地回退也要能抽,不能因为币种夹在动词和数字中间就放弃。"""
names = ["订舱费(DCF)", "操作费", "舱单", "海运费", "文件费", "设备费"]
text = "始发港费用\n订舱费(DCF)提高到CNY 585.00\n海运费\n海运费提高到USD 1330.00"
got = extract_adjust(text, fee_names=names, allow_model=False)
self.assertTrue(got.is_adjust)
items = {(x.fee_name, x.kind, x.value) for x in got.items}
self.assertIn(("订舱费(DCF)", "target", 585.0), items)
self.assertIn(("海运费", "target", 1330.0), items)
def test_sea_pol_subtotal_and_total_up_ten_percent(self) -> None:
"""协同话术:始发港费用小计 + 费用合计 各提升 10%。"""
src = {
@@ -888,6 +944,105 @@ class SheetPriceStampTests(unittest.TestCase):
self.assertIn("28150", str(selected["legs"][0]["costPrice"]))
self.assertIn("28150", str(got.quote["feeItems"][0]["amount"]))
def test_product_merge_recomputes_sea_subtotals_and_total(self) -> None:
"""产品按行改海运混币种价:三段小计和合计都要跟销售调价一样自动增长。"""
from agent.policy.sea_group_ops import merge_quote_fees
base = {
"source": "TMS",
"source_label": "TMS标准报价",
"business_line": "SEA",
"currency": "CNY",
"total": "6952.77",
"fee_lines": [
{"name": "订舱费(DCF)", "amount": "500.00", "currency": "CNY"},
{"name": "操作费", "amount": "520.00", "currency": "CNY"},
{"name": "舱单", "amount": "50.00", "currency": "CNY"},
{"name": "海运费", "amount": "1250.00", "currency": "USD"},
{"name": "文件费", "amount": "450.00", "currency": "CNY"},
{"name": "设备费", "amount": "30.00", "currency": "CNY"},
],
"polCostItems": [
{"name": "订舱费(DCF)", "amount": "500.00", "currency": "CNY"},
{"name": "操作费", "amount": "520.00", "currency": "CNY"},
{"name": "舱单", "amount": "50.00", "currency": "CNY"},
],
"oceanCostItems": [
{"name": "海运费", "amount": "1250.00", "currency": "USD"},
],
"podCostItems": [
{"name": "文件费", "amount": "450.00", "currency": "CNY"},
{"name": "设备费", "amount": "30.00", "currency": "CNY"},
],
"fee_total_polCostItems": "1070.00",
"fee_total_oceanCostItems": "8778.75",
"fee_total_podCostItems": "480.00",
}
got = merge_quote_fees(
base,
{
"source_label": "产品报价",
"currency": "CNY",
"fee_lines": [
{"name": "订舱费(DCF)", "amount": "585.00", "currency": "CNY"},
{"name": "海运费", "amount": "1330.00", "currency": "USD"},
],
},
)
self.assertEqual(got["fee_total_polCostItems"], "1155.00")
self.assertEqual(got["fee_total_oceanCostItems"], "9340.59")
self.assertEqual(got["fee_total_podCostItems"], "480.00")
self.assertEqual(got["total"], "7599.61")
def test_manual_currency_follows_into_sheet_copies(self) -> None:
"""2026-11-22 真机:产品报「文件费USD 60」,报价单副本必须写 USD,不能留 TMS 的 CNY。"""
from agent.policy.sea_group_ops import merge_quote_fees
from agent.schema.quote_adjust import stamp_prices_for_sheet
base = {
"source": "TMS",
"currency": "CNY",
"total": "480",
"fee_lines": [{"name": "文件费", "amount": "450", "currency": "CNY"}],
"podCostItems": [{"name": "文件费", "amount": "450", "currency": "CNY"}],
"fee_total_podCostItems": "450",
}
merged = merge_quote_fees(
base,
{
"source_label": "产品报价",
"currency": "USD",
"fee_lines": [{"name": "文件费", "amount": "60.00", "currency": "USD"}],
},
)
pod = [x for x in merged["podCostItems"] if x.get("name") == "文件费"]
self.assertEqual(pod[0]["currency"], "USD")
self.assertEqual(pod[0]["amount"], "60.00")
air = stamp_prices_for_sheet(
{
"source_label": "产品报价",
"currency": "USD",
"total": "60",
"fee_lines": [{"name": "文件费", "amount": "60", "currency": "USD"}],
"airOptions": [
{"departureCharges": [{"chargeName": "文件费", "amount": "450", "currency": "CNY"}]}
],
}
)
self.assertEqual(air["airOptions"][0]["departureCharges"][0]["currency"], "USD")
land = stamp_prices_for_sheet(
{
"source_label": "产品报价",
"currency": "USD",
"total": "60",
"fee_lines": [{"name": "运输费", "amount": "60", "currency": "USD"}],
"landSegments": [{"origin": "A", "destination": "B", "costPrice": "450", "currency": "CNY"}],
}
)
self.assertEqual(land["landSegments"][0]["currency"], "USD")
def test_product_and_airline_sheet_copies_follow_new_fee(self) -> None:
from agent.policy.sea_group_ops import merge_quote_fees
from agent.schema.quote_adjust import stamp_prices_for_sheet