Przeglądaj źródła

1、用户行为统计添加pid属性;

Lawsun_M 1 rok temu
rodzic
commit
5c6b14cb92

+ 6 - 1
app/controller/home/statistic.js

@@ -11,6 +11,9 @@ module.exports = class StatisticController extends Base {
     return {
       user_id: that.ctx.rules.default(that.service.shop.getWebUserId())
         .number(),
+      pid: that.ctx.rules.name('商品分类父级ID')
+        .default(4)
+        .number(),
     };
   }
 
@@ -54,6 +57,7 @@ module.exports = class StatisticController extends Base {
           const createBrowse = await that.app.comoBean.instance({
             user_id: dataParse.user_id,
             product_id: dataParse.product_id,
+            pid: dataParse.pid,
             browse_count: 1,
             product_name: dataParse.product_name,
             browse_params: dataParse.browse_params ? dataParse.browse_params : '{}',
@@ -76,12 +80,13 @@ module.exports = class StatisticController extends Base {
             event_count: that.app.Sequelize.literal('event_count + ' + 1),
             event_params: dataParse.event_params ? dataParse.event_params : '{}',
             update_time: that.app.szjcomo.date('Y-m-d H:i:s'),
-          }, { where: { user_id: dataParse.user_id, event_name: dataParse.event_name }, transaction });
+          }, { where: { user_id: dataParse.user_id, event_name: dataParse.event_name, pid: dataParse.pid }, transaction });
           await that.app.comoBean.update(updateBrowse, that.app.model.UsersEventLogs, '用户行为记录更新失败,请稍候重试');
         } else {
           // 2023/7/26 create 用户行为
           const createBrowse = await that.app.comoBean.instance({
             user_id: dataParse.user_id,
+            pid: dataParse.pid,
             event_name: dataParse.event_name,
             event_count: 1,
             event_params: dataParse.event_params ? dataParse.event_params : '{}',

+ 4 - 0
app/models/mysql/usersEventLogs.js

@@ -35,6 +35,10 @@ module.exports = app => {
       type: DataTypes.DATE,
       allowNull: true,
     },
+    pid: {
+      type: DataTypes.INTEGER(4).UNSIGNED,
+      allowNull: true,
+    },
   }, {
     tableName: 'szj_users_event_logs',
   });

+ 4 - 0
app/models/mysql/usersProductBrowseLogs.js

@@ -39,6 +39,10 @@ module.exports = app => {
       type: DataTypes.DATE,
       allowNull: true,
     },
+    pid: {
+      type: DataTypes.INTEGER(4).UNSIGNED,
+      allowNull: true,
+    },
   }, {
     tableName: 'szj_users_product_browse_logs',
   });