card.js 1.5 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. const zf = new Schema({
  7. mobile: { type: String, maxLength: 200 },
  8. account: { type: String, maxLength: 200 },
  9. name: { type: String, maxLength: 200 },
  10. remark: { type: String, maxLength: 200 },
  11. });
  12. // 办卡表
  13. const card = {
  14. mobile: { type: String, required: true, maxLength: 11, unique: true }, // 电话
  15. password: { type: Secret, required: true, select: false }, // 密码
  16. province: { type: String, required: true }, // 省份
  17. set: { type: String, required: true }, // 169/129 套餐
  18. pay_type: { type: String }, // 支付方式
  19. name: { type: String, required: true }, // 姓名
  20. id_card: { type: String, required: true, lowercase: true }, // 身份证
  21. level: { type: String, required: true, default: '1' }, // 等级
  22. points: { type: Number, default: 600 }, // 积分
  23. recommend: { type: String }, // 推荐人
  24. r_mobile: { type: String }, // 推荐人电话
  25. zf: { type: zf }, // 支付设置
  26. create_time: {
  27. type: String,
  28. default: moment().format('YYYY-MM-DD HH:mm:ss'),
  29. }, // 创建/办卡 时间
  30. };
  31. const schema = new Schema(card, { toJSON: { virtuals: true } });
  32. schema.index({ id: 1 });
  33. schema.plugin(metaPlugin);
  34. module.exports = app => {
  35. const { mongoose } = app;
  36. return mongoose.model('Card', schema, 'card');
  37. };