From 17385335fd8b4d8d9c16c1ea3a137b7473943a74 Mon Sep 17 00:00:00 2001 From: kicer Date: Wed, 22 Jul 2026 17:59:21 +0800 Subject: [PATCH] fix issues --- server/ai/prompt.js | 11 ++++++++++- server/db.js | 5 ++++- server/handlers.js | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/server/ai/prompt.js b/server/ai/prompt.js index 3a09461..41e6498 100644 --- a/server/ai/prompt.js +++ b/server/ai/prompt.js @@ -38,7 +38,16 @@ function buildSystemPrompt(username, isAdmin) { const purchaseRules = ` ⚠️ 采购规则: - 系统会在 Prompt 末尾提供"当前房间采购清单",你必须根据清单判断用户是要更新已有记录还是新建。 -- 用户说"买完了/完成了/付过了" → 更新对应记录 status 为"已完成" +- 采购状态(status)只能从以下 4 个值中选择,绝不允许自创: + * "待付款" — 采购已记录,等待付款 + * "已付款" — 已完成支付,等待收货 + * "已收货" — 已收到货物 + * "已完成" — 发票已收,全部结束 +- 状态映射: + * "付了/已付/付款了" → "已付款" + * "到了/收到货了" → "已收货" + * "发票到/全搞定/完结" → "已完成" + * 新建不指定 → "待付款" - 只有明确消费意图(购买/采购/下单/付款/买了/花了)才返回 action="purchase" - 纯陈述(如"前天deep")→ action="ignore" - 信息不完整 → action="ask" 追问 diff --git a/server/db.js b/server/db.js index 2e606e1..80f2d14 100644 --- a/server/db.js +++ b/server/db.js @@ -50,7 +50,7 @@ db.exec(` freight REAL DEFAULT 0, payment_method TEXT DEFAULT '未指定', invoice_type TEXT DEFAULT '无票', - status TEXT DEFAULT '待处理', + status TEXT DEFAULT '待付款', applicant TEXT, remarks TEXT DEFAULT '', created_at TEXT DEFAULT (datetime('now','localtime')), @@ -92,4 +92,7 @@ for (const sql of migrations) { try { db.exec(sql); } catch (e) { /* 列已存在 */ } } +// 统一存量状态值 +try { db.exec("UPDATE purchases SET status = '待付款' WHERE status = '待处理'"); } catch (e) {} + module.exports = db; diff --git a/server/handlers.js b/server/handlers.js index f97b95b..1ac2a86 100644 --- a/server/handlers.js +++ b/server/handlers.js @@ -175,7 +175,7 @@ function handleAIResult(aiResult, roomId, username, originalText, attachments) { const id = uuidv4(); const paymentMethod = aiResult.payment_method || (aiResult.method === '淘宝' ? '支付宝' : (aiResult.method || '未指定')); const invoiceType = aiResult.invoice_type || '无票'; - const status = aiResult.status || '待处理'; + const status = aiResult.status || '待付款'; const applicant = aiResult.applicant || username; const remarks = aiResult.remarks || ''; db.prepare('INSERT INTO purchases (id, room_id, item, quantity, unit_price, amount, freight, payment_method, invoice_type, status, applicant, remarks, created_at) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)').run(