oms/backend/database/migrations/20261109110000-add-external-source-to-shops.js
liufumingren c27ea5a789 feat(shop): 店管家接入「我的店铺」第二来源,支持拉取店铺并绑定货主
- 平台层新增 listShopSources() / resolveShopScope() 契约,来源由平台实现声明,控制器与前端不写死
- 店管家实现 my_shop 来源:POST /partner/LoadMyShopList 店铺列表(授权状态、平台、名称过滤)并归一化
- 新增 GET /api/external-print-accounts/:id/shop-sources;店铺列表接口支持 ?source=
- 店铺创建支持 source,写入 shops.external_source;编码 dgj-{账号ID}-{来源}-{ShopId},默认来源不加来源段
- 新增迁移 shops.external_source(默认 agent);刷新所在区只处理默认来源,避免自营店被误判解绑而自动禁用
- my_shop 的拉单/拉商品暂时明确拒绝,防止按账号 FxUserId 拉到上游其它数据(下一步接入)
- 前端「店铺列表」弹窗支持来源切换,展示平台、授权状态与服务到期时间
- 补充单元测试与文档(店管家取号-旧系统提取 §4.2.1.1)

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

33 lines
1.3 KiB
JavaScript
Raw Permalink 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';
/**
* 店铺表扩展:外部打单平台店铺的「来源」。
*
* 同一个打单账号下可能有两种来源的店铺:
* - agent:平台侧的商家/合作方(如店管家的「绑定商家」LoadMyAgentList),订单按商家归属过滤
* - my_shop:账号自己绑定的平台店铺(如店管家的「我的店铺」LoadMyShopList),订单按店铺ID过滤
*
* 该字段由各平台实现自行解释(取值来自 PrintPlatformService.listShopSources()),
* 通用层只当作字符串使用,用于区分同一账号下两类店铺的编码、归属与同步口径。
* 老数据(都是商家来源)统一回填为 agent,行为不变。
*/
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.addColumn('shops', 'external_source', {
type: Sequelize.STRING(20),
allowNull: false,
defaultValue: 'agent',
comment: '外部打单平台店铺来源(平台自定义,如 agent/my_shop)',
});
await queryInterface.addIndex('shops', {
fields: [ 'external_print_account_id', 'external_source' ],
name: 'idx_shops_external_account_source',
});
},
async down(queryInterface) {
await queryInterface.removeIndex('shops', 'idx_shops_external_account_source');
await queryInterface.removeColumn('shops', 'external_source');
},
};