Procházet zdrojové kódy

销售端客户管理增加AI分析功能

peicj před 1 měsícem
rodič
revize
b66fee9d38

+ 7 - 0
fs-company/src/main/java/com/fs/company/controller/crm/CrmCustomerController.java

@@ -190,6 +190,13 @@ public class CrmCustomerController extends BaseController
 //        if(loginUser.getCompany().getCompanyId()==116){   // 河北湘银信息咨询服务有限公司(JZ-1)客户假删除不显示
 //            param.setCompanyId(0L);
 //        }
+        //默认值处理
+        if(param.getIntentionDegreeGt() != null && param.getIntentionDegreeGt() == 0){
+            param.setIntentionDegreeGt(null);
+        }
+        if(param.getIntentionDegreelt() != null && param.getIntentionDegreelt() == 0){
+            param.setIntentionDegreelt(null);
+        }
         if (param.getIsReceive() != null && param.getIsReceive() == 0){
             CrmLineCustomerListQueryParam param1 = new CrmLineCustomerListQueryParam();
             BeanUtils.copyProperties(param,param1);

+ 4 - 0
fs-service/src/main/java/com/fs/crm/domain/CrmCustomerAnalyze.java

@@ -42,6 +42,10 @@ public class CrmCustomerAnalyze extends BaseEntity{
     @Excel(name = "流失风险等级 0:无风险;1:低风险;2:中风险;3:高风险")
     private Long attritionLevel;
 
+    /** 流失风险等级提示 */
+    @Excel(name = "流失风险等级提示")
+    private String attritionLevelPrompt;
+
     /** 客户关注点 */
     @Excel(name = "客户关注点")
     private String customerFocusJson;

+ 31 - 2
fs-service/src/main/java/com/fs/crm/mapper/CrmCustomerMapper.java

@@ -345,9 +345,24 @@ public interface CrmCustomerMapper extends BaseMapper<CrmCustomer> {
             "</script>"})
     List<CrmMyCustomerListQueryVO> selectCrmMyCustomerListQuery(@Param("maps") CrmMyCustomerListQueryParam param);
     @Select({"<script> " +
-            "select c.*,u.nick_name as company_user_nick_name,ccu.start_time as startTime  from  crm_customer c left join company_user u on u.user_id=c.receive_user_id left join crm_customer_user ccu on c.customer_user_id = ccu.customer_user_id " +
+            "select c.*,u.nick_name as company_user_nick_name,ccu.start_time as startTime,ca.attrition_level,ca.intention_degree  from  crm_customer c " +
+            "left join company_user u on u.user_id=c.receive_user_id " +
+            "left join crm_customer_user ccu on c.customer_user_id = ccu.customer_user_id " +
+            "LEFT JOIN LATERAL ( SELECT attrition_level, intention_degree FROM crm_customer_analyze WHERE customer_id = c.customer_id " +
+            "   ORDER BY create_time DESC " +
+            "   LIMIT 1 " +
+            ") ca ON TRUE " +
 //            "where is_line=0 " +
             "where 1=1 " +
+            "<if test = 'maps.attritionLevel != null and maps.attritionLevel != \"\" '> " +
+            "and ca.attrition_level = #{maps.attritionLevel} " +
+            "</if>" +
+            "<if test = 'maps.intentionDegreeGt != null'> " +
+            "and ca.intention_degree &gt;= #{maps.intentionDegreeGt} " +
+            "</if>" +
+            "<if test = 'maps.intentionDegreelt != null'> " +
+            "and ca.intention_degree &lt;= #{maps.intentionDegreelt} " +
+            "</if>" +
             "<if test = 'maps.companyId != null     '> " +
             "and c.company_id =#{maps.companyId} " +
             "</if>" +
@@ -427,7 +442,12 @@ public interface CrmCustomerMapper extends BaseMapper<CrmCustomer> {
             "</script>"})
     List<CrmCustomerListQueryVO> selectCrmCustomerListQuery(@Param("maps") CrmCustomerListQueryParam param);
     @Select({"<script> " +
-            "select c.*,u.nick_name as company_user_nick_name  from  crm_customer c left join company_user u on u.user_id=c.receive_user_id   " +
+            "select c.*,u.nick_name as company_user_nick_name,ca.attrition_level,ca.intention_degree  from  crm_customer c " +
+            "left join company_user u on u.user_id=c.receive_user_id " +
+            "LEFT JOIN LATERAL ( SELECT attrition_level, intention_degree FROM crm_customer_analyze WHERE customer_id = c.customer_id " +
+            "   ORDER BY create_time DESC " +
+            "   LIMIT 1 " +
+            ") ca ON TRUE " +
             "where is_line=1 " +
 //            " select  c.*  " +
 ////            "<if test = 'maps.isDuplicate != null '> " +
@@ -480,6 +500,15 @@ public interface CrmCustomerMapper extends BaseMapper<CrmCustomer> {
             "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
             "and date_format(c.create_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d') " +
             "</if>" +
+            "<if test = 'maps.attritionLevel != null and maps.attritionLevel != \"\" '> " +
+            "and ca.attrition_level = #{maps.attritionLevel} " +
+            "</if>" +
+            "<if test = 'maps.intentionDegreeGt != null'> " +
+            "and ca.intention_degree &gt;= #{maps.intentionDegreeGt} " +
+            "</if>" +
+            "<if test = 'maps.intentionDegreelt != null'> " +
+            "and ca.intention_degree &lt;= #{maps.intentionDegreelt} " +
+            "</if>" +
             " order by c.customer_id desc "+
             "</script>"})
     List<CrmLineCustomerListQueryVO> selectCrmLineCustomerListQuery(@Param("maps") CrmLineCustomerListQueryParam param);

+ 7 - 0
fs-service/src/main/java/com/fs/crm/param/CrmCustomerListQueryParam.java

@@ -103,5 +103,12 @@ public class CrmCustomerListQueryParam extends BaseQueryParam
     /** 结束时间 */
     private String endTime;
 
+    /** 流失风险等级 0:无风险;1:低风险;2:中风险;3:高风险 */
+    private Long attritionLevel;
+    /** 意向度>= */
+    private Long intentionDegreeGt;
+    /** 意向度<= */
+    private Long intentionDegreelt;
+
 
 }

+ 7 - 0
fs-service/src/main/java/com/fs/crm/param/CrmLineCustomerListQueryParam.java

@@ -85,4 +85,11 @@ public class CrmLineCustomerListQueryParam extends BaseQueryParam
     @Excel(name = "标签" )
     private String tags;
 
+    /** 流失风险等级 0:无风险;1:低风险;2:中风险;3:高风险 */
+    private Long attritionLevel;
+    /** 意向度>= */
+    private Long intentionDegreeGt;
+    /** 意向度<= */
+    private Long intentionDegreelt;
+
 }

+ 7 - 0
fs-service/src/main/java/com/fs/crm/vo/CrmCustomerListQueryVO.java

@@ -113,4 +113,11 @@ public class CrmCustomerListQueryVO implements Serializable
     /** 认领开始时间 */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date startTime;
+
+    /** 流失风险等级 0:无风险;1:低风险;2:中风险;3:高风险 */
+    @Excel(name = "流失风险等级 0:无风险;1:低风险;2:中风险;3:高风险")
+    private Long attritionLevel;
+    /** 意向度 */
+    @Excel(name = "意向度")
+    private Long intentionDegree;
 }

