Browse Source

1、活跃/邀请用户列表区分办公/家用属性;

Lawsun_M 1 year ago
parent
commit
1902899e33
1 changed files with 33 additions and 13 deletions
  1. 33 13
      app/controller/home/statistic.js

+ 33 - 13
app/controller/home/statistic.js

@@ -139,15 +139,26 @@ module.exports = class StatisticController extends Base {
     const seq = that.app.Sequelize;
     try {
       // const dataParse = await that.ctx.validate(that.loginValidate, await that.ctx.anyParse());
-      // const dataParse = await that.ctx.anyParse();
+      const dataParse = await that.ctx.anyParse();
       const currentDateTime = that.app.szjcomo.date('Y-m-d H:i:s');
       const endTimeStamp = Date.parse(currentDateTime) - 15 * 24 * 60 * 60 * 1000;
-      const endDateTime = that.app.szjcomo.date('Y-m-d H:i:s', endTimeStamp / 1000);
+      // const endDateTime = that.app.szjcomo.date('Y-m-d H:i:s', endTimeStamp / 1000);
+      const whereOpts = {
+        intergral: { [seq.Op.gte]: 1 },
+        is_employee: false,
+        login_time: { [seq.Op.gte]: endTimeStamp },
+      };
+      if (dataParse.is_office) {
+        whereOpts.is_office = true;
+      }
+      if (dataParse.is_family) {
+        whereOpts.is_family = true;
+      }
       // 2023/7/26 查询
       const users = await that.app.model.Users.findAll({
         // attributes: [ 'user_id', 'nickname', 'intergral', 'money', 'commission', 'headimgurl' ],
-        order: [[ 'update_ttime', 'desc' ], [ 'intergral', 'desc' ]],
-        where: { intergral: { [seq.Op.gte]: 1 }, is_employee: false, update_ttime: { [seq.Op.gte]: endDateTime } },
+        order: [[ 'login_time', 'desc' ], [ 'intergral', 'desc' ]],
+        where: whereOpts,
       });
       return that.ctx.appJson(that.app.szjcomo.appResult('SUCCESS', { users }, false));
     } catch (err) {
@@ -166,12 +177,13 @@ module.exports = class StatisticController extends Base {
     const seq = that.app.Sequelize;
     try {
       const dataParse = await that.ctx.validate(that.loginValidate, await that.ctx.anyParse());
-      const currentDateTime = that.app.szjcomo.date('Y-m-d H:i:s');
-      const endTimeStamp = Date.parse(currentDateTime) - 30 * 24 * 60 * 60 * 1000;
-      const endDateTime = that.app.szjcomo.date('Y-m-d H:i:s', endTimeStamp / 1000);
+      // const currentDateTime = that.app.szjcomo.date('Y-m-d H:i:s');
+      // const endTimeStamp = Date.parse(currentDateTime) - 30 * 24 * 60 * 60 * 1000;
+      // const endDateTime = that.app.szjcomo.date('Y-m-d H:i:s', endTimeStamp / 1000);
       const selectBean = await that.app.comoBean.instance({}, {
         where: { inviter_id: dataParse.user_id },
-        create_time: { [seq.Op.gte]: endDateTime },
+        // create_time: { [seq.Op.gte]: endDateTime },
+        order: [[ 'create_time', 'desc' ]],
       });
       const myUsers = await that.service.base.select(selectBean, that.app.model.RelUserInviter, '查询邀请关联用户失败,请稍候重试', false, true);
 
@@ -179,12 +191,20 @@ module.exports = class StatisticController extends Base {
       for (const user of myUsers) {
         userIds.push(user.user_id);
       }
+      const whereOpts = {
+        user_id: { [seq.Op.in]: userIds },
+        intergral: { [seq.Op.gte]: 1 },
+        is_employee: false,
+      };
+      if (dataParse.is_office) {
+        whereOpts.is_office = true;
+      }
+      if (dataParse.is_family) {
+        whereOpts.is_family = true;
+      }
       const users = await that.app.model.Users.findAll({
-        where: {
-          user_id: { [seq.Op.in]: userIds },
-          intergral: { [seq.Op.gte]: 1 },
-        },
-        order: [[ 'update_ttime', 'desc' ], [ 'intergral', 'desc' ]],
+        where: whereOpts,
+        order: [[ 'login_time', 'desc' ], [ 'intergral', 'desc' ]],
       });
       return that.ctx.appJson(that.app.szjcomo.appResult('SUCCESS', { users }, false));
     } catch (err) {