fix issues
This commit is contained in:
@@ -38,7 +38,16 @@ function buildSystemPrompt(username, isAdmin) {
|
||||
const purchaseRules = `
|
||||
⚠️ 采购规则:
|
||||
- 系统会在 Prompt 末尾提供"当前房间采购清单",你必须根据清单判断用户是要更新已有记录还是新建。
|
||||
- 用户说"买完了/完成了/付过了" → 更新对应记录 status 为"已完成"
|
||||
- 采购状态(status)只能从以下 4 个值中选择,绝不允许自创:
|
||||
* "待付款" — 采购已记录,等待付款
|
||||
* "已付款" — 已完成支付,等待收货
|
||||
* "已收货" — 已收到货物
|
||||
* "已完成" — 发票已收,全部结束
|
||||
- 状态映射:
|
||||
* "付了/已付/付款了" → "已付款"
|
||||
* "到了/收到货了" → "已收货"
|
||||
* "发票到/全搞定/完结" → "已完成"
|
||||
* 新建不指定 → "待付款"
|
||||
- 只有明确消费意图(购买/采购/下单/付款/买了/花了)才返回 action="purchase"
|
||||
- 纯陈述(如"前天deep")→ action="ignore"
|
||||
- 信息不完整 → action="ask" 追问
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user