12345678910111213141516171819202122232425262728293031323334353637 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const { ObjectId } = require('mongoose').Types;
- // 创新券表
- const coupons = {
- user_id: { type: ObjectId }, // 创建者id
- coupons_type: { type: String }, // 类型:科技创新券;研发补贴;奖励兑现
- name: { type: String }, // 名称
- discount_type: { type: String }, // 折扣类型: 全额折扣券;折扣券;定额折扣券
- use_type: { type: String }, // 使用服务类型
- classify: { type: String }, // 所属分类
- limit_time: { type: Number }, // 期限
- scale: { type: String }, // 抵扣比例-为折扣券
- allowance: { type: String }, // 面额
- total_allowance: { type: String }, // 券总额度
- desc: { type: String }, // 描述
- status: { type: String, default: '0' }, // 0:待上架;1:上架;-1:下架
- remark: { type: String },
- };
- const schema = new Schema(coupons, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ user_id: 1 });
- schema.index({ type: 1 });
- schema.index({ name: 1 });
- schema.index({ coupons_type: 1 });
- schema.index({ discount_type: 1 });
- schema.index({ use_type: 1 });
- schema.index({ classify: 1 });
- schema.index({ limit_time: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Coupons', schema, 'coupons');
- };
|