- 商品/商品图片、店铺、店铺商品、组合商品及明细 - 仓库、仓库商品(WMS itemId 映射)、仓库接口配置与字段定义(warehouseApi/warehouseApiField) - 库存:stock_items、product_stocks(ZC/CC 双维度)与库存重算工具(utils/recalcStock.js) - 库存单据与对接日志:stock orders、api_outbound_logs - 相关迁移:shops/shop_products/stock_orders/warehouses/warehouse_apis/warehouse_products/product_stocks/files-images 等表与字段
37 lines
1.3 KiB
JavaScript
37 lines
1.3 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* product_stocks 增加「残次品」维度:
|
||
* - 原 quantity / lock_quantity / available 视为「正品」总/锁定/可用
|
||
* - 新增 defect_quantity / defect_lock_quantity / defect_available 作为「残次品」
|
||
* 旧数据 defect_* 默认 0,即全部库存归为正品,向前兼容
|
||
*/
|
||
module.exports = {
|
||
async up(queryInterface, Sequelize) {
|
||
await queryInterface.addColumn('product_stocks', 'defect_quantity', {
|
||
type: Sequelize.DECIMAL(12, 3),
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: '残次品总数量',
|
||
});
|
||
await queryInterface.addColumn('product_stocks', 'defect_lock_quantity', {
|
||
type: Sequelize.DECIMAL(12, 3),
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: '残次品锁定数量',
|
||
});
|
||
await queryInterface.addColumn('product_stocks', 'defect_available', {
|
||
type: Sequelize.DECIMAL(12, 3),
|
||
allowNull: false,
|
||
defaultValue: 0,
|
||
comment: '残次品可用数量 = 总数量 - 锁定数量',
|
||
});
|
||
},
|
||
|
||
async down(queryInterface) {
|
||
await queryInterface.removeColumn('product_stocks', 'defect_quantity');
|
||
await queryInterface.removeColumn('product_stocks', 'defect_lock_quantity');
|
||
await queryInterface.removeColumn('product_stocks', 'defect_available');
|
||
},
|
||
};
|