huangzhiguo пре 1 година
родитељ
комит
4951740ef3

+ 26 - 0
src/main/java/com/caimei365/tools/mapper/CmBehaviorRecordMapper.java

@@ -441,5 +441,31 @@ public interface CmBehaviorRecordMapper {
      * @param cmClubLabelPo
      */
     void updateClubLabel(CmClubLabelPo cmClubLabelPo);
+
+    /**
+     * 机构数据
+     * @return
+     */
+    List<CmClubPo> getClubData();
+
+    /**
+     * 机构访问标签及类型
+     * @param accessDate
+     * @return
+     */
+    List<CmBehaviorRecordPo> getClubBehaviorPage(@Param("accessDate") String accessDate);
+
+    /**
+     * 保存机构日常访问数据
+     * @param cmBehaviorInfo
+     */
+    void insertBehaviorInfo(CmBehaviorInfo cmBehaviorInfo);
+
+    /**
+     *
+     * @param accessDate
+     * @return
+     */
+    List<ClubRemarksPo> getClubRemarks(@Param("accessDate") String accessDate);
 }
 

+ 164 - 0
src/main/java/com/caimei365/tools/model/po/ClubRemarksPo.java

@@ -0,0 +1,164 @@
+package com.caimei365.tools.model.po;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * Description
+ *
+ * @author : Aslee
+ * @date : 2021/9/26
+ */
+@ApiModel("机构资料备注")
+@Data
+public class ClubRemarksPo implements Serializable {
+    /**
+     * 机构id
+     */
+    private Integer clubId;
+
+    /**
+     * 备注id
+     */
+    private Integer remarksId;
+    /**
+     * 机构名称
+     */
+    private String clubName;
+    /**
+     * 记录的咨询类别
+     */
+    private String consultType;
+
+    /**
+     * 手机号
+     */
+    private String contractMobile;
+    /**
+     * 咨询类别
+     */
+    private String consult;
+
+    /**
+     * 协销id
+     */
+    private Integer serviceProviderId;
+    /**
+     * 组长id/管理员id
+     */
+    private Integer leaderId;
+    /**
+     * 管理员姓名
+     */
+    private String leaderName;
+    /**
+     * 文字备注/关键词
+     */
+    private String remarks;
+    /**
+     * 1 已注册记录  2  未注册记录
+     */
+    private Integer type;
+    /**
+     * 添加时间
+     */
+    private Date addTime;
+
+    private String startTime;
+
+
+    private String endTime;
+    /**
+     * 咨询人
+     */
+    private String questionMan;
+    /**
+     * 时分 时间
+     */
+    private String divisionTime;
+
+    /**
+     * 机构类型
+     */
+    private String clubType;
+    /**
+     * 价格敏感度
+     */
+    private Integer pinceSensitve;
+    /**
+     * 意向程度
+     */
+    private Integer satisfied;
+    /**
+     * 跟进状态
+     */
+    private Integer followup;
+    /**
+     * 额外说明
+     */
+    private String extra;
+    /**
+     * 关联事由
+     */
+    private String reportText;
+
+    private String auditName;
+    /**
+     * 状态 1.已审核 2.待审核 3.审核未通过
+     */
+    private Integer reportStatus;
+    /**
+     * 审核时间
+     */
+    private String auditTime;
+    /**
+     * 报备记录id
+     */
+    private Integer reportId;
+
+    private Integer number;
+
+    private Integer numbers;
+    /**
+     * 是否注册 0 全部 1 未注册 2已注册
+     */
+    private Integer isRegister;
+    /**
+     * 沟通情况 0 已沟通 1联系不上
+     */
+    private Integer communicationSituation;
+    /**
+     * 沟通方式 0:电话,微信 1:电话 2:微信
+     */
+    private String communicationMethods;
+    /**
+     * 客户来源 0 公众号 1 小红书 2 微博 3 搜狐 4 其他
+     */
+    private Integer customerSource;
+    /**
+     * 客户性别 0 男 1 女
+     */
+    private Integer customerGender;
+    /**
+     * 客户年龄
+     */
+    private String customerAge;
+    /**
+     * 加群情况 0 以加群 1 未加群
+     */
+    private Integer groupAddition;
+    /**
+     * 动态标签
+     */
+    private String trendsKeyword;
+    /**
+     * 静态标签
+     */
+    private String stateKeyword;
+}

