|
@@ -0,0 +1,32 @@
|
|
|
+'use strict';
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
|
|
|
+
|
|
|
+// 套装表
|
|
|
+const goodsSet = {
|
|
|
+ name: { type: String, required: false, zh: '套装名称' }, //
|
|
|
+ set: { type: Array, required: false, zh: '商品规格组合' }, //
|
|
|
+ shop: { type: Array, required: false, zh: '参与组合的店铺id集合' }, // 由set来
|
|
|
+ goods: { type: Array, required: false, zh: '参与组合的商品id集合' }, // 由set来
|
|
|
+ spec: { type: Array, required: false, zh: '参与组合的规格id集合' }, // 由set来
|
|
|
+ is_use: { type: String, required: false, default: '0', zh: '是否使用' }, // 字典:is_use
|
|
|
+ sell_money: { type: Number, required: false, zh: '套装销售金额' }, // 由set中的set_money之后而来
|
|
|
+ single_stock: { type: String, required: false, default: '1', zh: '单独设置库存' }, // 字典:is_use
|
|
|
+ stock: { type: Number, required: false, default: '0', zh: '库存数量' }, //
|
|
|
+};
|
|
|
+const schema = new Schema(goodsSet, { toJSON: { getters: true, virtuals: true } });
|
|
|
+schema.index({ id: 1 });
|
|
|
+schema.index({ 'meta.createdAt': 1 });
|
|
|
+schema.index({ name: 1 });
|
|
|
+schema.index({ shop: 1 });
|
|
|
+schema.index({ goods: 1 });
|
|
|
+schema.index({ spec: 1 });
|
|
|
+schema.index({ is_use: 1 });
|
|
|
+schema.index({ single_stock: 1 });
|
|
|
+
|
|
|
+schema.plugin(metaPlugin);
|
|
|
+
|
|
|
+module.exports = app => {
|
|
|
+ const { mongoose } = app;
|
|
|
+ return mongoose.model('GoodsSet', schema, 'goodsSet');
|
|
|
+};
|