WMS_MAIN/database/migrations/20260809130100-create-wms-after-sale-detail.js
liufumingren 296536c83e feat: 售后模块V2全面落地
数据库:

- 创建 wms_after_sale 主表 (36字段/16索引)

- 创建 wms_after_sale_detail 步骤表 (11字段/3索引)

- 插入售后权限 16条 (ID 508-523)

- 绑定6个角色权限 (客服/仓库/生产主管/拣货组长)

代码:

- Model: after_sale.js + after_sale_detail.js (含常量枚举)

- Service: systemMethods/afterSale.js + systems/afterSale.js (19方法)

文档:

- API定义: methods/system.json (+9 methods)

- 设计文档: database/designs/after-sale-v2-design.md

- 开发/生产环境均已执行迁移,权限ID完全一致
2026-08-09 21:17:34 +08:00

101 lines
2.8 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_after_sale_detail';
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: '主键',
},
after_sale_id: {
type: Sequelize.BIGINT(20).UNSIGNED,
allowNull: false,
comment: '关联售后主表ID(wms_after_sale.id)',
},
step_status: {
type: Sequelize.TINYINT(3).UNSIGNED,
allowNull: false,
defaultValue: 0,
comment: '步骤状态:0=待开始,1=进行中,2=已完成,3=已跳过',
},
operator_id: {
type: Sequelize.BIGINT(20).UNSIGNED,
allowNull: true,
defaultValue: null,
comment: '操作人账户ID(关联 accounts 表)',
},
operator_snapshot: {
type: Sequelize.TEXT,
allowNull: true,
defaultValue: null,
comment: '操作人信息快照(JSON),防止账户删除后历史丢失',
},
action: {
type: Sequelize.STRING(100),
allowNull: true,
defaultValue: null,
comment: '操作动作描述',
},
remark: {
type: Sequelize.TEXT,
allowNull: true,
defaultValue: null,
comment: '处理备注',
},
started_at: {
type: Sequelize.DATE,
allowNull: true,
defaultValue: null,
comment: '步骤开始时间',
},
completed_at: {
type: Sequelize.DATE,
allowNull: true,
defaultValue: null,
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,
defaultValue: null,
comment: '软删除时间',
},
});
// 按售后单查询进度步骤(最高频)
await queryInterface.addIndex(TABLE_NAME, ['after_sale_id'], {
name: 'idx_after_sale_id',
});
// 按操作人查询
await queryInterface.addIndex(TABLE_NAME, ['operator_id'], {
name: 'idx_operator_id',
});
},
down: async queryInterface => {
await queryInterface.dropTable(TABLE_NAME);
},
};