+ 7 - 0
fs-service/src/main/java/com/fs/crm/vo/CrmLineCustomerListQueryVO.java

@@ -106,5 +106,12 @@ public class CrmLineCustomerListQueryVO implements Serializable
     /** 非重客户Id(重客户最早录入手机号码的客户id) */
     private Long dCustomerId;
 
+    /** 流失风险等级 0:无风险;1:低风险;2:中风险;3:高风险 */
+    @Excel(name = "流失风险等级 0:无风险;1:低风险;2:中风险;3:高风险")
+    private Long attritionLevel;
+    /** 意向度 */
+    @Excel(name = "意向度")
+    private Long intentionDegree;
+
 
 }

+ 6 - 1
fs-service/src/main/resources/mapper/crm/CrmCustomerAnalyzeMapper.xml

@@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="communicationAbstract"    column="communication_abstract"    />
         <result property="communicationSummary"    column="communication_summary"    />
         <result property="attritionLevel"    column="attrition_level"    />
+        <result property="attritionLevelPrompt"    column="attrition_level_prompt"    />
         <result property="customerFocusJson"    column="customer_focus_json"    />
         <result property="intentionDegree"    column="intention_degree"    />
         <result property="aiChatRecord"    column="ai_chat_record"    />
@@ -22,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectCrmCustomerAnalyzeVo">
-        select id, customer_id, customer_name, customer_portrait_json, communication_abstract, communication_summary, attrition_level, customer_focus_json, intention_degree, ai_chat_record, create_time, remark, reserve_int, reserve_str from crm_customer_analyze
+        select id, customer_id, customer_name, customer_portrait_json, communication_abstract, communication_summary, attrition_level, attrition_level_prompt, customer_focus_json, intention_degree, ai_chat_record, create_time, remark, reserve_int, reserve_str from crm_customer_analyze
     </sql>
 
     <select id="selectCrmCustomerAnalyzeList" parameterType="CrmCustomerAnalyze" resultMap="CrmCustomerAnalyzeResult">
