|
@@ -2,19 +2,53 @@
|
|
|
const Schema = require('mongoose').Schema;
|
|
|
const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
|
|
|
|
|
|
+const gift = {
|
|
|
+ type: [ 'goods', 'desc' ], // 平台商品; 赠品描述
|
|
|
+ goods: { type: String, zh: '商品' },
|
|
|
+ spec: { type: String, zh: '规格' },
|
|
|
+ desc: { type: String, zh: '赠品描述' }, // 即使是有赠品有关联,也可以写描述,例如:200件,赠完为止
|
|
|
+};
|
|
|
+
|
|
|
+const set = {
|
|
|
+ goods: { type: String, zh: '商品' },
|
|
|
+ spec: { type: String, zh: '规格' },
|
|
|
+ num: { type: Number, zh: '套装销售数量' },
|
|
|
+ money: { type: Number, zh: '套装销售价格' },
|
|
|
+};
|
|
|
+
|
|
|
+const config = {
|
|
|
+ // 1.买赠: 关联赠品/描述赠品 赠品不一定只是商品, 还可能不是登陆在平台上的商品
|
|
|
+ gift: { type: [ gift ] },
|
|
|
+
|
|
|
+ // 2.特价: 设置商品的活动销售价
|
|
|
+ sp_price: { type: Number, zh: '特价' },
|
|
|
+
|
|
|
+ // 3.加价购: 标注这个商品是 基础商品 还是 加价购置的商品
|
|
|
+ goods_type: { type: [ 'basic', 'plus' ] },
|
|
|
+ plus_money: { type: Number, zh: '加价金额' },
|
|
|
+ // 4.套装: 关联商品 以及 每个商品设置的价格; 外边的goods为主商品, 只有主商品才能看到套装; 进入购物车与下单,订单时,也是套装出现
|
|
|
+ set: { type: [ set ] },
|
|
|
+};
|
|
|
+
|
|
|
+
|
|
|
// 参加平台活动商品
|
|
|
const goodsJoinAct = {
|
|
|
- platformAct: { type: String, required: false, zh: '平台活动', ref: 'System.PlatformAct' }, //
|
|
|
+ platform_act: { type: String, required: false, zh: '平台活动', ref: 'System.PlatformAct' }, //
|
|
|
+ platform_act_type: { type: String, required: false, zh: '平台活动类型' }, //
|
|
|
shop: { type: String, required: false, zh: '店铺', ref: 'Shop.Shop' }, //
|
|
|
- goods: { type: String, required: false, zh: '商品', ref: 'Shop.Goods' }, //
|
|
|
+ goods: { type: Object, required: false, zh: '商品' }, // 复制商品过来
|
|
|
+ spec: { type: Object, required: false, zh: '规格' }, // 复制指定规格过来
|
|
|
+ config: { type: Object, required: false, zh: '设置' }, // 各种设置都放这里,一个一个字段写,写不完还得总更新
|
|
|
status: { type: String, required: false, default: '0', zh: '状态' }, // 字典:platformAct_goods_status
|
|
|
};
|
|
|
const schema = new Schema(goodsJoinAct, { toJSON: { getters: true, virtuals: true } });
|
|
|
schema.index({ id: 1 });
|
|
|
schema.index({ 'meta.createdAt': 1 });
|
|
|
-schema.index({ platformAct: 1 });
|
|
|
+schema.index({ platform_act: 1 });
|
|
|
+schema.index({ platform_act_type: 1 });
|
|
|
schema.index({ shop: 1 });
|
|
|
-schema.index({ goods: 1 });
|
|
|
+schema.index({ 'goods._id': 1 });
|
|
|
+schema.index({ 'spec._id': 1 });
|
|
|
schema.index({ status: 1 });
|
|
|
|
|
|
schema.plugin(metaPlugin);
|