card.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. const { Secret } = require('naf-framework-mongoose/lib/model/schema');
  6. // 办卡表
  7. const card = {
  8. mobile: { type: String, required: true, maxLength: 11, unique: true }, // 电话
  9. password: { type: Secret, required: true, select: false }, // 密码
  10. province: { type: String, required: true }, // 省份
  11. city: { type: String }, // 省份
  12. set: { type: String, required: true }, // 169/129 套餐
  13. pay_type: { type: String }, // 支付方式
  14. name: { type: String, required: true }, // 姓名
  15. id_card: { type: String, required: true, lowercase: true }, // 身份证
  16. level: { type: Number, required: true, default: 1 }, // 等级
  17. points: { type: Number, default: 0 }, // 积分
  18. recommend: { type: String }, // 推荐人
  19. r_mobile: { type: String }, // 推荐人电话
  20. car_show: { type: Boolean, default: false }, // 车奖
  21. stockholder: { type: Boolean, default: false }, // 股东
  22. wxaccount: { type: String }, // 微信号(支付账号)
  23. create_time: {
  24. type: String,
  25. default: moment().format('YYYY-MM-DD HH:mm:ss'),
  26. }, // 创建/办卡 时间
  27. status: { type: String, default: '1' }, // 审核状态:0=>可以使用;1=>禁止使用,需要审核
  28. admin: { type: Boolean, default: false },
  29. };
  30. const schema = new Schema(card, { toJSON: { virtuals: true } });
  31. schema.index({ id: 1 });
  32. schema.index({ status: 1 });
  33. schema.index({ 'meta.createdAt': 1 });
  34. schema.plugin(metaPlugin);
  35. module.exports = app => {
  36. const { mongoose } = app;
  37. return mongoose.model('Card', schema, 'card');
  38. };