@@ -34,6 +35,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="communicationAbstract != null  and communicationAbstract != ''"> and communication_abstract = #{communicationAbstract}</if>
             <if test="communicationSummary != null  and communicationSummary != ''"> and communication_summary = #{communicationSummary}</if>
             <if test="attritionLevel != null "> and attrition_level = #{attritionLevel}</if>
+            <if test="attritionLevelPrompt != null  and attritionLevelPrompt != ''"> and attrition_level_prompt like concat('%', #{attritionLevelPrompt}, '%')</if>
             <if test="customerFocusJson != null  and customerFocusJson != ''"> and customer_focus_json = #{customerFocusJson}</if>
             <if test="intentionDegree != null "> and intention_degree = #{intentionDegree}</if>
             <if test="aiChatRecord != null  and aiChatRecord != ''"> and ai_chat_record = #{aiChatRecord}</if>
@@ -56,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="communicationAbstract != null">communication_abstract,</if>
             <if test="communicationSummary != null">communication_summary,</if>
             <if test="attritionLevel != null">attrition_level,</if>
+            <if test="attritionLevelPrompt != null">attrition_level_prompt,</if>
             <if test="customerFocusJson != null">customer_focus_json,</if>
             <if test="intentionDegree != null">intention_degree,</if>
             <if test="aiChatRecord != null">ai_chat_record,</if>
@@ -71,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="communicationAbstract != null">#{communicationAbstract},</if>
             <if test="communicationSummary != null">#{communicationSummary},</if>
             <if test="attritionLevel != null">#{attritionLevel},</if>
+            <if test="attritionLevelPrompt != null">#{attritionLevelPrompt},</if>
             <if test="customerFocusJson != null">#{customerFocusJson},</if>
             <if test="intentionDegree != null">#{intentionDegree},</if>
             <if test="aiChatRecord != null">#{aiChatRecord},</if>
@@ -90,6 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="communicationAbstract != null">communication_abstract = #{communicationAbstract},</if>
             <if test="communicationSummary != null">communication_summary = #{communicationSummary},</if>
             <if test="attritionLevel != null">attrition_level = #{attritionLevel},</if>
+            <if test="attritionLevelPrompt != null">attrition_level_prompt = #{attritionLevelPrompt},</if>
             <if test="customerFocusJson != null">customer_focus_json = #{customerFocusJson},</if>
             <if test="intentionDegree != null">intention_degree = #{intentionDegree},</if>
             <if test="aiChatRecord != null">ai_chat_record = #{aiChatRecord},</if>