Browse Source

用户行为记录数据为空修复

huangzhiguo 2 years ago
parent
commit
aa8c767b03

+ 13 - 10
src/main/java/com/caimei365/tools/service/impl/CmBehaviorRecordServiceImpl.java

@@ -41,9 +41,10 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
             if (ipSavePo.getParams().contains("userId") || ipSavePo.getParams().contains("productId")) {
                 String[] split = ipSavePo.getParams().split("&");
                 for (String s : split) {
+                    String str = s.trim();
                     // 页面路径
-                    if (s.contains("pagePath") && s.contains("=")) {
-                        String[] split1 = s.split("=");
+                    if (str.startsWith("pagePath") && str.contains("=")) {
+                        String[] split1 = str.split("=");
                         if (split1.length > 1) {
                             String value = split1[1];
                             String trim = value.trim();
@@ -66,8 +67,10 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                         }
                     }
                     // 页面类型
-                    if (s.contains("pageType") && s.contains("=")) {
-                        String[] split1 = s.split("=");
+                    if (str.startsWith("pageType") && str.contains("=")) {
+                        String[] split1 = str.split("=");
+                        // 赋默认值
+                        cmBehaviorRecordPo.setPageType(0);
                         if (split1.length > 1) {
                             String value = split1[1];
                             String trim = value.trim();
@@ -79,8 +82,8 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                         }
                     }
                     // 页面标签
-                    if (s.contains("pageLabel") && s.contains("=")) {
-                        String[] split1 = s.split("=");
+                    if (str.startsWith("pageLabel") && str.contains("=")) {
+                        String[] split1 = str.split("=");
                         cmBehaviorRecordPo.setPageLabel("");
                         if (split1.length > 1) {
                             String value = split1[1];
@@ -102,8 +105,8 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                         }
                     }
                     // 商品ID
-                    if (s.contains("productId") && s.contains("=")) {
-                        String[] split1 = s.split("=");
+                    if (str.startsWith("productId") && str.contains("=")) {
+                        String[] split1 = str.split("=");
                         if (split1.length > 1) {
                             String value = split1[1];
                             String trim = value.trim();
@@ -113,8 +116,8 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
                         }
                     }
                     // 访问时长
-                    if (s.contains("accessDuration") && s.contains("=")) {
-                        String[] split1 = s.split("=");
+                    if (str.startsWith("accessDuration") && str.contains("=")) {
+                        String[] split1 = str.split("=");
                         if (split1.length > 1) {
                             String value = split1[1];
                             String trim = value.trim();