texts.py 52 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
"""库存补货的默认话术 / 提示词(Jinja2)。后台「智能助手 → 话术模板」可以修改,这里只是代码默认值。

定时补货的清单只在单据页出现一次:群里只推一句「补货推荐已生成,点开确认」,不再列清单(两处出现容易不一致)。
定时补货不能在群里发起 / 确认:清单确认、建单后的「确认提交」都在单据页上点。
会话里只做单次补货(群里必须 @ 机器人;一个会话 = 一个用户,群里谁 @ 都算):「零件号 数量」→ 回「订」建单截图
→ 回「确认提交」提交(回「不提交」先不下单)。每个会话同时只处理一单,消息只发回所属会话。
单次补货建单结果未知 → 建单异常:会话里暂停一切补货操作,系统自动到 DMS 按备注单号核实,已建成就接管,没建成回到待确认。
定时补货建单结果未知:页面再确认时先到 DMS 核实,已建成就接管,没建成才重新建。
回复里的仓库名用「广州仓 / 华南仓」(planner.wh_label),不用 DMS 原名「GTMC广州 / 华南GTMC」。
"""
from __future__ import annotations

from ...services.texts import TextDef

T = TextDef
_S = {"order_count": 6, "order_qty": 53, "amount": 3842.6, "total": 50, "stock_count": 6, "other_count": 44,
      "errors": [], "need_count": 6}
_LINK = "https://restock.example.com/m/restock/order/xxxx"
_L = {"part_no": "8713902280", "name": "空调滤清器滤芯分总成", "stock": 6, "in_transit": 2, "cap": 30, "final_qty": 2,
      "suggested": 2, "unit_price": 53.3, "amount": 106.6, "tag": "normal", "note": "", "mad": 15.3,
      "wh": {"GTMC广州": 0, "华南GTMC": 1095}, "wh_cn": {"广州仓": 0, "华南仓": 1095}}
_WH = {"广州仓": 0, "华南仓": 1095}
_Q = {"part_no": "8713902280", "name": "空调滤清器滤芯分总成", "stock": 6, "in_transit": 2, "in_transit_label": "在途数量",
      "cap": 30, "unit_price": 53.3, "wh": {"广州仓": 0, "华南仓": 1095}, "oos": False, "error": ""}
_SUB = [{"part_no": "8713902280", "name": "空调滤清器滤芯分总成", "qty": 2, "amount": 106.6}]

