WMS_MAIN/database/migrations/20260804140000-create-inbox-group.js
liufumingren e61efbb66a feat(inbox): 站内信模块完整实现 - AI智能助手、群管理、消息列表增强、灰度开关
新增功能:
- AI智能助手: DeepSeek多轮推理、函数调用(searchStock/createOrder等)
- silent动作: AI识别无需回复的消息(好的/谢谢/再见)自动跳过回执
- ai_enabled灰度开关: 群级别控制AI启停,支持逐群放量
- 消息列表增强: storeId/groupId/groupName/userName/content/sourceType多条件筛选,时间格式化

代码优化:
- processWithAI: 多轮推理循环(MAX_ROUNDS=5)、对话历史不含[#N]前缀防AI污染
- 回执记录补齐group_id/user_id/group_name/user_name上下文
- 移除未使用的target_channel字段及迁移
- bindCode文档修正: store_warehouse → store

接口文档:
- system.json v0.3.18→0.3.19: 新增aiEnabled参数、消息列表响应扩充
- changes/system.json: 新增bindCode变更记录

杂项:
- store_warehouse.js JSDoc补全
- wave.js waveBatchSource修复
2026-08-06 17:40:36 +08:00

93 lines
2.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
const TABLE_NAME = 'wms_inbox_group';
module.exports = {
up: async (queryInterface, Sequelize) => {
const tables = await queryInterface.showAllTables();
if (tables.some(t => (typeof t === 'string' ? t : t.tableName) === TABLE_NAME)) return;
await queryInterface.createTable(TABLE_NAME, {
id: {
type: Sequelize.BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '主键',
},
group_name: {
type: Sequelize.STRING(100),
allowNull: false,
comment: '群名称',
},
group_id: {
type: Sequelize.STRING(100),
allowNull: true,
comment: '外部群ID',
},
warehouse_id: {
type: Sequelize.BIGINT(20).UNSIGNED,
allowNull: false,
comment: '所属仓库ID',
},
store_id: {
type: Sequelize.BIGINT(20).UNSIGNED,
allowNull: true,
comment: '关联货主ID',
},
group_type: {
type: Sequelize.ENUM('store', 'warehouse', 'express'),
allowNull: true,
comment: '群类型: store=货主 warehouse=仓库 express=快递',
},
sub_type: {
type: Sequelize.STRING(20),
allowNull: true,
comment: '群子类型',
},
source_type: {
type: Sequelize.STRING(20),
allowNull: true,
comment: '来源类型:im / api / system',
},
source_extra: {
type: Sequelize.STRING(100),
allowNull: true,
comment: '来源附加信息',
},
is_blocked: {
type: Sequelize.TINYINT(1),
allowNull: false,
defaultValue: 0,
comment: '是否屏蔽 0=否 1=是',
},
created_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
comment: '创建时间',
},
updated_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'),
comment: '更新时间',
},
deleted_at: {
type: Sequelize.DATE,
allowNull: true,
comment: '软删除时间',
},
});
await queryInterface.addIndex(TABLE_NAME, [ 'group_name', 'warehouse_id' ], {
unique: true,
name: 'uk_group_warehouse',
});
},
down: async queryInterface => {
await queryInterface.dropTable(TABLE_NAME);
},
};