oms/backend/database/migrations/20261104071200-add-subsidiary-to-shops.js
liufumingren 7c8e531362 feat(shop): 店铺/店铺商品关联货主与打单平台权限限制
- shops、shop_products 新增 subsidiary_id,店铺商品货主跟随店铺并按店铺回填历史数据
- 店铺列表/详情/新增/编辑/删除按货主范围隔离:货主权限仅可见/可维护自己所属公司的店铺,
  新增必须选货主,货主下拉仅自己所属公司;集团改店铺货主时店铺商品同步跟随
- 外部打单平台导入的店铺(type=2)在货主权限下只读:仅保留拉取订单、同步商品,不可编辑/删除
- 打单平台相关接口(平台资料、账号、商家、快递接口、外部发货)加集团权限门禁;添加店铺必须指定货主
- 货主权限菜单隐藏「外部打单平台」;店铺商品列表/绑定按货主范围隔离
- 店铺与店铺商品导出新增货主列并按范围收窄

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-05 02:15:42 +08:00

28 lines
945 B
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';
/**
* 店铺绑定下属公司(货主):shops 增加 subsidiary_id。
*
* 货主权限仅可见自己所属公司的店铺;外部打单平台添加店铺时必须选择货主。
* 历史店铺可为空(未绑定货主时仅集团权限可见)。
*/
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn('shops', 'subsidiary_id', {
type: Sequelize.BIGINT.UNSIGNED,
allowNull: true,
comment: '所属货主(下属公司ID)',
references: { model: 'principal_subsidiaries', key: 'id' },
after: 'principal_id',
});
await queryInterface.addIndex('shops', [ 'principal_id', 'subsidiary_id' ], {
name: 'idx_shops_principal_subsidiary',
});
},
async down(queryInterface) {
await queryInterface.removeIndex('shops', 'idx_shops_principal_subsidiary');
await queryInterface.removeColumn('shops', 'subsidiary_id');
},
};