TEXTS = [
    # ---------------------------------------------------------------- 技能提示词片段(后台「智能助手 → 技能」可改)
    T("restock.skill.single", "prompt", "提示词", "技能提示词:单次补货",
      "1. 计划员发「零件号 数量」(如「041520V010*10」「帮我订 8713902280 2个」)→ 调 single_restock 查询,"
      "查询结果会自动发到这个会话,并问要不要订。\n"
      "2. 查询结果发出后,表示同意(订、定(「订」的错别字)、好、行、可以、没问题、ok、下单、就这样、"
      "没毛病、整吧……任何口语化的同意)→ 调 confirm_order:在 DMS 建成待提交的采购单并截图,不会提交。\n"
      "3. 建单后要正式提交:只有原话正好是「提交」或「确认提交」才会提交(调 submit_order);"
      "其他说法(「提交吧」「可以提交」「好的」)都不会提交,系统会提示他回「确认提交」。\n"
      "4. 表示不要了(不订、不要了、取消、算了、不提交)→ 调 cancel_order。本会话没有单时也照样调,它会自己回复该说的话"
      "(比如定时补货的单据页链接)。\n"
      "5. 问自己这单到哪了(单次补货的进度)→ 调 single_status。\n"
      "6. 本会话没有进行中的单次补货时,只回「订」「确认」这类话:看聊天记录,刚查过某个零件且说了数量(如「那订 2 个」)"
      "→ 用聊天记录里的零件号调 single_restock;没说数量就问他要订几个(不要在回复里写零件号)。\n"
      "7. 本会话单次补货的状态是「建单异常」时任何操作都不会执行,照常调对应工具即可(系统会回复正在核实)。\n"
      "8. 群里所有「订 / 确认 / 提交 / 取消」都只针对本会话的单次补货;定时补货在群里不能操作。",
      hint="拼在通用提示词后面,作为「单次补货」这一节;技能停用时不拼。"),
    T("restock.skill.part_query", "prompt", "提示词", "技能提示词:查库存",
      "1. 只是想问某个零件的库存 / 有没有货 / 在途 / 今天还能订多少(话里有零件号,没说要订几个)→ 调 query_part,"
      "只查不订,查询结果会自动发到这个会话。\n"
      "{% if 'restock.single' in skills %}2. 话里有零件号和数量、明确要订 → 不是查询,按单次补货处理。\n"
      "3. 查完之后对方接着说「那订 2 个」「来 3 个」→ 从聊天记录里的查询结果取零件号,调 single_restock。"
      "{% else %}2. 现在没有开通单次补货:想订货的,告诉他请联系配件计划员在 DMS 下单。{% endif %}",
      ("skills",), {"skills": ["restock.part_query", "restock.single"]},
      hint="拼在通用提示词后面,作为「查库存」这一节;技能停用时不拼。skills 是已启用的技能代码列表。"),
    T("restock.skill.scheduled", "prompt", "提示词", "技能提示词:定时补货",
      "定时补货每天自动推送,清单确认、确认提交、今天不订 / 先不提交都只能在单据页上点,群里不能操作。\n"
      "1. 问今天定时补货到哪一步了 → 调 scheduled_status。\n"
      "2. 想在群里发起、确认、提交或取消定时补货(如「今天的补货确认一下」「定时补货不订了」)→ 调 scheduled_link"
      "(取消时 cancel=true),回复单据页链接,不会改任何单据。\n"
      "3. 只说「订 / 确认 / 提交」、没提定时补货的,按单次补货处理,不要调这里的工具。",
      hint="拼在通用提示词后面,作为「定时补货」这一节;技能停用时不拼。"),
    # ---------------------------------------------------------------- 查库存
    T("restock.msg_part_querying", "message", "查库存", "收到查库存,开始查",
      "收到,查一下 {{ part_no }} 的库存…", ("part_no",), {"part_no": "8713902280"}),
    T("restock.msg_part_query", "message", "查库存", "查库存结果",
      "查到 {{ r.part_no }} {{ r.name }}\n————————\n"
      "{% if r.wh %}{% for w, q in r.wh.items() %}{{ w }} {{ '%g'|format(q) }}{% if not loop.last %} · {% endif %}"
      "{% endfor %}\n{% endif %}"
      "当前库存 {{ '%g'|format(r.stock) }} · {{ r.in_transit_label }} {{ '%g'|format(r.in_transit) }}\n"
      "当日剩余可订 {{ r.cap if r.cap is not none else '不限' }}"
      "{% if r.unit_price %}\n单价 ¥{{ '%.2f'|format(r.unit_price) }}{% endif %}\n————————\n"
      "{% if r.oos %}关注仓都没货(厂家缺货),现在订不了。"
      "{% else %}👉 要订就 @我 发「{{ r.part_no }} 数量」{% endif %}",
      ("r",), {"r": _Q}, "r.wh 里的仓库名已经换成「广州仓 / 华南仓」。"),
    T("restock.msg_part_query_failed", "message", "查库存", "查库存失败",
      "{{ part_no }} 没查到:{{ reason }}", ("part_no", "reason"), {"part_no": "8713902280", "reason": "门店取数端不在线"}),
    T("restock.msg_part_query_limited", "message", "查库存", "查得太频繁",
      "查得有点快,每分钟最多查 {{ n }} 次,稍等一下再问。", ("n",), {"n": 6}),
    T("restock.msg_part_query_usage", "message", "查库存", "格式提示",
      "要查库存请 @我 发「零件号 有货吗」,例如:8713902280 有货吗"),
    T("restock.msg_start", "message", "定时补货", "开始取数",
      "{% if trigger == 'schedule' %}⏰ 到点了,{% else %}🔧 后台手动执行补货,{% endif %}"
      "正在拉今天的出库明细、算补货推荐({{ cutoff }} 截单),{{ eta }}",
      ("now", "cutoff", "trigger", "eta"), {"now": "15:00", "cutoff": "16:00", "trigger": "schedule", "eta": "大概 3 分钟"}),
    T("restock.msg_list", "message", "定时补货", "补货推荐已生成(推链接)",
      "📦 今天的定时补货推荐已生成(出库 {{ window }},共 {{ s.total }} 种纯牌零件,其中常备件 {{ s.stock_count }} 种)\n"
      "请点开链接确认,不确认不会生成采购单 👉\n{{ link }}\n{{ cutoff }} 截单",
      ("window", "s", "link", "cutoff"), {"window": "10/27 15:00 — 10/28 15:00", "s": _S, "link": _LINK, "cutoff": "16:00"},
      "清单只在单据页出现,群里只推一句,避免两处不一致。"),
    T("restock.drafts_hint", "message", "定时补货", "未提交采购单提示(拼在推送 / 进度回复后面)",
      "{% if d['items'] %}⚠️ DMS 里还有 {{ d['items']|length }} 张没提交的采购单(含他人创建的),不参与本次计算,确认前请留意别重复订:\n"
      "{% for it in d['items'][:10] %}· {% if it.order_no %}{{ it.order_no }}{% else %}(没有采购单号){% endif %}"
      "{% if it.doc_no %}(本系统 {{ it.doc_no }}){% endif %}"
      "{% if it.create_by %} {{ it.create_by }}{% endif %}{% if it.create_time %} {{ it.create_time[5:16] }}{% endif %}"
      "{% if it.lines is not none %} · {{ it.lines|length }} 项{% endif %}{% if it.note %} · {{ it.note }}{% endif %}"
      "{% if it.link %} 👉 {{ it.link }}{% endif %}"
      "{% if not loop.last %}\n{% endif %}{% endfor %}"
      "{% if d['items']|length > 10 %}\n…其余 {{ d['items']|length - 10 }} 张见单据页{% endif %}"
      "{% if d.truncated %}\n(待提交的单比较多,只有前 50 张取了明细,其余没标零件,请到 DMS「采购订单管理」核对){% endif %}"
      "{% if d.error %}\n{% endif %}{% endif %}"
      "{% if d.error %}ℹ️ {{ d.error }}{% endif %}",
      ("d",), {"d": {"items": [{"order_no": "S20261104008", "doc_no": "", "create_by": "张三",
                                "create_time": "2026-11-04 10:12:00", "lines": [{}, {}], "note": ""},
                               {"order_no": "", "doc_no": "RP-20261103-1-01", "create_by": "邹新",
                                "create_time": "2026-11-03 15:20:00", "lines": [{}], "note": "建单结果未知"}],
                     "error": "", "truncated": False}},
      "d['items'] 每张:order_no 采购单号 / doc_no 本系统补货单号(不是本系统建的为空)/ create_by 创建人 / create_time 创建时间 / "
      "lines 明细 / note 说明;d.error 没能查 DMS 的原因"),
    T("restock.late_hint", "message", "提醒与截单", "截单风险提示(拼在消息后面)",
      "{% if after %}⏰ 已过截单时间 {{ cutoff }},仍可确认 / 提交,但实际提交时间会超过截单时间。"
      "{% else %}⏰ 离截单 {{ cutoff }} 只剩 {{ minutes }} 分钟,时间已经不多,系统创建 / 提交订单可能会错过截单时间。{% endif %}",
      ("after", "cutoff", "minutes"), {"after": False, "cutoff": "16:00", "minutes": 12},
      "截单只提示风险、不拦操作;离截单不到「截单前紧急告警」分钟数或已过截单时才拼上。"),
    T("restock.stale_hint", "message", "定时补货", "不是今天的清单",
      "ℹ️ 这是 {{ biz_date }} 的补货清单({{ doc }}),下一张定时补货单生成时作废;确认前请先刷新拿最新库存。",
      ("biz_date", "doc"), {"biz_date": "11月08日", "doc": "RP-20261108-1-01"}),
    T("restock.msg_stale_superseded", "message", "定时补货", "新单生成时作废之前没确认的清单",
      "ℹ️ 之前没确认的定时补货清单 {{ old }} 已作废,以这张新单 {{ doc }} 为准。",
      ("doc", "old"), {"doc": "RP-20261109-1-01", "old": "RP-20261108-1-01"}),
    T("restock.msg_no_candidates", "message", "定时补货", "窗口内没有纯牌出库",
      "📦 今天(出库 {{ window }})没有纯牌零件出库,不用补货。", ("window", "stats"),
      {"window": "10/27 15:00 — 10/28 15:00", "stats": {}}),
    T("restock.msg_busy", "message", "定时补货", "上一轮还在进行中", "上一轮还没跑完({{ stage }}),好了我叫你。",
      ("stage",), {"stage": "取数中"}),
    T("restock.msg_already_ordered", "message", "定时补货", "今天已经下过单",
      "今天的定时补货已经建过采购单 {{ order_no }}(一天只建一次)。\n单据:{{ link }}", ("order_no", "link"),
      {"order_no": "S2026102701", "link": _LINK}),
    T("restock.msg_scheduled_use_link", "message", "定时补货", "群里回确认(定时补货必须走页面)",
      "{% if items and items|length > 1 %}⚠️ 现在有 {{ items|length }} 张定时补货单(一般一天只有一张,请留意别重复订),"
      "{% if cancel %}请在对应链接里操作:待确认提交的点「先不提交」,待确认的点「今天不订」"
      "{% else %}群里回复不会提交,请分别点开链接核对:待确认提交的点「确认提交」,待确认的先确认清单{% endif %}\n"
      "{% for it in items %}{{ loop.index }}. {{ it.doc_no }}({{ it.trigger_cn }}"
      "{% if it.biz_date %},{{ it.biz_date }}{% endif %},{{ it.stage_cn }}"
      "{% if it.order_no %},采购单 {{ it.order_no }}{% endif %})👉 {{ it.link }}"
      "{% if not loop.last %}\n{% endif %}{% endfor %}"
      "{% elif cancel %}定时补货请在链接页面里点"
      "{% if stage == 'awaiting_submit' %}「先不提交」{% else %}「今天不订」{% endif %}👉 {{ link }}"
      "{% elif stage == 'awaiting_submit' %}定时补货的采购单 {{ order_no }} 请点开链接核对,没问题点「确认提交」,"
      "群里回复不会提交 👉\n{{ link }}"
      "{% else %}定时补货请点开链接确认清单,不确认不会生成采购单 👉\n{{ link }}{% endif %}",
      ("link", "stage", "order_no", "items", "cancel"),
      {"link": _LINK, "stage": "awaiting_submit", "order_no": "S20261104009", "cancel": False,
       "items": [{"doc_no": "RP-20261104-1-01", "trigger_cn": "手动补充", "biz_date": "", "stage_cn": "待确认提交",
                  "order_no": "S20261104008", "link": _LINK},
                 {"doc_no": "RP-20261104-1-02", "trigger_cn": "定时推送", "biz_date": "", "stage_cn": "待确认提交",
                  "order_no": "S20261104009", "link": _LINK}]},
      "items 是要给链接的全部定时补货单(两张及以上时逐张列出);cancel = 群里说不订 / 不提交时"),
    T("restock.msg_scheduled_no_chat", "message", "定时补货", "群里要发起定时补货",
      "定时补货每天 {{ push_time }} 自动推送,不能在群里发起。\n\n"
      "👉 要单独补某个零件,@我 发「零件号 数量」,例如:8713902280 2个",
      ("push_time",), {"push_time": "15:00"}),
    T("restock.msg_cancelled", "message", "定时补货", "今天不订", "好,今天的定时补货不订了。"),
    T("restock.msg_confirmed", "message", "建单", "确认后开始建单",
      "✅ {{ by }} 已确认,正在 DMS 建单\n{{ s.order_count }} 项 · {{ s.order_qty }} 件,{{ eta }}", ("s", "by", "eta"),
      {"s": _S, "by": "邹新", "eta": "大概 3 分钟"}),
    T("restock.msg_recover_shot", "message", "建单", "云端重启时正在截图(采购单已建好)",
      "⚠️ 系统重启时采购单 {{ order_no }} 正在截图,截图没发出来,但单已经在 DMS 建好(待提交)。\n"
      "请点开链接核对明细(或到 DMS「采购订单管理」看这张单),没问题点「确认提交」 👉\n{{ link }}",
      ("order_no", "doc", "link"), {"order_no": "S20261104009", "doc": "RP-20261104-1-01", "link": _LINK}),
    T("restock.msg_po_done", "message", "建单", "建单完成回执(等确认提交)",
      "✅ 单建好了:{{ order_no }}(待提交)\n\n"
      "{{ count }} 项 · {{ qty }} 件 · 约 ¥{{ '%.2f'|format(amount) }}"
      "{% if shots and not shot_err %} · 截图 {{ shots }} 张在上面{% if fallback %}(接口数据渲染){% endif %}{% endif %}\n"
      "————————\n"
      "{% if not can_submit %}提交功能已关闭,请到 DMS 核对后人工提交"
      "{% elif kind == 'scheduled' %}请点开链接核对,没问题点「确认提交」(不过期,提交前会先查 DMS 状态) 👉\n{{ link }}"
      "{% else %}请核对截图\n\n"
      "👉 没问题 @我 回「确认提交」\n"
      "👉 不要了 @我 回「不提交」{% endif %}"
      "{% if mismatch %}\n⚠️ DMS 回查明细与请求不一致:{{ mismatch }}{% endif %}"
      "{% if shot_err %}{% if kind == 'scheduled' %}\n❌ 截图没发出去:{{ shot_err }}。采购单已经建好,需要人工核对:"
      "请点链接或到 DMS「采购订单管理」核对明细后再确认提交\n详情:{{ link }}"
      "{% else %}\n❌ 截图没发出去:{{ shot_err }},请到 DMS 核对后再确认\n详情:{{ link }}{% endif %}{% endif %}"
      "{% if late %}\n{{ late }}{% endif %}",
      ("kind", "order_no", "count", "qty", "amount", "shots", "fallback", "shot_err", "mismatch", "link",
       "can_submit", "owner", "late"),
      {"kind": "single", "order_no": "S20261104009", "count": 1, "qty": 2, "amount": 106.6, "shots": 2, "fallback": "",
       "shot_err": "", "mismatch": "", "link": _LINK, "can_submit": True, "owner": "邹新", "late": ""},
      "单号紧跟「单建好了」;定时补货在单据页确认提交,单次补货在会话里 @机器人 回「确认提交」(谁回都行)。"),
    T("restock.msg_shot_fallback", "message", "建单", "DMS 截图失败的兜底说明",
      "⚠️ 因系统问题,DMS 页面截图失败({{ reason }})。\n"
      "{% if mode == 'image' %}下面 {{ n }} 张是用 DMS 接口实际返回的数据渲染出来的截图,不是 DMS 原页面,仅供核对。"
      "{% else %}也没能生成兜底图片,以下是 DMS 接口实际返回的采购单明细:\n{{ details }}{% endif %}",
      ("mode", "reason", "n", "details"),
      {"mode": "image", "reason": "浏览器登录超时", "n": 2, "details": "· 8713902280 空调滤清器滤芯分总成 ×2 ¥106.6"}),
    T("restock.msg_po_failed", "message", "建单", "建单失败",
      "❌ 建单没成功:{{ reason }}\n"
      "{% if unknown %}结果不确定:DMS 里可能已经建成。为防止重复建单,系统已暂停,不会自动重试。\n"
      "{% if kind == 'single' %}已转人工处理:请到 DMS「采购订单管理」按备注里的单号 {{ doc }} 核实。"
      "{% else %}请不要到 DMS 手工重建:系统 {{ wait_min }} 分钟后自动到 DMS 按单号 {{ doc }} 核实,"
      "已经建成就直接用那张单(发截图等你确认提交),没建成会在群里通知,到时在页面刷新后再确认。"
      "如果一直没有核实结果,需要人工介入:请到 DMS「采购订单管理」按备注里的单号 {{ doc }} 查一下。{% endif %}"
      "{% elif kind == 'single' %}DMS 里没建成。\n\n👉 @我 再回「订」重试"
      "{% else %}DMS 里没建成。需要人工处理:请看上面的原因,在页面刷新后重新确认;"
      "多次失败的话请检查门店取数端,或直接到 DMS 下单。{% endif %}"
      "{% if late %}\n{{ late }}{% endif %}", ("reason", "unknown", "kind", "doc", "wait_min", "late"),
      {"reason": "DMS 返回:供应商代码不存在", "unknown": False, "kind": "scheduled", "doc": "RP-20261027-1-01",
       "wait_min": 2, "late": ""}),
    T("restock.msg_reconcile_wait", "message", "建单", "结果未知后太快再确认",
      "上次建单结果未知,为防止重复建单,请 {{ seconds }} 秒后再确认(我会先到 DMS 核实是否已经建成)。",
      ("seconds",), {"seconds": 75}),
    T("restock.msg_reconciling", "message", "建单", "再确认:先到 DMS 核实",
      "🔎 上次建单结果未知,先到 DMS 按单号 {{ doc }} 核实是否已经建成…", ("doc",), {"doc": "SP-20261028-1-01"}),
    T("restock.msg_po_adopted", "message", "建单", "核实:上次其实已建成(接管)",
      "🔎 核实结果:上次其实已经建成采购单 {{ order_no }},没有重复建单,下面按这张单发截图,请核对。"
      "{% if mismatch %}\n⚠️ 这张单和本次清单不一致:{{ mismatch }}{% endif %}",
      ("order_no", "mismatch"), {"order_no": "S20261104009", "mismatch": ""}),
    T("restock.msg_reconcile_none", "message", "建单", "核实:DMS 里没有建成",
      "{% if kind == 'single' %}🔎 核实完成:没有建成,需要的话 @我 回「订」"
      "{% elif auto %}🔎 自动核实完成:DMS 里没有本单({{ doc }})的采购单,上次没建成,系统不会自动重建。"
      "{% if stage == 'awaiting_confirm' %}还要订的话请在页面刷新后重新确认。{% endif %}"
      "{% else %}🔎 核实结果:DMS 里没有本单({{ doc }})的采购单,开始重新建单。{% endif %}",
      ("doc", "kind", "auto", "stage"), {"doc": "SP-20261028-1-01", "kind": "single", "auto": False, "stage": ""},
      "单次补货(自动核实)没建成时不自动重建,回到待确认;定时补货自动核实没建成只通知;定时补货再确认时核实,没建成接着重建"),
    T("restock.msg_create_unknown", "message", "建单", "单次补货建单异常(结果未知,自动核实)",
      "⚠️ 系统异常({{ reason }}),正在自动核实,暂停补货操作", ("reason", "doc"),
      {"reason": "取数端已领取任务,但 300 秒内没有回传结果", "doc": "SP-20261028-1-01"}),
    T("restock.msg_create_unknown_busy", "message", "建单", "建单异常期间又有操作",
      "⚠️ 系统异常,正在自动核实,暂停补货操作", ("doc",), {"doc": "SP-20261028-1-01"}),
    T("restock.msg_create_unknown_still", "message", "建单", "建单异常一直没核实完(提醒)",
      "⚠️ 系统异常仍在核实(已 {{ minutes }} 分钟),暂停补货操作", ("minutes", "doc"),
      {"minutes": 30, "doc": "SP-20261028-1-01"}),
    T("restock.msg_reconcile_manual", "message", "建单", "核实异常,转人工",
      "❌ 核实异常({{ reason }}),已转人工处理", ("reason", "doc"),
      {"reason": "DMS 里有 2 张本单的采购单(S20261104009、S20261104010)", "doc": "SP-20261028-1-01"}),
    T("restock.msg_unknown_closed", "message", "建单", "建单异常已人工处理",
      "✅ 已人工处理,可以继续补货", ("doc", "by", "conclusion"),
      {"doc": "SP-20261028-1-01", "by": "店长", "conclusion": "DMS 里没有这张单"}),
    T("restock.msg_reconcile_failed", "message", "建单", "核实失败(没有建单)",
      "❌ 到 DMS 核实上次建单结果失败:{{ reason }}\n这次没有建单。\n\n"
      "👉 请稍后{% if kind == 'single' %} @我 再回「订」{% else %}在页面再确认{% endif %}\n"
      "👉 或到 DMS「采购订单管理」人工核实(备注带单号 {{ doc }})",
      ("reason", "kind", "doc"), {"reason": "访问 DMS 网络失败", "kind": "single", "doc": "SP-20261028-1-01"}),
    T("restock.msg_reconcile_multi", "message", "建单", "核实:DMS 里有多张本单的采购单",
      "❌ DMS 里查到 {{ n }} 张本补货单({{ doc }})的采购单:{{ order_nos }}。系统不会建单也不会提交。\n"
      "需要人工介入:请到 DMS「采购订单管理」核对这几张单,保留需要的、删除多余的,再在 DMS 人工提交。",
      ("n", "doc", "order_nos"), {"n": 2, "doc": "SP-20261028-1-01", "order_nos": "S20261104009、S20261104010"}),
    T("restock.msg_unknown_left", "message", "建单", "取消 / 截单时提醒:之前有一次建单结果未知",
      "⚠️ 补货单 {{ doc }} 之前有一次建单结果未知,DMS 里可能已经有采购单(备注带单号 {{ doc }}),请到 DMS 核实后人工处理。",
      ("doc",), {"doc": "SP-20261028-1-01"}),
    T("restock.msg_create_disabled", "message", "建单", "建单开关关闭",
      "{{ kind_cn }}的建单功能已关闭(企业后台 → 取数端 → 运行参数),这次不在 DMS 建单。", ("kind_cn",),
      {"kind_cn": "单次补货"}),
    # ---------------- 提交 ----------------
    T("restock.msg_submitting", "message", "提交", "确认后开始提交",
      "{% if kind == 'scheduled' %}✅ {{ by }} 在单据页确认提交,{% else %}✅ 收到,{% endif %}正在 DMS 提交 {{ order_no }}…"
      "{% if late %}\n{{ late }}{% endif %}",
      ("order_no", "by", "via_cn", "kind", "late"), {"order_no": "S20261104009", "by": "邹新", "via_cn": "企微群里回复",
                                                     "kind": "single", "late": ""}),
    T("restock.msg_po_submitted", "message", "提交", "提交成功回执",
      "已提交 ✅\n——————————————\n"
      "PO 单号 {{ order_no }}\n\n"
      "{% for x in lines[:15] %}{{ x.name or x.part_no }} × {{ '%g'|format(x.qty) }}\n{% endfor %}"
      "{% if lines|length > 15 %}…其余 {{ lines|length - 15 }} 项见单据页\n{% endif %}\n"
      "{% if count > 1 %}共 {{ count }} 项 / {{ '%g'|format(qty) }} 件\n{% endif %}"
      "金额 ¥ {{ '%.2f'|format(amount) }}\n——————————————\n"
      "提交人 {{ by }}\n"
      "状态 已提交{% if already %}(DMS 里之前已经提交过){% endif %}",
      ("kind", "order_no", "lines", "count", "qty", "amount", "by", "confirmed_by", "already", "link"),
      {"kind": "single", "order_no": "S20261104009", "lines": _SUB, "count": 1, "qty": 2, "amount": 106.6,
       "by": "邹新", "confirmed_by": "邹新", "already": False, "link": _LINK},
      "提交人是 DMS 里实际的提交账号(applyOperator);不写预计到货(DMS 不返回)。"),
    T("restock.msg_submit_failed", "message", "提交", "提交失败 / 结果未知",
      "❌ {{ order_no }} 没提交成功:{{ reason }}\n"
      "{% if kind == 'scheduled' %}"
      "{% if unknown %}结果不确定,系统不会自动重试。需要人工介入:请到 DMS「采购订单管理」看 {{ order_no }} 是不是「已提交」:"
      "已提交就不用再管;还是「待提交」的话请在 DMS 人工提交。"
      "{% elif not retry %}DMS 里的单据和建单时不一致(可能被人改过),系统不会提交。需要人工介入:请到 DMS 核对这张单后人工处理。"
      "{% else %}DMS 里仍是「待提交」。需要人工处理:按上面的原因处理好后,在单据页再点「确认提交」,"
      "或直接到 DMS 人工提交 👉\n{{ link }}{% endif %}"
      "{% if late %}\n{{ late }}{% endif %}"
      "{% elif unknown %}结果不确定:请到 DMS「采购订单管理」看它是不是「已提交」,系统不会自动重试。"
      "{% elif not retry %}DMS 里的单据和建单时不一致,系统不会提交,请到 DMS 人工处理。"
      "{% else %}DMS 里仍是「待提交」。处理后:\n\n👉 @我 再回「确认提交」\n👉 或到 DMS 人工提交{% endif %}",
      ("order_no", "reason", "unknown", "retry", "kind", "link", "late"),
      {"order_no": "S20261104009", "reason": "DMS 检查未通过:accountBalanceFlag=false(疑似账户余额不足)",
       "unknown": False, "retry": True, "kind": "single", "link": _LINK, "late": ""}),
    T("restock.msg_submit_cancelled", "message", "提交", "先不提交",
      "好,{{ order_no }} 先不提交。DMS 里这张单还是「待提交」,需要的话请到 DMS 人工删除或提交。",
      ("order_no", "by", "kind"), {"order_no": "S20261104009", "by": "邹新", "kind": "single"}),
    T("restock.msg_po_deleted", "message", "提交", "确认提交时发现 DMS 里的单已被删除",
      "🗑 采购单 {{ order_no }} 在 DMS 里已经被删除了,这次不提交。"
      "{% if kind == 'scheduled' %}今天还要订的话,请等下次推送或在后台「立即执行补货」。"
      "{% else %}\n\n👉 要订请重新 @我 发「零件号 数量」{% endif %}",
      ("order_no", "kind"), {"order_no": "S20261104009", "kind": "single"}),
    T("restock.msg_po_status_other", "message", "提交", "确认提交时发现 DMS 里的单已不是待提交",
      "ℹ️ 采购单 {{ order_no }} 在 DMS 里现在是「{{ status_cn }}」,不是待提交了(可能已经有人在 DMS 处理过),这次不再提交。",
      ("order_no", "status_cn", "kind"), {"order_no": "S20261104009", "status_cn": "已完成", "kind": "single"}),
    T("restock.msg_submit_disabled", "message", "提交", "提交开关关闭",
      "{{ kind_cn }}的提交功能已关闭(企业后台 → 取数端 → 运行参数),没有提交。"
      "DMS 里的 {{ order_no }} 仍是「待提交」,请到 DMS 人工提交。", ("kind_cn", "order_no"),
      {"kind_cn": "单次补货", "order_no": "S20261104009"}),
    T("restock.msg_submit_need_explicit", "message", "提交", "待确认提交时没明确说「提交」",
      "单 {{ order_no }} 已建好、待提交。为防误操作,只有回「确认提交」才会提交。\n\n"
      "👉 核对截图没问题 @我 回「确认提交」\n"
      "👉 不要了 @我 回「不提交」", ("order_no",), {"order_no": "S20261104009"}),
    T("restock.msg_submit_not_ready", "message", "提交", "说了「提交」但没有待确认提交的单次补货",
      "{% if doc %}单次补货 {{ doc }} 现在是「{{ stage }}」,还不能提交。"
      "{% if status == 'awaiting_confirm' %}\n\n👉 请先 @我 回「订」建单{% endif %}"
      "{% else %}现在没有待确认提交的单次补货。{% endif %}",
      ("doc", "stage", "status"), {"doc": "SP-20261028-1-01", "stage": "待确认", "status": "awaiting_confirm"}),
    # ---------------- 提醒与截单 ----------------
    T("restock.msg_reminder", "message", "提醒与截单", "未确认提醒",
      "⏰ 今天的补货推荐还没确认(第 {{ n }}/{{ max }} 次提醒),{{ cutoff }} 截单。\n"
      "请点开链接确认,不确认不会生成采购单 👉\n{{ link }}{% if late %}\n{{ late }}{% endif %}",
      ("doc", "n", "max", "cutoff", "link", "late"),
      {"doc": "RP-20261027-1-01", "n": 1, "max": 3, "cutoff": "16:00", "link": _LINK, "late": ""}),
    T("restock.msg_cutoff_passed", "message", "提醒与截单", "到截单时间(只提示)",
      "⏰ 已到截单时间 {{ cutoff }},今天的补货单 {{ doc }} 还在「{{ stage }}」。仍可继续确认 / 提交,"
      "但实际提交时间会超过截单时间 👉\n{{ link }}",
      ("cutoff", "doc", "stage", "link"), {"cutoff": "16:00", "doc": "RP-20261027-1-01", "stage": "待确认", "link": _LINK}),
    T("restock.msg_closed", "message", "提醒与截单", "截单收口",
      "⌛ 已到 {{ cutoff }} 截单时间,今天的补货单 {{ doc }} 未完成({{ stage }}),流程结束,不顺延到明天。",
      ("cutoff", "doc", "stage"), {"cutoff": "16:00", "doc": "RP-20261027-1-01", "stage": "待确认"}),
    T("restock.msg_after_cutoff", "message", "提醒与截单", "过截单时间", "已过今天的截单时间 {{ cutoff }},不能再建单了。",
      ("cutoff",), {"cutoff": "16:00"}),
    T("restock.msg_status", "message", "查询", "进度查询",
      "{% if stage %}今天的定时补货:{{ stage }}{% if order_no %},采购单 {{ order_no }}"
      "{% if po_status %}({{ po_status }}){% endif %}{% endif %}\n{{ link }}{% endif %}"
      "{% if others %}\n⚠️ 另外还有 {{ others|length }} 张定时补货单(一般一天只有一张,请留意别重复订):"
      "{% for it in others %}\n· {{ it.doc_no }}({{ it.trigger_cn }}{% if it.biz_date %},{{ it.biz_date }}{% endif %},"
      "{{ it.stage_cn }}{% if it.order_no %},采购单 {{ it.order_no }}{% endif %})👉 {{ it.link }}{% endfor %}{% endif %}"
      "{% if single %}{% if stage or others %}\n{% endif %}单次补货 {{ single.doc }}:{{ single.stage }}"
      "{% if single.order_no %},采购单 {{ single.order_no }}{% endif %}{% endif %}",
      ("stage", "order_no", "po_status", "link", "single", "others"),
      {"stage": "待确认提交", "order_no": "S20261104009", "po_status": "待提交", "link": _LINK, "single": None,
       "others": []}),
    T("restock.msg_no_run", "message", "查询", "今天还没有补货单",
      "今天的定时补货还没开始(每天 {{ push_time }} 自动推送)。\n\n"
      "👉 要单独补某个零件,@我 发「零件号 数量」",
      ("push_time",), {"push_time": "15:00"}),
    T("restock.msg_retry", "message", "异常", "取数失败,稍后自动重试",
      "❌ 取数失败:{{ reason }}\n{{ minutes }} 分钟后自动重试(只重试查询,已试 {{ attempt }} 次),{{ stop_at }} 停止自动重试。"
      "{% if left_min is not none %}\n距截单 {{ cutoff }} 还有 {{ left_min }} 分钟"
      "{% if tight %},时间已经不多:就算重试成功,建单 / 提交也可能错过截单时间,建议同时人工到 DMS 下单{% endif %}。{% endif %}",
      ("reason", "minutes", "attempt", "stop_at", "left_min", "cutoff", "tight"),
      {"reason": "门店取数端不在线", "minutes": 10, "attempt": 1, "stop_at": "15:30", "left_min": 50, "cutoff": "16:00",
       "tight": False}),
    T("restock.msg_scan_failed", "message", "异常", "取数最终失败",
      "❌ 拉今天的补货数据失败:{{ reason }}\n系统已停止自动重试(已通知运维),需要人工介入:\n"
      "① 检查门店电脑和取数端是否开机、联网\n② 在后台「补货单」点「立即执行补货」重跑\n③ 来不及的话请直接到 DMS 下单"
      "{% if late %}\n{{ late }}{% endif %}",
      ("reason", "late"), {"reason": "门店取数端不在线", "late": ""}),
    # ---------------- 单次补货 ----------------
    T("restock.msg_single_querying", "message", "单次补货", "收到单次补货,开始查",
      "收到,查一下 {{ part_no }}(要 {{ qty }} 个)…", ("part_no", "qty"), {"part_no": "8713902280", "qty": 2}),
    T("restock.msg_single_quote", "message", "单次补货", "查询结果(等回「订」)",
      "查到 {{ l.part_no }} {{ l.name }}\n————————\n"
      "{% for w, q in wh.items() %}{{ w }} {{ '%g'|format(q) }}{% if not loop.last %} · {% endif %}{% endfor %}\n"
      "当前库存 {{ '%g'|format(l.stock) }} · {{ in_transit_label }} {{ '%g'|format(l.in_transit) }}\n"
      "当日剩余可订 {{ l.cap if l.cap is not none else '不限' }}\n————————\n"
      "{% if l.final_qty != requested %}你要 {{ requested }} 个,{{ l.note }},只能按 {{ l.final_qty }} 个下单。\n{% endif %}"
      "按 {{ l.final_qty }} 个下单,约 ¥{{ '%.2f'|format(l.amount) }}\n\n"
      "👉 @我 回「订」建单\n"
      "👉 @我 回「不订」取消",
      ("l", "requested", "wh", "in_transit_label"),
      {"l": _L, "requested": 2, "wh": _WH, "in_transit_label": "在途数量"},
      "wh 里的仓库名已经换成「广州仓 / 华南仓」。"),
    T("restock.msg_single_not_orderable", "message", "单次补货", "查完不能订",
      "{{ l.part_no }} {{ l.name }}:{{ l.note or l.label }},这次不能订。", ("l", "requested"),
      {"l": dict(_L, note="关注仓(广州仓/华南仓)都没货,这次不订", tag="oos", label="厂家缺货"), "requested": 2}),
    T("restock.msg_single_confirmed", "message", "单次补货", "回「订」后开始建单",
      "✅ 收到,正在 DMS 建单:{{ l.name }} × {{ l.final_qty }}", ("l",), {"l": _L}),
    T("restock.msg_single_cancelled", "message", "单次补货", "不订", "好,这单不订了。"),
    T("restock.msg_terminated", "message", "后台操作", "后台强制终止",
      "⏹ {{ kind_cn }} {{ doc }} 已被 {{ by }} 在后台终止{% if reason %}({{ reason }}){% endif %},"
      "不再自动重试、不再处理。{% if kind == 'single' %}需要的话请重新发「零件号 数量」。{% endif %}",
      ("doc", "by", "reason", "kind", "kind_cn"),
      {"doc": "RP-20261110-1-01", "by": "管理员", "reason": "取数端长时间离线", "kind": "scheduled", "kind_cn": "定时补货"}),
    T("restock.msg_voided", "message", "后台操作", "后台作废单次补货",
      "🗑 单次补货 {{ doc }} 已被 {{ by }} 在后台作废{% if reason %}({{ reason }}){% endif %}"
      "{% if order_no %},不再提交;DMS 草稿 {{ order_no }} 保留「待提交」,需要的话请到 DMS 删除或提交{% else %},DMS 里没有建单{% endif %}。"
      "需要的话请重新发「零件号 数量」。",
      ("doc", "by", "reason", "order_no"),
      {"doc": "SP-20261110-1-01", "by": "管理员", "reason": "计划员说不要了", "order_no": ""}),
    T("restock.msg_single_pending", "message", "单次补货", "上一单还没处理完",
      "上一单单次补货还没处理完({% if part_no %}{{ name }} {{ part_no }} × {{ qty }},{% endif %}{{ stage }}"
      "{% if order_no %},采购单 {{ order_no }}{% endif %}),这次没有新建。"
      "{% if status == 'awaiting_submit' %}"
      "{% if dms_note == 'checked' %}刚到 DMS 查过,这张单还是「待提交」。"
      "{% elif dms_note == 'unknown' %}暂时查不到 DMS 里这张单的状态(取数端不在线或查询失败)。{% endif %}"
      "\n\n👉 @我 回「确认提交」提交,或回「不提交」\n"
      "👉 处理完再发新的"
      "{% elif status == 'awaiting_confirm' %}\n\n👉 @我 回「订」下单,或回「不订」取消\n"
      "👉 处理完再发新的"
      "{% else %}等它处理完再发新的。{% endif %}",
      ("stage", "status", "doc", "order_no", "owner", "name", "part_no", "qty", "unknown", "dms_note"),
      {"stage": "待确认提交", "status": "awaiting_submit", "doc": "SP-20261028-1-01", "order_no": "S20261104009",
       "owner": "邹新", "name": "空调滤清器滤芯分总成", "part_no": "8713902280", "qty": 2, "unknown": False,
       "dms_note": "checked"},
      "dms_note:checked 刚查过 DMS 仍是待提交 / unknown 查不到 DMS 状态 / 空 = 没查(不是已建单待提交)"),
    T("restock.msg_single_prev_closed", "message", "单次补货", "发新单时上一单已收口",
      "{% if reason == 'quote' %}上一单{% if owner %}({{ owner }} 发的){% endif %} {{ name }} {{ part_no }} × {{ qty }} "
      "只报了价、没在 DMS 建单,已作废。"
      "{% elif reason == 'missing' %}上一单的采购单 {{ order_no }}({{ name }} {{ part_no }} × {{ qty }})在 DMS 里已经被删除,"
      "这单已收口。"
      "{% else %}上一单的采购单 {{ order_no }}({{ name }} {{ part_no }} × {{ qty }})在 DMS 里已经是「{{ status_cn }}」,"
      "这单已收口,不会再提交。{% endif %}",
      ("reason", "doc", "order_no", "status_cn", "owner", "name", "part_no", "qty"),
      {"reason": "missing", "doc": "SP-20261028-1-01", "order_no": "S20261104009", "status_cn": "", "owner": "邹新",
       "name": "空调滤清器滤芯分总成", "part_no": "8713902280", "qty": 2},
      "reason:quote 只报了价被新单替换 / missing DMS 里已删除 / submitted、other DMS 里已不是待提交"),
    T("restock.msg_single_failed", "message", "单次补货", "查询失败", "❌ 没查成:{{ reason }},稍后再发一次试试。",
      ("reason",), {"reason": "门店取数端不在线"}),
    T("restock.msg_single_usage", "message", "单次补货", "格式提示", "单次补货请 @我 发「零件号 数量」,例如:8713902280 2个"),
    T("restock.msg_no_pending", "message", "单次补货", "没有待确认的单",
      "现在没有待确认的单次补货。\n\n"
      "👉 要补某个零件,@我 发「零件号 数量」\n"
      "👉 定时补货请点开推送里的链接确认"),
    T("restock.msg_single_status", "message", "单次补货", "本会话单次补货的进度",
      "{% if doc %}本会话的单次补货 {{ doc }}{% if part_no %}({{ name }} {{ part_no }} × {{ qty }}){% endif %}:{{ stage }}"
      "{% if order_no %},采购单 {{ order_no }}{% endif %}"
      "{% if status == 'awaiting_confirm' %}\n👉 @我 回「订」建单,或回「不订」取消"
      "{% elif status == 'awaiting_submit' %}\n👉 @我 回「确认提交」提交,或回「不提交」先不下单{% endif %}"
      "{% else %}这个会话现在没有进行中的单次补货。\n\n👉 要单独补某个零件,@我 发「零件号 数量」,例如:8713902280 2个{% endif %}",
      ("doc", "stage", "status", "order_no", "name", "part_no", "qty"),
      {"doc": "SP-20261109-1-01", "stage": "待确认", "status": "awaiting_confirm", "order_no": "",
       "name": "空调滤清器滤芯分总成", "part_no": "8713902280", "qty": 2}),
]