+ 63 - 0
src/main/java/com/caimei365/tools/model/po/CmBehaviorInfo.java

@@ -0,0 +1,63 @@
+package com.caimei365.tools.model.po;
+
+import lombok.Data;
+
+/**
+ * Description
+ *
+ * @author : hzg
+ * @date : 2024/1/19
+ */
+@Data
+public class CmBehaviorInfo {
+    private Integer id;
+    /**
+     * 操作对象 1 机构 2 协销 3 客服 4 系统
+     */
+    private Integer operateObject;
+    /**
+     * 机构Id
+     */
+    private Integer clubId;
+    /**
+     * 协销Id
+     */
+    private Integer spId;
+    /**
+     * 1:日常访问; 2:推送访问(站内信); 3: 推送访问(短信); 4: 推送访问(微信模板消息):
+     * 5: 下单; 6: 收藏商品; 7: 加购物车; 8: 内容库访问; 9: 咨询记录,10: 分配协销
+     */
+    private Integer type;
+    /**
+     * 页面类型
+     */
+    private String pageType;
+    /**
+     * 标签
+     */
+    private String label;
+    /**
+     * 页面路径
+     */
+    private String pagePath;
+    /**
+     * 商品Id
+     */
+    private String productId;
+    /**
+     * 子订单Id, 多个使用逗号隔开
+     */
+    private String shopOrderId;
+    /**
+     * 分配人
+     */
+    private String allocation;
+    /**
+     * 添加时间
+     */
+    private String addTime;
+    /**
+     * 删除标记 0未删除 1已删除
+     */
+    private Integer delFlag;
+}

+ 25 - 0
src/main/java/com/caimei365/tools/model/po/CmClubPo.java

@@ -0,0 +1,25 @@
+package com.caimei365.tools.model.po;
+
+import lombok.Data;
+
+/**
+ * Description
+ *
+ * @author : hzg
+ * @date : 2024/1/19
+ */
+@Data
+public class CmClubPo {
+    /**
+     * 机构Id
+     */
+    private Integer clubId;
+    /**
+     * 用户Id
+     */
+    private Integer userId;
+    /**
+     * 协销Id
+     */
+    private Integer spId;
+}

+ 5 - 0
src/main/java/com/caimei365/tools/service/CmBehaviorRecordService.java

@@ -39,4 +39,9 @@ public interface CmBehaviorRecordService {
      * @param endTime
      */
     void clubDemand(String startTime, String endTime);
+
+    /**
+     * 机构日常数据,咨询记录清洗
+     */
+    void clubBehaviorInfo();
 }

+ 81 - 0
src/main/java/com/caimei365/tools/service/impl/CmBehaviorRecordServiceImpl.java

@@ -1109,6 +1109,87 @@ public class CmBehaviorRecordServiceImpl implements CmBehaviorRecordService {
         log.info("机构需求标签====统计结束");
     }
 
