- 盘点明细/记录支持未知商品(stock_id 可空)与库位范围,模式/状态口径修正 - 新增静态盘点任务、公告相关模型与迁移,stock_warehouse 增加预警数量 - methods/system.json 同步盘点接口文档;headers platform 微信端取值 wx 修正为 miniprogram
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
'use strict';
|
||
|
||
const TABLE_NAME = 'wms_stock_static_notice';
|
||
|
||
module.exports = {
|
||
up: async (queryInterface, Sequelize) => {
|
||
const tables = await queryInterface.showAllTables();
|
||
const exists = tables.some(t => (typeof t === 'string' ? t : t.tableName) === TABLE_NAME);
|
||
if (exists) return;
|
||
|
||
await queryInterface.createTable(TABLE_NAME, {
|
||
id: {
|
||
type: Sequelize.BIGINT(20).UNSIGNED,
|
||
primaryKey: true,
|
||
autoIncrement: true,
|
||
allowNull: false,
|
||
comment: '主键ID',
|
||
},
|
||
stock_id: {
|
||
type: Sequelize.BIGINT(20).UNSIGNED,
|
||
allowNull: false,
|
||
comment: '商品ID,关联 wms_stock_warehouse.id',
|
||
},
|
||
notice_time: {
|
||
type: Sequelize.DATE,
|
||
allowNull: false,
|
||
comment: '通知时间',
|
||
},
|
||
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: '软删除时间',
|
||
},
|
||
}, {
|
||
comment: '静态商品通知关联表(记录静态商品已通知时间,避免重复通知)',
|
||
});
|
||
|
||
// 核心查询:查某商品最近一次通知时间
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'stock_id', 'notice_time' ], {
|
||
name: 'idx_stock_notice_time',
|
||
});
|
||
// 时间范围扫描:按通知时间清理/统计
|
||
await queryInterface.addIndex(TABLE_NAME, [ 'notice_time' ], {
|
||
name: 'idx_notice_time',
|
||
});
|
||
},
|
||
|
||
down: async queryInterface => {
|
||
await queryInterface.dropTable(TABLE_NAME);
|
||
},
|
||
};
|