From 1efa6b7df996c9b4d1074d3c9710cf00f8d59692 Mon Sep 17 00:00:00 2001 From: wecom-project Date: Thu, 22 Oct 2026 12:49:06 +0800 Subject: [PATCH] =?UTF-8?q?refactor(lead):=20=E9=80=80=E5=BD=B9=20notify?= =?UTF-8?q?=5Fwecom=208800=20=E5=85=A8=E5=91=98=E7=BE=A4=E6=8E=A8=E9=80=81?= =?UTF-8?q?=EF=BC=88=E5=8F=AA=E4=BF=9D=E7=95=99=20notify=5Fboss=20DM?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 删除 notify_wecom()(JSON body 打 8800/send,中继只解析 form-encoded,从未发出过消息)与吞异常的 except: pass - 客户咨询通知唯一通道:notify_boss 推任总 DM(经 ai-cs 分流) - 去掉随之无用的 urllib.request 导入 - 零行为变更:删的是从不生效的代码;防止后人「修成 form-encoded」把客户个人信息推进全员群 关联决策:ASK-20261021-09(任总 2026-10-22 11:16:8800 仅限 notice_class=content) 派单:finance-20261022-cma-lead-retire-8800-project(父任务 yanxue-20261022-relay-8800-koujing-finance) --- backend/app/api/lead.py | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/backend/app/api/lead.py b/backend/app/api/lead.py index 8635a021..b87d3332 100644 --- a/backend/app/api/lead.py +++ b/backend/app/api/lead.py @@ -1,7 +1,7 @@ """AI获客 - 客户咨询接口""" from fastapi import APIRouter, HTTPException from pydantic import BaseModel -import json, os, datetime, subprocess, urllib.request +import json, os, datetime, subprocess router = APIRouter(prefix="/api/cma/lead", tags=["AI获客"]) @@ -18,26 +18,6 @@ class LeadRequest(BaseModel): requirement: str = "" source: str = "sxbh.ltd" -def notify_wecom(name, phone, requirement, source): - """推送到企微全员群""" - msg = { - "msgtype": "markdown", - "markdown": { - "content": f"## 🔔 新客户咨询\n**姓名**: {name}\n**电话**: {phone}\n**需求**: {requirement}\n**来源**: {source}\n**时间**: {datetime.datetime.now().strftime('%Y-%m-%d %H:%M')}" - } - } - try: - data = json.dumps(msg).encode('utf-8') - req = urllib.request.Request( - "http://127.0.0.1:8800/send", - data=data, - headers={"Content-Type": "application/json"}, - method="POST" - ) - urllib.request.urlopen(req, timeout=5) - except: - pass # 通知失败不影响主流程 - def notify_boss(name, phone, requirement): """额外推给任总(经 ai-cs 实盘分流脚本;失败不影响主流程)""" try: @@ -66,9 +46,8 @@ def create_lead(data: LeadRequest): with open(f"{log_dir}/leads.json", "a") as f: f.write(json.dumps(record, ensure_ascii=False) + "\n") - # 异步推送企微通知 - notify_wecom(data.name, data.phone, data.requirement, data.source) - # 加性:额外推给任总 DM(口径与 ai-cs 客服分流一致) + # 客户咨询通知唯一通道:推任总 DM(经 ai-cs 分流);不再推 8800 全员群 + # (2026-10-22 裁定:8800 仅限内容类群发,客户线索含个人信息,不得进全员群) notify_boss(data.name, data.phone, data.requirement) return {"success": True, "message": "咨询已提交,我们将在30分钟内联系您"}