guhongwei 2 роки тому
батько
коміт
e433c373ca
3 змінених файлів з 16 додано та 29 видалено
  1. 0 13
      app/schedule/watchvip.js
  2. 14 14
      app/service/user.js
  3. 2 2
      config/config.default.js

+ 0 - 13
app/schedule/watchvip.js

@@ -1,13 +0,0 @@
-'use strict';
-module.exports = {
-  schedule: {
-    interval: '30s', // 1 分钟间隔
-    // cron: '0 0 23 * * *', // 每天晚上十一点
-    // cron: '5 * * * * ?', // 30s
-    type: 'worker', // 指定所有的 worker 都需要执行
-  },
-  async task(ctx) {
-    console.log('监听');
-    // ctx.service.user.watchvip();
-  },
-};

+ 14 - 14
app/service/user.js

@@ -45,20 +45,20 @@ class UserService extends CrudService {
     return token;
   }
   // 监听用户vip信息
-  async watchvip() {
-    const list = [];
-    const data = await this.model.find();
-    for (const val of data) {
-      if (val.is_vip === '1') {
-        if (moment().isAfter(val.vip_end_time)) list.push(val);
-      }
-    }
-    if (list.length > 0) {
-      for (const val of list) {
-        await this.model.updateOne({ _id: ObjectId(val._id) }, { is_vip: '0' });
-      }
-    }
-  }
+  // async watchvip() {
+  //   const list = [];
+  //   const data = await this.model.find();
+  //   for (const val of data) {
+  //     if (val.is_vip === '1') {
+  //       if (moment().isAfter(val.vip_end_time)) list.push(val);
+  //     }
+  //   }
+  //   if (list.length > 0) {
+  //     for (const val of list) {
+  //       await this.model.updateOne({ _id: ObjectId(val._id) }, { is_vip: '0' });
+  //     }
+  //   }
+  // }
 }
 
 module.exports = UserService;

+ 2 - 2
config/config.default.js

@@ -19,12 +19,12 @@ module.exports = appInfo => {
   };
   // http请求前缀
   config.httpPrefix = {
-    logs: 'http://localhost:10101/projectadmin/api',
+    logs: 'http://localhost:10108/projectadmin/api',
   };
   // 进程设置
   config.cluster = {
     listen: {
-      port: 10102,
+      port: 10109,
     },
   };
   // jwt设置