oms/backend/app/model/comboProductItem.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

31 lines
1.5 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';
/**
* 组合商品明细模型,对应 combo_product_items 表。
* 存储组合商品与系统商品的组合关系(product_id + quantity),
* 一个组合内同一系统商品仅有一条记录。
* @param {Egg.Application} app egg application
* @return {object} comboProductItem model
*/
module.exports = app => {
const { BIGINT, INTEGER, DATE } = app.Sequelize;
const ComboProductItem = app.model.define('combo_product_item', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
principal_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属主体ID' },
combo_product_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '所属组合商品ID' },
product_id: { type: BIGINT.UNSIGNED, allowNull: false, comment: '系统商品ID' },
quantity: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 1, comment: '该商品在组合中的数量' },
created_at: { type: DATE, comment: '创建时间' },
updated_at: { type: DATE, comment: '更新时间' },
});
ComboProductItem.associate = () => {
app.model.ComboProductItem.belongsTo(app.model.Principal, { foreignKey: 'principal_id', as: 'principal' });
app.model.ComboProductItem.belongsTo(app.model.ComboProduct, { foreignKey: 'combo_product_id', as: 'comboProduct' });
app.model.ComboProductItem.belongsTo(app.model.Product, { foreignKey: 'product_id', as: 'product' });
};
return ComboProductItem;
};