Browse Source

用户行为优化1.0.5

huangzhiguo 1 year ago
parent
commit
d987f7bacd

+ 13 - 3
src/main/java/com/caimei365/user/controller/LoginApi.java

@@ -11,6 +11,7 @@ import com.caimei365.user.service.SellerService;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.http.HttpHeaders;
 import org.springframework.web.bind.annotation.*;
 
@@ -317,13 +318,22 @@ public class LoginApi {
 
     }
 
-    @ApiOperation(("机构站内消息点击统计"))
+    @ApiOperation(("机构站内消息/微信模板消息点击统计"))
     @GetMapping("/clubBehaviorInfo")
-    public ResponseJson clubBehaviorInfo(Integer userId, String link, Integer infoId, Integer productId, Integer orderId) {
+    public ResponseJson clubBehaviorInfo(Integer userId, String link, Integer accessType, Integer accessClient) {
         if (null == userId) {
             return ResponseJson.error(-1, "用户Id不能为空", null);
         }
-        return loginService.clubBehaviorInfo(userId, link);
+        if (StringUtils.isBlank(link)) {
+            return ResponseJson.error(-1, "链接不能为空", null);
+        }
+        if (null == accessType) {
+            return ResponseJson.error(-1, "访问类型不能为空", null);
+        }
+        if (null == accessClient) {
+            return ResponseJson.error(-1, "访问来源不能为空", null);
+        }
+        return loginService.clubBehaviorInfo(userId, link, accessType, accessClient);
     }
 
     @ApiOperation("供应商站内消息列表")

+ 3 - 1
src/main/java/com/caimei365/user/service/LoginService.java

@@ -93,9 +93,11 @@ public interface LoginService {
      * 推送访问(站内信) 记录
      * @param userId
      * @param link
+     * @param accessType
+     * @param accessClient
      * @return
      */
-    ResponseJson clubBehaviorInfo(Integer userId, String link);
+    ResponseJson clubBehaviorInfo(Integer userId, String link, Integer accessType, Integer accessClient);
 
     ResponseJson<PageInfo<MessageCenter>> shopMessageList(Integer commonId,Integer messageType,Integer source, int pageNum, int pageSize);
 

+ 107 - 55
src/main/java/com/caimei365/user/service/impl/LoginServiceImpl.java

@@ -719,10 +719,12 @@ public class LoginServiceImpl implements LoginService {
      *
      * @param userId
      * @param link
+     * @param accessType
+     * @param accessClient
      * @return
      */
     @Override
-    public ResponseJson clubBehaviorInfo(Integer userId, String link) {
+    public ResponseJson clubBehaviorInfo(Integer userId, String link, Integer accessType, Integer accessClient) {
         // 行为记录
         try {
             if (null == userId) {
@@ -732,16 +734,19 @@ public class LoginServiceImpl implements LoginService {
                 UserLoginVo user = loginMapper.getLoginUserByUserId(userId);
                 if (null != user) {
                     // 记录
-                    link = wwwDomain + link;
+                    // 网站需要加上域名,小程序不需要域名,无法访问
+                    if (0 == accessClient) {
+                        link = wwwDomain + link;
+                    }
                     CmBehaviorInfoPo behaviorInfo = clubMapper.getClubSpId(userId);
-                    setBehaviorInfo(behaviorInfo, link);
+                    setBehaviorInfo(behaviorInfo, link, accessType);
                     if (1 == user.getUserIdentity()) {
                         behaviorInfo.setSpId(user.getServiceProviderId());
                     } else {
                         behaviorInfo.setClubId(user.getClubId());
                     }
                     behaviorInfo.setOperateObject(1);
-                    behaviorInfo.setType(2);
+
                     clubMapper.insertBehaviorInfo(behaviorInfo);
                 }
             }
@@ -1333,8 +1338,8 @@ public class LoginServiceImpl implements LoginService {
                     String openid = messageCenterMapper.getOpenidListByPermission(unionId);
                     String time = current;
                     String remarkText = "绑定成功后,您可通过微信直接访问采美商城进行采购。";
-                    // 跳转到【小程序付款-选择支付方式页面】
-                    String pagePath = "https://www.caimei365.com/";
+                    // 绑定运营人员
+                    String pagePath = "/pages/user/operator/list?userBehaviorType=model";
                     // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
                     log.error("获取openid>>>>>" + openid);
                     weChatService.sendTemplateMessg(accessToken, openid, nickName, time, remarkText, pagePath);
@@ -1738,70 +1743,117 @@ public class LoginServiceImpl implements LoginService {
         return map;
     }
 
-    private void setBehaviorInfo(CmBehaviorInfoPo behaviorInfo, String link) {
+    /**
+     * 站内信链接标签处理
+     * @param behaviorInfo
+     * @param link
+     */
+    private void setBehaviorInfo(CmBehaviorInfoPo behaviorInfo, String link, Integer accessType) {
         Pattern compile = Pattern.compile("^[0-9]+$");
         behaviorInfo.setPagePath(link);
         String labels = "";
         Integer id = 0;
-        // 文章详情
-        // https://www.caimei365.com/info/detail-7855-1.html
-        if (link.contains("info") && link.contains("detail")) {
-            behaviorInfo.setPageType("文章详情");
-            String[] split = link.split("-");
-            for (String s : split) {
-                if (compile.matcher(s).matches()) {
-                    id = Integer.parseInt(s);
-                }
-            }
-            // 获取文章标签
-            labels = clubMapper.getInfoLabels(id);
-        }
-        // 商品详情
-        id = 0;
-        if (link.contains("product")) {
-            behaviorInfo.setPageType("商品详情");
-            String[] split = link.split("-");
-            // https://www.caimei365.com/product-7729.html
-            if (split.length <= 2) {
-                for (String s : split) {
-                    String str = s.substring(0, s.lastIndexOf(".html"));
-                    if (compile.matcher(str).matches()) {
-                        id = Integer.parseInt(str);
-                    }
-                }
-            } else {
-                // https://www.caimei365.com/product-7729-1.html
+        if ( 2 == accessType ) {
+            // 文章详情
+            // https://www.caimei365.com/info/detail-7855-1.html
+            if (link.contains("info") && link.contains("detail")) {
+                behaviorInfo.setPageType("文章详情");
+                String[] split = link.split("-");
                 for (String s : split) {
                     if (compile.matcher(s).matches()) {
                         id = Integer.parseInt(s);
                     }
                 }
+                // 获取文章标签
+                labels = clubMapper.getInfoLabels(id);
             }
-            // 获取商品标签
-            labels = clubMapper.getProductLabels(id);
-        }
-        // 网页
-        id = 0;
-        // https://www.caimei365.com/page-375.html
-        if (link.contains("topic") || link.contains("equipment") || link.contains("page") || link.contains("product/type") || link.contains("product/activity")
-                || link.contains("product/beauty") || link.contains("quickOperation/operation") || link.contains("cmpage/info")) {
-            behaviorInfo.setPageType("网页列表");
-            String[] split = link.split("-");
-            if (split.length <= 2) {
-                for (String s : split) {
-                    String str = s.substring(0, s.lastIndexOf(".html"));
-                    if (compile.matcher(str).matches()) {
-                        id = Integer.parseInt(str);
+            // 商品详情
+            id = 0;
+            if (link.contains("product")) {
+                behaviorInfo.setPageType("商品详情");
+                String[] split = link.split("-");
+                // https://www.caimei365.com/product-7729.html
+                if (split.length <= 2) {
+                    for (String s : split) {
+                        String str = s.substring(0, s.lastIndexOf(".html"));
+                        if (compile.matcher(str).matches()) {
+                            id = Integer.parseInt(str);
+                        }
+                    }
+                } else {
+                    // https://www.caimei365.com/product-7729-1.html
+                    for (String s : split) {
+                        if (compile.matcher(s).matches()) {
+                            id = Integer.parseInt(s);
+                        }
                     }
                 }
-            } else {
-                for (String s : split) {
-                    if (compile.matcher(s).matches()) {
-                        id = Integer.parseInt(s);
+                // 获取商品标签
+                labels = clubMapper.getProductLabels(id);
+            }
+            // 网页
+            id = 0;
+            // https://www.caimei365.com/page-375.html
+            if (link.contains("topic") || link.contains("equipment") || link.contains("page") || link.contains("product/type") || link.contains("product/activity")
+                    || link.contains("product/beauty") || link.contains("quickOperation/operation") || link.contains("cmpage/info")) {
+                behaviorInfo.setPageType("网页列表");
+                String[] split = link.split("-");
+                if (split.length <= 2) {
+                    for (String s : split) {
+                        String str = s.substring(0, s.lastIndexOf(".html"));
+                        if (compile.matcher(str).matches()) {
+                            id = Integer.parseInt(str);
+                        }
+                    }
+                } else {
+                    for (String s : split) {
+                        if (compile.matcher(s).matches()) {
+                            id = Integer.parseInt(s);
+                        }
                     }
                 }
+                labels = clubMapper.getPageLabels(id);
+            }
+            if (link.contains("caimei-paylist")) {
+                behaviorInfo.setPageType("线上支付");
+                labels = "线上支付";
+            }
+            if (link.contains("caimei-payunder")) {
+                behaviorInfo.setPageType("线下支付");
+                labels = "线下支付";
             }
-            labels = clubMapper.getPageLabels(id);
+            if (link.contains("user/order/detail")) {
+                behaviorInfo.setPageType("机构订单详情");
+                labels = "机构订单详情";
+            }
+            if (link.contains("/user/member")) {
+                behaviorInfo.setPageType("超级会员");
+                labels = "超级会员";
+            }
+            if (link.contains("/user/coupon")) {
+                behaviorInfo.setPageType("优惠券");
+                labels = "优惠券";
+            }
+            if (link.contains("/info/detail")) {
+                behaviorInfo.setPageType("文章中心");
+                labels = "文章中心";
+            }
+            behaviorInfo.setType(2);
+        } else {
+            if (link.contains("/member/member")) {
+                behaviorInfo.setPageType("超级会员");
+                labels = "超级会员";
+            }
+            if (link.contains("/operator/list")) {
+                behaviorInfo.setPageType("添加运营人员");
+                labels = "添加运营人员";
+            }
+            if (link.contains("/login/apply")) {
+                behaviorInfo.setPageType("升级审核");
+                labels = "升级审核";
+            }
+
+            behaviorInfo.setType(3);
         }
         behaviorInfo.setLabel(labels);
     }

+ 3 - 3
src/main/java/com/caimei365/user/service/impl/RegisterServiceImpl.java

@@ -1428,8 +1428,8 @@ public class RegisterServiceImpl implements RegisterService {
                         String date = "30";
                         String time = current;
                         String remarkText = "如在使用中有任何疑问,请在小程序内联系在线客服";
-                        // 跳转到【小程序付款-选择支付方式页面】
-                        String pagePath = "/pages/user/member/member";
+                        // 超级会员
+                        String pagePath = "/pages/user/member/member?userBehaviorType=model";
                         // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
                         log.error("获取openid>>>>>" + openid);
                         weChatService.sendTemplateMsgs(accessToken, openid, title, name, price, date, remarkText, pagePath);
@@ -1469,7 +1469,7 @@ public class RegisterServiceImpl implements RegisterService {
                         String date = current;
                         String remarkText = "如在使用中有任何疑问,请在小程序内联系在线客服";
                         // 跳转到【小程序付款-选择支付方式页面】
-                        String pagePath = "/pages/user/member/member";
+                        String pagePath = "/pages/user/member/member?userBehaviorType=model";
                         // sendTemplateMsg(openid, 标题, 金额, 收款日期, 备注, 跳转链接
                         log.error("获取openid>>>>>" + openid);
                         weChatService.sendTemplateMsg(accessToken, openid, date, remarkText, pagePath);

+ 12 - 0
src/main/resources/mapper/ClubMapper.xml

@@ -1356,6 +1356,12 @@
         <if test="allocation != null and allocation != ''">
             allocation,
         </if>
+        <if test="label != null and label != ''">
+            label,
+        </if>
+        <if test="pagePath != null and pagePath != ''">
+            pagePath,
+        </if>
         addTime,
         delFlag)
         values(
@@ -1371,6 +1377,12 @@
         <if test="allocation != null and allocation != ''">
             #{allocation},
         </if>
+        <if test="label != null and label != ''">
+            #{label},
+        </if>
+        <if test="pagePath != null and pagePath != ''">
+            #{pagePath},
+        </if>
         now(),
         0
         )