# 变量中文说明(后台「可用变量」列表)
VARS = {
    "cutoff": "截单时间", "stage": "补货单当前阶段", "order_no": "DMS 采购单号", "link": "手机单据页链接",
    "doc": "补货单号", "window": "出库窗口(如 10/27 15:00 — 10/28 15:00)", "trigger": "触发方式:schedule 定时 / console 后台",
    "s": "汇总:s.total 出库零件种数 / s.stock_count 常备件 / s.other_count 其他 / s.order_count 要订项数 / "
         "s.order_qty 件数 / s.amount 金额 / s.errors 查询失败项",
    "stats": "出库明细统计", "push_time": "定时补货推送时间", "by": "确认人 / DMS 提交人",
    "count": "项数", "qty": "件数 / 要的数量", "amount": "金额(元)", "shots": "已发截图张数",
    "fallback": "截图兜底方式(空 = DMS 真实截图 / image 接口数据渲染 / text 文字明细)", "mode": "兜底方式:image / text",
    "n": "第几次提醒 / 兜底截图张数", "details": "采购单明细文字", "kind": "scheduled 定时补货 / single 单次补货",
    "shot_err": "截图失败原因(空 = 成功)", "mismatch": "DMS 回查与请求不一致的说明(空 = 一致)",
    "reason": "失败原因", "unknown": "结果是否未知(是 / 否)", "eta": "预计还要等多久(如 大概 2 分钟)",
    "max": "最多提醒几次", "attempt": "已重试次数", "stop_at": "停止自动重试的时间", "minutes": "分钟数",
    "part_no": "零件号", "name": "零件名称",
    "r": "查库存结果:r.part_no / r.name / r.stock 库存 / r.in_transit 在途 / r.in_transit_label 在途口径 / r.cap 当日可订 / "
         "r.unit_price 单价 / r.wh 关注仓 {广州仓: 数量} / r.oos 关注仓都没货",
    "skills": "已启用的技能代码列表,如 restock.single(技能提示词里按它判断要不要提别的技能)",
    "single": "单次补货进度:single.doc 单号 / single.stage 阶段 / single.order_no 采购单号",
    "l": "单次补货这一行:l.part_no / l.name / l.stock 库存 / l.in_transit 在途 / l.mad 月均 / l.cap 当日可订 / "
         "l.final_qty 下单数量 / l.amount 金额 / l.note 说明",
    "requested": "计划员要的数量", "wh": "关注仓库存 {仓库名: 数量}(仓库名已换成 广州仓 / 华南仓)",
    "in_transit_label": "在途口径名称", "now": "当前时间",
    "deadline": "确认提交的截止时间(HH:MM)", "can_submit": "提交开关是否打开", "owner": "单次补货发起人(只用于描述,谁回复都行)",
    "kind_cn": "业务名称:定时补货 / 单次补货", "via_cn": "确认提交渠道:企微群里回复 / 单据页按钮",
    "lines": "提交后 DMS 回查的明细:x.part_no / x.name / x.qty / x.amount", "confirmed_by": "确认提交的人",
    "already": "DMS 里之前是否已经提交过", "retry": "能否处理后再确认提交", "left_min": "距截单还有几分钟(已过截单 / 关闭每天自动执行时为空)",
    "late": "截单风险提示(临近 / 已过截单时的一句话,否则为空)", "tight": "距截单是否只剩 30 分钟以内",
    "after": "是否已过截单", "biz_date": "补货单的业务日期", "old": "被作废的旧清单单号",
    "auto": "是否系统自动核实", "d": "未提交采购单:d['items'] 列表 / d.error 没能查 DMS 的原因 / d.truncated 是否只列了一部分",
    "wait_min": "结果未知后再确认要等几分钟", "seconds": "还要等几秒", "order_nos": "采购单号(多个用顿号分隔)",
    "status": "补货单状态代码(awaiting_confirm 待确认 / awaiting_submit 待确认提交 …)", "po_status": "采购单状态:待提交 / 已提交",
}

