lrf402788946 4 năm trước cách đây
mục cha
commit
23417cd6bb

+ 7 - 0
app/controller/.card.js

@@ -62,6 +62,7 @@ module.exports = {
         stockholder: "stockholder",
         wxaccount: "%wxaccount%",
         set: "set",
+        status: "status",
         "create_time@start": "create_time@start",
         "create_time@end": "create_time@end",
       },
@@ -99,4 +100,10 @@ module.exports = {
       // count: true,
     },
   },
+  // 用户审核
+  check: {
+    params: ["!id"],
+    requestBody: ["!status"],
+    service: "check",
+  },
 };

+ 5 - 1
app/model/card.js

@@ -15,7 +15,7 @@ const card = {
   name: { type: String, required: true }, // 姓名
   id_card: { type: String, required: true, lowercase: true }, // 身份证
   level: { type: Number, required: true, default: 1 }, // 等级
-  points: { type: Number, default: 600 }, // 积分
+  points: { type: Number, default: 0 }, // 积分
   recommend: { type: String }, // 推荐人
   r_mobile: { type: String }, // 推荐人电话
   car_show: { type: Boolean, default: false }, // 车奖
@@ -25,9 +25,13 @@ const card = {
     type: String,
     default: moment().format('YYYY-MM-DD HH:mm:ss'),
   }, // 创建/办卡 时间
+  status: { type: String, default: '1' }, // 审核状态:0=>可以使用;1=>禁止使用,需要审核
+  admin: { type: Boolean, default: false },
 };
 const schema = new Schema(card, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
+schema.index({ status: 1 });
+schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {
   const { mongoose } = app;

+ 1 - 0
app/model/carousel.js

@@ -11,6 +11,7 @@ const carousel = {
 };
 const schema = new Schema(carousel, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {
   const { mongoose } = app;

+ 1 - 0
app/model/cash.js

@@ -18,6 +18,7 @@ const cash = {
 };
 const schema = new Schema(cash, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {
   const { mongoose } = app;

+ 1 - 0
app/model/cash_error.js

@@ -11,6 +11,7 @@ const cashError = {
 };
 const schema = new Schema(cashError, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {
   const { mongoose } = app;

+ 1 - 0
app/model/config.js

@@ -12,6 +12,7 @@ const config = {
 };
 const schema = new Schema(config, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {
   const { mongoose } = app;

+ 1 - 0
app/model/place.js

@@ -11,6 +11,7 @@ const xzqh = {
 };
 const schema = new Schema(xzqh, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {
   const { mongoose } = app;

+ 1 - 0
app/model/record.js

@@ -14,6 +14,7 @@ const record = {
 };
 const schema = new Schema(record, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {
   const { mongoose } = app;

+ 1 - 0
app/model/set.js

@@ -12,6 +12,7 @@ const set = {
 };
 const schema = new Schema(set, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {
   const { mongoose } = app;

+ 1 - 0
app/model/xzqh.js

@@ -13,6 +13,7 @@ const xzqh = {
 };
 const schema = new Schema(xzqh, { toJSON: { virtuals: true } });
 schema.index({ id: 1 });
+schema.index({ 'meta.createdAt': 1 });
 schema.plugin(metaPlugin);
 module.exports = app => {
   const { mongoose } = app;

+ 1 - 0
app/router/card.js

@@ -6,6 +6,7 @@ module.exports = app => {
   const prefix = '/api/htyd';
   const index = 'card';
   const { router, controller } = app;
+  router.post(index, `${prefix}/${index}/check/:id`, controller[index].check);
   router.get(index, `${prefix}/${index}/group`, controller[index].group);
   router.post(index, `${prefix}/${index}/passwd/:id`, controller[index].passwd);
   router.resources(index, `${prefix}/${index}`, controller[index]); // index、create、show、destroy

+ 17 - 0
app/service/card.js

@@ -70,6 +70,23 @@ class CardService extends CrudService {
         '输入信息有误,用户创建失败!'
       );
     }
+    return user;
+    // 2021-04-02 12:00 修改,添加用户审核,需要将非创建用户部分移至通过审核后进行
+
+  }
+
+  async check({ id }, { status }) {
+    // 2021-04-02 12:00 修改,将积分计算部分移至用户审核后进行
+    const user = await this.model.findById(id);
+    if (!user) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '未找到用户信息');
+    if (status === '-1') {
+      //  审核不通过,直接删除用户
+      await this.model.deleteOne({ _id: ObjectId(id) });
+      return '审核未通过,用户已删除';
+    }
+    user.status = status;
+    await user.save();
+    const { set, r_mobile } = user;
     // 3,检查有没有推荐人,如果没有推荐人,那就完事了,有推荐人,还需要检查给推荐人加多少分
     if (!r_mobile) return user;
     const recommender = await this.model.findOne({ mobile: r_mobile });

+ 1 - 0
app/service/login.js

@@ -15,6 +15,7 @@ class LoginService extends CrudService {
     assert(password, '请填写密码');
     let user = await this.model.findOne({ mobile }, '+password');
     if (!user) throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '为找到该手机号的用户');
+    if (user.status !== '0') throw new BusinessError(ErrorCode.SERVICE_FAULT, '用户未通过审核,无法登陆');
     user = JSON.parse(JSON.stringify(user));
     const { password: up, meta, __v, ...userInfo } = user;
     const { secret } = up;