+    /**
+     * 机构日常数据,咨询记录清洗
+     */
+    @Override
+    public void clubBehaviorInfo() {
+        log.info("机构行为记录数据清洗");
+        // 获取昨日日期
+        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date());
+        calendar.add(Calendar.DAY_OF_MONTH, -1);
+        Date time = calendar.getTime();
+        String format = dateFormat.format(time);
+        // 机构数据
+        List<CmClubPo> clubData = recordMapper.getClubData();
+        // 机构访问标签及类型
+        List<CmBehaviorRecordPo> clubBehaviorPage = recordMapper.getClubBehaviorPage(format);
+        // 机构咨询记录
+        List<ClubRemarksPo> clubRemarks = recordMapper.getClubRemarks(format);
+        if (null != clubData && clubData.size() > 0) {
+            for (CmClubPo club : clubData) {
+                // 日常访问
+                if (null != clubBehaviorPage && clubBehaviorPage.size() > 0) {
+                    // 机构昨日浏览数据
+                    List<CmBehaviorRecordPo> clubBehavior = clubBehaviorPage.stream().filter(re -> re.getUserId().equals(club.getUserId().toString())).collect(Collectors.toList());
+                    // 访问日常
+                    if (null != clubBehavior && clubBehavior.size() > 0) {
+                        CmBehaviorInfo cmBehaviorInfo = new CmBehaviorInfo();
+                        cmBehaviorInfo.setClubId(club.getClubId());
+                        cmBehaviorInfo.setSpId(club.getSpId());
+                        cmBehaviorInfo.setOperateObject(1);
+                        cmBehaviorInfo.setType(1);
+                        // 设置机构访问页面类型和标签
+                        List<CmBehaviorRecordPo> collect = clubBehavior.stream().filter(be -> StringUtils.isNotBlank(be.getPageLabels())).collect(Collectors.toList());
+                        List<String> pageLabelList = collect.stream().map(CmBehaviorRecordPo::getPageLabels).collect(Collectors.toList());
+                        String strip = StringUtils.strip(pageLabelList.toString(), "[]");
+                        if (StringUtils.isNotBlank(strip)) {
+                            cmBehaviorInfo.setLabel(strip.endsWith(".") ? strip.substring(strip.length() - 1) : strip);
+                        } else {
+                            cmBehaviorInfo.setLabel("");
+                        }
+                        List<CmBehaviorRecordPo> collect1 = clubBehavior.stream().filter(be -> StringUtils.isNotBlank(be.getPageTypes())).collect(Collectors.toList());
+                        List<String> pageTypesList = collect1.stream().map(CmBehaviorRecordPo::getPageTypes).collect(Collectors.toList());
+                        String strip1 = StringUtils.strip(pageTypesList.toString(), "[]");
+                        if (StringUtils.isNotBlank(strip1)) {
+                            cmBehaviorInfo.setPageType(strip1);
+                        } else {
+                            cmBehaviorInfo.setPageType("");
+                        }
+                        recordMapper.insertBehaviorInfo(cmBehaviorInfo);
+                    }
+                }
+                // 咨询记录
+                if (null != clubRemarks && clubRemarks.size() > 0) {
+                    // 机构咨询记录
+                    List<ClubRemarksPo> clubRemarkList = clubRemarks.stream().filter(re -> re.getClubId().equals(club.getClubId())).collect(Collectors.toList());
+                    if (null != clubRemarkList && clubRemarkList.size() > 0) {
+                        CmBehaviorInfo cmBehaviorInfo = new CmBehaviorInfo();
+                        cmBehaviorInfo.setClubId(club.getClubId());
+                        cmBehaviorInfo.setSpId(club.getSpId());
+                        cmBehaviorInfo.setOperateObject(2);
+                        cmBehaviorInfo.setType(9);
+                        List<String> labels = new ArrayList<>();
+                        for (ClubRemarksPo clubRemarksPo : clubRemarkList) {
+                            if (StringUtils.isNotBlank(clubRemarksPo.getTrendsKeyword())){
+                                labels.add(clubRemarksPo.getTrendsKeyword());
+                            }
+                            if (StringUtils.isNotBlank(clubRemarksPo.getStateKeyword())) {
+                                labels.add(clubRemarksPo.getStateKeyword());
+                            }
+                        }
+                        String strip = StringUtils.strip(labels.toString(), "[]");
+                        cmBehaviorInfo.setLabel(StringUtils.isNotBlank(strip)? strip : "");
+                        recordMapper.insertBehaviorInfo(cmBehaviorInfo);
+                    }
+                }
+            }
+        }
+        log.info("机构行为记录数据清洗结束");
+    }
+
 
     // 获取IP对应地址 ---- 太平洋
     public static String recordIp(String ip) throws IOException {

+ 10 - 1
src/main/java/com/caimei365/tools/task/CmOrganValueSystemTask.java

@@ -111,5 +111,14 @@ public class CmOrganValueSystemTask {
         instance.add(Calendar.DAY_OF_MONTH, -1);
         Date time = instance.getTime();
         String startTime = dateFormat.format(time);
-        cmBehaviorRecordService.clubDemand(startTime, endTime); }
+        cmBehaviorRecordService.clubDemand(startTime, endTime);
+    }
+
+    /**
+     * 机构日常数据,咨询记录清洗
+     */
+    @Scheduled(cron = "0 25 0 * * ?")
+    public void getClubBehaviorInfo() {
+        cmBehaviorRecordService.clubBehaviorInfo();
+    }
 }