# 什么时候发、发给谁(后台编辑器头部说明)
WHEN = {
    "restock.msg_start": "发到补货对话群:每天推送时间到点(@计划员)/ 后台点「立即执行补货」,开始取数时",
    "restock.msg_list": "发到补货对话群(@计划员):取数完成,推单据页链接(清单只在页面里)",
    "restock.msg_no_candidates": "发到补货对话群:窗口内没有纯牌零件出库",
    "restock.msg_busy": "后台点「立即执行补货」时上一轮还在进行中",
    "restock.msg_already_ordered": "今天的定时补货已经建过单又要确认时",
    "restock.msg_scheduled_use_link": "回复计划员:有待确认 / 待确认提交的定时补货时在群里回「确认」",
    "restock.msg_scheduled_no_chat": "回复计划员:在群里说「帮我查库存补货」想发起定时补货时",
    "restock.msg_cancelled": "发到补货对话群:页面上点「今天不订」之后",
    "restock.msg_confirmed": "发到补货对话群:页面上确认清单,开始在 DMS 建单",
    "restock.msg_po_done": "发到补货对话群:采购单建好、截图发出后的回执,等确认提交(定时 / 单次共用)",
    "restock.msg_shot_fallback": "发到补货对话群:DMS 页面截图失败,发兜底截图(或文字明细)之前的说明",
    "restock.msg_po_failed": "发到补货对话群:建单失败或结果未知时",
    "restock.msg_reconcile_wait": "回复计划员:建单结果未知后,等待时间没到就再确认",
    "restock.msg_reconciling": "发到补货对话群:再确认时先到 DMS 核实上次建单结果",
    "restock.msg_po_adopted": "发到补货对话群:核实发现上次其实已建成,接管这张单(不重复建单)",
    "restock.msg_reconcile_none": "发到所属会话:核实 DMS 里没有本单的采购单(单次补货回到待确认;定时补货开始重新建单)",
    "restock.msg_create_unknown": "发到所属会话:单次补货建单结果未知,进入建单异常、系统自动核实",
    "restock.msg_create_unknown_busy": "回复计划员:单次补货建单异常(正在自动核实)期间,会话里的任何补货操作都不执行",
    "restock.msg_create_unknown_still": "发到所属会话:建单异常超过设定时长还没核实完的提醒(之后每 2 小时最多一次)",
    "restock.msg_reconcile_manual": "发到所属会话:自动核实发现 DMS 里有多张 / 状态异常,转人工",
    "restock.msg_unknown_closed": "发到所属会话:后台「人工核实后关闭」建单异常的单之后",
    "restock.msg_reconcile_failed": "发到补货对话群:核实失败,这次没有建单",
    "restock.msg_reconcile_multi": "发到补货对话群:核实发现 DMS 里有多张本单的采购单,转人工",
    "restock.msg_unknown_left": "发到补货对话群:之前有一次建单结果未知的补货单被取消 / 截单收口时",
    "restock.msg_create_disabled": "回复计划员:取数端运行参数里对应业务的「允许建单」关着时确认建单",
    "restock.msg_submitting": "回复计划员 / 发到补货对话群:确认提交后,开始在 DMS 提交",
    "restock.msg_po_submitted": "发到补货对话群:DMS 提交成功后的回执",
    "restock.msg_submit_failed": "发到补货对话群:提交失败或结果未知时",
    "restock.msg_submit_cancelled": "发到补货对话群:回「不提交」/ 单据页点「先不提交」之后(DMS 草稿保留)",
    "restock.msg_po_deleted": "发到补货对话群:确认提交 / 发新单次补货时查到 DMS 里这张采购单已被删除(补货单收口)",
    "restock.msg_po_status_other": "发到补货对话群:确认提交 / 发新单次补货时查到 DMS 里这张采购单已不是待提交(补货单收口)",
    "restock.msg_submit_disabled": "回复计划员:取数端运行参数里对应业务的「允许提交」关着时确认提交",
    "restock.msg_submit_need_explicit": "回复计划员:单次补货待确认提交时回了「订 / 好的 / 确认」等,没明确说「提交」(不提交)",
    "restock.msg_submit_not_ready": "回复计划员:说了「提交」但没有待确认提交的单次补货",
    "restock.msg_reminder": "发到补货对话群(@计划员):链接推送后一直没确认,按间隔提醒(关闭每天自动执行时不发)",
    "restock.msg_closed": "发到补货对话群:到截单时间仍未完成(只在「截单后禁止确认(旧规则)」打开时作废并发这条)",
    "restock.msg_cutoff_passed": "发到补货对话群:到截单时间,今天的定时补货还没走完(只提示风险,不作废;关闭每天自动执行时不发)",
    "restock.late_hint": "拼在定时补货消息 / 单据页后面:离截单不到「截单前紧急告警」分钟数或已过截单时",
    "restock.stale_hint": "拼在群里回复 / 单据页上:清单不是今天的(等下一张定时补货单生成时作废)",
    "restock.msg_stale_superseded": "拼在开始取数消息后面:新的定时补货单生成时,作废了之前没确认的清单",
    "restock.drafts_hint": "拼在补货推荐推送 / 进度回复后面:DMS 里还有没提交的采购单(含他人创建、本系统建单结果未知的)",
    "restock.msg_recover_shot": "发到补货对话群(@计划员):云端重启时定时补货正在截图,采购单已建好,转为待确认提交",
    "restock.msg_after_cutoff": "页面上截单后才点确认 / 刷新时",
    "restock.msg_status": "回复计划员:问「补货到哪一步了」",
    "restock.msg_no_run": "回复计划员:今天还没有补货单时问进度",
    "restock.msg_retry": "发到补货对话群:取数失败、稍后自动重试时",
    "restock.msg_scan_failed": "发到补货对话群:自动重试也失败、停止重试时",
    "restock.msg_single_querying": "回复计划员:发了「零件号 数量」,开始查询",
    "restock.msg_single_quote": "发到补货对话群:单次补货查询结果,等回「订」",
    "restock.msg_single_not_orderable": "发到补货对话群:单次补货查完发现不能订(厂家缺货 / 可订量用完 / 没查到)",
    "restock.msg_single_confirmed": "回复计划员:回「订」之后开始建单",
    "restock.msg_single_cancelled": "回复计划员:单次补货回「不订」之后",
    "restock.msg_terminated": "发到这张单的会话(定时补货发补货对话群):后台点「强制终止」之后",
    "restock.msg_voided": "发到所属会话:后台点单次补货的「作废」/「不提交(保留 DMS 草稿)」之后",
    "restock.msg_single_pending": "回复计划员:上一单单次补货还没处理完(含待确认提交)又发了新的",
    "restock.msg_single_prev_closed": "回复计划员:发新单次补货时,上一单(只报价 / DMS 里已删除 / 已不是待提交)收口,拼在新单回执前面",
    "restock.msg_single_failed": "发到补货对话群:单次补货查询失败",
    "restock.msg_single_usage": "回复计划员:单次补货格式不对时",
    "restock.msg_no_pending": "回复计划员:回「订 / 确认」但没有待处理的单次补货时",
    "restock.skill.single": "大模型系统提示词的一节:单次补货技能启用时拼在通用提示词后面(不直接发给人)",
    "restock.skill.part_query": "大模型系统提示词的一节:查库存技能启用时拼在通用提示词后面(不直接发给人)",
    "restock.skill.scheduled": "大模型系统提示词的一节:定时补货技能启用时拼在通用提示词后面(不直接发给人)",
    "restock.msg_single_status": "回复计划员:问自己这单单次补货到哪一步了",
    "restock.msg_part_querying": "回复计划员:问了「零件号 有货吗」,开始查询",
    "restock.msg_part_query": "回复计划员:查库存结果(只查不订)",
    "restock.msg_part_query_failed": "回复计划员:查库存失败(取数端不在线 / 没查到)",
    "restock.msg_part_query_limited": "回复计划员:同一个会话一分钟内查得太多次",
    "restock.msg_part_query_usage": "回复计划员:想查库存但没说零件号",
}