From f4bcd1ba257e1df39b21575e1ed52f2f027e2758 Mon Sep 17 00:00:00 2001 From: selfrelease Date: Wed, 15 Jul 2026 12:14:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=A2=E6=88=B7=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E7=BA=BF=E5=85=B3=E8=81=94=E6=94=B9=E4=B8=BA=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E5=86=85=E5=AE=B9=E5=85=B3=E9=94=AE=E8=AF=8D?= =?UTF-8?q?=E6=8E=A8=E6=96=AD=EF=BC=8C=E4=B8=8D=E5=86=8D=E4=BB=85=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=E6=88=90=E4=BA=A4=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/web/server.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/demo/web/server.py b/demo/web/server.py index fb360e9..d2ae96d 100644 --- a/demo/web/server.py +++ b/demo/web/server.py @@ -254,7 +254,8 @@ def list_customers( cu.key_needs, cu.stage, cu.last_analysis, c.display_name AS contact_display_name, max(m.created_at) AS last_message_at, - string_agg(DISTINCT p.category, ', ') AS product_categories + string_agg(DISTINCT p.category, ', ') AS deal_categories, + string_agg(m.normalized_content, ' ') AS all_messages FROM customer cu JOIN salesperson s ON s.id = cu.salesperson_id JOIN contact c ON c.id = cu.contact_id @@ -283,8 +284,25 @@ def list_customers( ORDER BY cu.salesperson_id, cu.id """ cur.execute(sql, params) - return [ - { + # 产品线关键词:通过对话内容推断产品线 + diet_keywords = ["减肥", "减脂", "瘦身", "B420", "纤益", "代餐", "体脂", "产后减肥", "节食"] + child_keywords = ["湿疹", "过敏", "鼻炎", "腹泻", "便秘", "免疫力", "胀气", + "拉肚子", "打喷嚏", "流鼻涕", "感冒", "食物过敏", "牛奶蛋白", + "宝宝", "宝妈", "儿童", "丹麦", "鼠李糖", "LGG", "合生元"] + results = [] + for r in cur.fetchall(): + deal_cats = r[11] + all_msgs = r[12] or "" + # 优先用 deal 关联的产品线,其次通过对话内容推断 + if deal_cats: + product_categories = deal_cats + elif any(kw in all_msgs for kw in diet_keywords): + product_categories = "女性减肥益生菌" + elif any(kw in all_msgs for kw in child_keywords): + product_categories = "儿童益生菌" + else: + product_categories = None + results.append({ "id": r[0], "salesperson_id": r[1], "salesperson_name": r[2], "customer_name": r[3], "industry": r[4], @@ -293,10 +311,9 @@ def list_customers( "last_analysis": r[8].isoformat() if r[8] else None, "contact_display_name": r[9], "last_message_at": r[10].isoformat() if r[10] else None, - "product_categories": r[11], - } - for r in cur.fetchall() - ] + "product_categories": product_categories, + }) + return results finally: put_conn(conn)