+ 80 - 0
src/main/resources/mapper/CmBehaviorRecordMapper.xml

@@ -722,5 +722,85 @@
         set appearNumber = #{appearNumber}
         where id = #{id}
     </update>
+
+    <select id="getClubData" resultType="com.caimei365.tools.model.po.CmClubPo">
+        select clubId, userId, spId from club
+    </select>
+
+    <select id="getClubBehaviorPage" resultType="com.caimei365.tools.model.po.CmBehaviorRecordPo">
+        SELECT
+            b.IP,
+            b.userID,
+            c.clubID,
+            GROUP_CONCAT(b.pageLabel) as pageLabels,
+            GROUP_CONCAT(cpt.pageType) as pageTypes,
+            b.delFlag
+        FROM cm_behavior_record b
+                 LEFT JOIN cm_page_type cpt ON b.pageType = cpt.id
+                 LEFT JOIN USER u ON b.userID = u.userID
+                 LEFT JOIN club c ON b.userID = c.userID
+        WHERE  b.IP != '106.55.202.118' AND b.delFlag = 0  AND b.accessDate = #{accessDate}
+          AND b.region NOT LIKE '%美国Microsoft公司%' AND b.region NOT LIKE '%亚马逊(Amazon)公司%'
+        GROUP BY b.IP, b.accessDate,b.userID ORDER BY b.accessTime DESC
+    </select>
+
+    <insert id="insertBehaviorInfo">
+        insert into cm_behavior_info(
+                                     operateObject,
+                                     clubId,
+                                     <if test="spId != null">
+                                        spId,
+                                     </if>
+                                     type,
+                                     <if test="pageType != null and pageType != ''">
+                                        pageType,
+                                     </if>
+                                     label,
+                                     addTime,
+                                     delFlag)
+        values(
+               #{operateObject},
+               #{clubId},
+                <if test="spId != null">
+                    #{spId},
+                </if>
+               #{type},
+                <if test="pageType != null and pageType != ''">
+                    #{pagetType},
+                </if>
+               #{label},
+               now(),
+               0
+               )
+    </insert>
+
+    <select id="getClubRemarks" resultType="com.caimei365.tools.model.po.ClubRemarksPo">
+        SELECT DISTINCT
+            ccr.id AS remarksId, ccr.remarks,  ccr.addTime, ccr.questionMan,
+            IFNULL(ccr.consultType,'') AS consult,
+            ccr.clubType, ccr.pinceSensitve, ccr.satisfied, ccr.followup, ccr.extra,
+            ccr.communicationSituation, ccr.communicationMethods, ccr.customerSource, ccr.customerGender, ccr.groupAddition,
+            ccr.customerAge, ccr.trendsKeyword, ccr.stateKeyword
+        FROM cm_club_remarks ccr
+        WHERE  ccr.addTime LIKE concat('%', #{accessDate}, '%')
+          AND trendsKeyword IS NOT NULL AND stateKeyword IS NOT NULL
+        UNION
+
+        SELECT DISTINCT
+            ccr.id AS remarksId, ccr.remarks, ccr.addTime, ccr.questionMan,
+            IFNULL(ccr.consultType,'') AS consult,
+            ccr.clubType, ccr.pinceSensitve, ccr.satisfied, ccr.followup, ccr.extra,
+            ccr.communicationSituation AS communicationSituation, ccr.communicationMethods AS communicationMethods, ccr.customerSource AS customerSource,
+            ccr.customerGender AS customerGender, ccr.groupAddition AS groupAddition, ccr.customerAge AS customerAge,
+            ccr.trendsKeyword AS trendsKeyword, ccr.stateKeyword AS stateKeyword
+        FROM cm_visitor_remarks ccr
+        WHERE
+            ccr.clubId is not null and ccr.clubId != ''
+            and ccr.addTime like concat('%', #{accessDate}, '%')
+          AND ccr.remarks IS NOT NULL
+          AND trendsKeyword IS NOT NULL AND stateKeyword IS NOT NULL
+        ORDER BY ADDTIME DESC
+    </select>
+
 </mapper>