oms/backend/app/model/shop.js
liufumingren cbd16752a5 feat(backend): 商品、店铺、组合商品、仓库与库存模块
- 商品/商品图片、店铺、店铺商品、组合商品及明细
- 仓库、仓库商品(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 等表与字段
2026-09-13 02:23:39 +08:00

35 lines
1.7 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';
/**
* 店铺模型,对应 shops 表(归属于主体,一个主体可有多个平台店铺)
* @param {Egg.Application} app egg application
* @return {object} shop model
*/
module.exports = app => {
const { BIGINT, STRING, TINYINT, JSON, DATE } = app.Sequelize;
const Shop = app.model.define('shop', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
principal_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属主体ID' },
code: { type: STRING(50), allowNull: false, comment: '店铺编码(平台店铺ID或自定义编码,OMS 内新建时按 OMS 前缀自动生成)' },
name: { type: STRING(100), allowNull: false, comment: '店铺名称' },
platform: { type: STRING(50), comment: '所属平台:taobao/pdd/douyin/jd/other' },
contact_name: { type: STRING(50), comment: '联系人' },
contact_phone: { type: STRING(20), comment: '联系电话' },
status: { type: TINYINT, allowNull: false, defaultValue: 1, comment: '状态:1启用 0禁用' },
extra: { type: JSON, comment: '扩展配置 JSON:授权信息、接口参数等' },
remark: { type: STRING(255), comment: '备注' },
created_at: { type: DATE, comment: '创建时间' },
updated_at: { type: DATE, comment: '更新时间' },
});
Shop.associate = () => {
app.model.Shop.belongsTo(app.model.Principal, { foreignKey: 'principal_id', as: 'principal' });
app.model.Shop.hasMany(app.model.ShopProduct, { foreignKey: 'shop_id', as: 'shopProducts' });
app.model.Shop.hasMany(app.model.Order, { foreignKey: 'shop_id', as: 'orders' });
app.model.Shop.hasMany(app.model.OrderItem, { foreignKey: 'shop_id', as: 'orderItems' });
};
return Shop;
};