Kaynağa Gözat

1、每日用户登录数量查询;

Lawsun 1 yıl önce
ebeveyn
işleme
cd163bb3c3

+ 15 - 17
.idea/workspace.xml

@@ -1,13 +1,11 @@
 <?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、时间倒序;">
-      <change afterPath="$PROJECT_DIR$/app/models/mysql/user_login_logs.js" afterDir="false" />
-      <change afterPath="$PROJECT_DIR$/app/schedule/dayUsers.js" afterDir="false" />
+    <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/RelInviter.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/controller/home/RelInviter.js" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/app/controller/home/user.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/controller/home/user.js" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/schedule/dayUsers.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/schedule/dayUsers.js" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/app/service/manager.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/service/manager.js" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/app/service/order.js" beforeDir="false" afterPath="$PROJECT_DIR$/app/service/order.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" />
@@ -63,7 +61,7 @@
     "node.js.detected.package.eslint": "true",
     "node.js.selected.package.eslint": "(autodetect)",
     "nodejs_package_manager_path": "npm",
-    "settings.editor.selected.configurable": "preferences.keymap",
+    "settings.editor.selected.configurable": "advanced.settings",
     "ts.external.directory.path": "D:\\Program Files (x86)\\WebStorm 2022.2.1\\plugins\\JavaScriptLanguage\\jsLanguageServicesImpl\\external",
     "vue.rearranger.settings.migration": "true"
   },
@@ -269,14 +267,7 @@
       <workItem from="1692582714108" duration="4090000" />
       <workItem from="1692666690140" duration="5486000" />
       <workItem from="1692752289886" duration="4795000" />
-      <workItem from="1692840290649" duration="31392000" />
-    </task>
-    <task id="LOCAL-00025" summary="1.支持配置无分佣的分类,该分类下商品推荐购买不获得分佣;">
-      <created>1671889807711</created>
-      <option name="number" value="00025" />
-      <option name="presentableId" value="LOCAL-00025" />
-      <option name="project" value="LOCAL" />
-      <updated>1671889807711</updated>
+      <workItem from="1692840290649" duration="36047000" />
     </task>
     <task id="LOCAL-00026" summary="1.支持配置无红包优惠的分类,该分类下的商品不能使用红包优惠;">
       <created>1671899979174</created>
@@ -614,7 +605,14 @@
       <option name="project" value="LOCAL" />
       <updated>1692153818840</updated>
     </task>
-    <option name="localTasksCounter" value="74" />
+    <task id="LOCAL-00074" summary="1、每日用户登录记录;">
+      <created>1693124235814</created>
+      <option name="number" value="00074" />
+      <option name="presentableId" value="LOCAL-00074" />
+      <option name="project" value="LOCAL" />
+      <updated>1693124235815</updated>
+    </task>
+    <option name="localTasksCounter" value="75" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
@@ -660,7 +658,6 @@
     </option>
   </component>
   <component name="VcsManagerConfiguration">
-    <MESSAGE value="1.补充餐店经纬度位置;2.补充餐店订单更新排名;" />
     <MESSAGE value="1.补充餐店排序字段;" />
     <MESSAGE value="1.参数错误文案调整;" />
     <MESSAGE value="1.补充所有合作餐店可以核销通用电子餐费的逻辑;" />
@@ -685,7 +682,8 @@
     <MESSAGE value="1、用户统计详情;" />
     <MESSAGE value="1、我邀请的用户活跃列表;" />
     <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>

+ 2 - 2
app/schedule/dayUsers.js

@@ -39,9 +39,9 @@ class dayUsers extends Subscription {
         order: [[ 'update_ttime', 'asc' ]],
         attributes: [ 'user_id', 'nickname', 'headimgurl', 'login_time', 'update_ttime' ],
       });
-
+      const result = JSON.parse(JSON.stringify(users));
       // 2023/8/27 批量创建用户登录记录
-      const datas = await users.map(item => {
+      const datas = await result.map(item => {
         return Object.assign(item, {
           create_time: that.app.szjcomo.date('Y-m-d H:i:s'),
         });

+ 36 - 0
app/service/manager.js

@@ -120,6 +120,7 @@ module.exports = class ManagerService extends BaseService {
         ],
         baseData: await that.service.order.orderDataCount(),
         saleData: await that.service.order.saleDataCount(),
+        loginData: await that.userLoginDataCount(),
       };
       await that.service.redis.set(cacheKey, result, 10 * 60);
     }
@@ -145,4 +146,39 @@ module.exports = class ManagerService extends BaseService {
     return result;
   }
 
+  /**
+   * [userLoginDataCount 最近每日用户登录数量统计]
+   * @return {[type]} [description]
+   */
+  async userLoginDataCount(day = 20) {
+    const that = this;
+    const curTime = that.app.szjcomo.time();
+    const seq = that.app.Sequelize;
+    const times = [];
+    for (let i = 0; i < day; i++) {
+      const tmpTime = curTime - i * 24 * 60 * 60;
+      times.push([ `${that.app.szjcomo.date('Y-m-d', tmpTime)} 00:00:00`, `${that.app.szjcomo.date('Y-m-d', tmpTime)} 23:59:59` ]);
+    }
+    const users = await that.app.model.UserLoginLogs.findAll({
+      where: {
+        update_ttime: { [seq.Op.between]: [ times[day - 1][0], times[0][1] ] },
+      }, raw: true,
+    });
+    const result = [];
+    times.forEach(item => {
+      const startTime = that.app.szjcomo.strToTime(item[0]);
+      const endTime = that.app.szjcomo.strToTime(item[1]);
+      const tmpData = { date: that.app.szjcomo.date('m-d', startTime), count: 0 };
+      users.forEach(childItem => {
+        const tmpTime = that.app.szjcomo.strToTime(childItem.update_ttime);
+        if (tmpTime >= startTime && tmpTime <= endTime) {
+          tmpData.count += 1;
+        }
+      });
+      result.push(tmpData);
+    });
+    return result;
+  }
+
+
 };

+ 1 - 1
app/service/order.js

@@ -182,7 +182,7 @@ class OrderService extends ShopService {
    * [saleDataCount 销售数量统计]
    * @return {[type]} [description]
    */
-  async saleDataCount(day = 15) {
+  async saleDataCount(day = 20) {
     const that = this;
     const curTime = that.app.szjcomo.time();
     const seq = that.app.Sequelize;

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
node_modules/egg-ts-helper/.tmp/eggInfo.json


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor