Browse Source

1、我邀请的用户活跃列表;

Lawsun 1 year ago
parent
commit
4bebb2ad8e

+ 17 - 12
.idea/workspace.xml

@@ -1,9 +1,12 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
   <component name="ChangeListManager">
-    <list default="true" id="08cfebb0-a4a4-47ee-a307-566aa06f29bb" name="Default Changelist" comment="1、统计;">
+    <list default="true" id="08cfebb0-a4a4-47ee-a307-566aa06f29bb" name="Default Changelist" comment="1、用户统计详情;">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/app/controller/home/statistic.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/controller/home/statistic.js" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/models/mysql/rel_user_inviter.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/models/mysql/rel_user_inviter.js" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/models/mysql/users.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/models/mysql/users.js" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/routers/home/shop.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/routers/home/shop.js" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/node_modules/egg-ts-helper/.tmp/eggInfo.json" beforeDir="false" afterPath="$PROJECT_DIR$/node_modules/egg-ts-helper/.tmp/eggInfo.json" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
@@ -255,14 +258,9 @@
       <workItem from="1689384833956" duration="6286000" />
       <workItem from="1689558398171" duration="37385000" />
       <workItem from="1690506765249" duration="16389000" />
-      <workItem from="1691058586577" duration="5807000" />
-    </task>
-    <task id="LOCAL-00022" summary="1.代理申请,短信验证;">
-      <created>1670899723089</created>
-      <option name="number" value="00022" />
-      <option name="presentableId" value="LOCAL-00022" />
-      <option name="project" value="LOCAL" />
-      <updated>1670899723089</updated>
+      <workItem from="1691058586577" duration="6589000" />
+      <workItem from="1691547091961" duration="8363000" />
+      <workItem from="1691635063702" duration="14049000" />
     </task>
     <task id="LOCAL-00023" summary="1.记录显示红包/分佣来源用户信息;">
       <created>1670992932618</created>
@@ -600,7 +598,14 @@
       <option name="project" value="LOCAL" />
       <updated>1690420695156</updated>
     </task>
-    <option name="localTasksCounter" value="71" />
+    <task id="LOCAL-00071" summary="1、用户统计详情;">
+      <created>1691246300646</created>
+      <option name="number" value="00071" />
+      <option name="presentableId" value="LOCAL-00071" />
+      <option name="project" value="LOCAL" />
+      <updated>1691246300647</updated>
+    </task>
+    <option name="localTasksCounter" value="72" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
@@ -646,7 +651,6 @@
     </option>
   </component>
   <component name="VcsManagerConfiguration">
-    <MESSAGE value="1.餐币有效期;" />
     <MESSAGE value="1.修复餐币发放数量错误的bug;" />
     <MESSAGE value="1.增加合作餐店列表接口;" />
     <MESSAGE value="1.补充餐店经纬度位置;2.补充餐店订单更新排名;" />
@@ -671,7 +675,8 @@
     <MESSAGE value="1.暂存;" />
     <MESSAGE value="1.gte 大于等于 ;" />
     <MESSAGE value="1、统计;" />
-    <option name="LAST_COMMIT_MESSAGE" value="1、统计;" />
+    <MESSAGE value="1、用户统计详情;" />
+    <option name="LAST_COMMIT_MESSAGE" value="1、用户统计详情;" />
   </component>
   <component name="XDebuggerManager">
     <breakpoint-manager>

+ 39 - 2
app/controller/home/statistic.js

@@ -115,11 +115,11 @@ module.exports = class StatisticController extends Base {
       const dataParse = await that.ctx.anyParse();
       // 2023/7/26 查询用户统计记录列表
       const resultBrowse = await that.app.model.UsersProductBrowseLogs.findAll({
-        order: [[ 'browse_count', 'desc' ]],
+        order: [[ 'update_time', 'desc' ], [ 'browse_count', 'desc' ]],
         where: { user_id: dataParse.user_id },
       });
       const resultEvent = await that.app.model.UsersEventLogs.findAll({
-        order: [[ 'event_count', 'desc' ]],
+        order: [[ 'update_time', 'desc' ], [ 'event_count', 'desc' ]],
         where: { user_id: dataParse.user_id },
       });
       return that.ctx.appJson(that.app.szjcomo.appResult('SUCCESS', { resultBrowse, resultEvent }, false));
@@ -153,4 +153,41 @@ module.exports = class StatisticController extends Base {
     }
   }
 
+  /**
+   *  我邀请的活跃用户列表
+   * @return {Promise<*>}
+   */
+  async myActiveUsers() {
+    const that = this;
+    // const transaction = await that.app.model.transaction();
+    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 selectBean = await that.app.comoBean.instance({}, {
+        where: { inviter_id: dataParse.user_id },
+        create_time: { [seq.Op.gte]: endDateTime },
+      });
+      const myUsers = await that.service.base.select(selectBean, that.app.model.RelUserInviter, '查询邀请关联用户失败,请稍候重试', false, true);
+
+      const userIds = [];
+      for (const user of myUsers) {
+        userIds.push(user.user_id);
+      }
+      const users = await that.app.model.Users.findAll({
+        where: {
+          user_id: { [seq.Op.in]: userIds },
+          intergral: { [seq.Op.gte]: 1 },
+        },
+        order: [[ 'intergral', 'desc' ]],
+      });
+      return that.ctx.appJson(that.app.szjcomo.appResult('SUCCESS', { users }, false));
+    } catch (err) {
+      console.log(err);
+      return that.ctx.appJson(that.app.szjcomo.appResult(err.message));
+    }
+  }
+
 };

+ 2 - 1
app/models/mysql/rel_user_inviter.js

@@ -28,7 +28,8 @@ module.exports = app => {
   });
 
   Model.associate = function() {
-
+    // 关联用户表
+    // Model.hasOne(app.model.Users, { foreignKey: 'user_id', targetKey: 'user_id', as: 'user' });
   };
   // 同步:没有就新建,有就不变
   Model.sync();

+ 2 - 0
app/models/mysql/users.js

@@ -107,6 +107,8 @@ module.exports = app => {
     Model.hasMany(app.model.Collects, { foreignKey: 'user_id', targetKey: 'user_id', as: 'collects' });
     // 关联代理认证申请
     Model.hasOne(app.model.ProxyApplyLogs, { foreignKey: 'user_id', targetKey: 'user_id', as: 'proxyApplyLogs' });
+
+    // Model.hasOne(app.model.RelUserInviter, { foreignKey: 'user_id', targetKey: 'user_id', as: 'relUser' });
   };
   // 同步:没有就新建,有就不变
   Model.sync();

+ 2 - 0
app/routers/home/shop.js

@@ -126,5 +126,7 @@ module.exports = app => {
   subRouter.get('/statisticLogs', webLogin, shops.statistic.statisticLogsList);
   // 2023/7/25 活跃用户列表
   subRouter.get('/activeUsers', shops.statistic.activeUsers);
+  // 2023/7/25 我邀请的活跃用户列表
+  subRouter.get('/myActiveUsers', shops.statistic.myActiveUsers);
 
 };

File diff suppressed because it is too large
+ 0 - 0
node_modules/egg-ts-helper/.tmp/eggInfo.json


Some files were not shown because too many files changed in this diff