|
@@ -1022,4 +1022,69 @@ public interface CrmCustomerMapper extends BaseMapper<CrmCustomer> {
|
|
|
|
|
|
|
|
@Select("select mobile from crm_customer where customer_id = #{customerId} limit 1")
|
|
@Select("select mobile from crm_customer where customer_id = #{customerId} limit 1")
|
|
|
String selectCrmCustomerPhoneByCustomerId(Long customerId);
|
|
String selectCrmCustomerPhoneByCustomerId(Long customerId);
|
|
|
|
|
+
|
|
|
|
|
+ @Select({"<script> " +
|
|
|
|
|
+ "select c.*,u.nick_name as company_user_nick_name,ccu.start_time as startTime,ca.attrition_level,ca.intention_degree,ca.customer_focus_json " +
|
|
|
|
|
+ "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,customer_focus_json FROM crm_customer_analyze WHERE customer_id = c.customer_id " +
|
|
|
|
|
+ " ORDER BY create_time DESC " +
|
|
|
|
|
+ " LIMIT 1 " +
|
|
|
|
|
+ ") ca ON TRUE " +
|
|
|
|
|
+ "where c.is_del=0 " +
|
|
|
|
|
+ "<if test = 'maps.companyId != null '> " +
|
|
|
|
|
+ "and c.company_id =#{maps.companyId} " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.customerCode != null and maps.customerCode !=\"\" '> " +
|
|
|
|
|
+ "and c.customer_code like CONCAT('%',#{maps.customerCode},'%') " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.customerName != null and maps.customerName !=\"\" '> " +
|
|
|
|
|
+ "and c.customer_name like CONCAT('%',#{maps.customerName},'%') " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.mobile != null and maps.mobile !=\"\" '> " +
|
|
|
|
|
+ "and c.mobile like CONCAT('%',#{maps.mobile},'%') " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.status != null and maps.status !=\"\" '> " +
|
|
|
|
|
+ "and c.status =#{maps.status} " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.customerType != null '> " +
|
|
|
|
|
+ "and c.customer_type =#{maps.customerType} " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.source != null and maps.source !=\"\" '> " +
|
|
|
|
|
+ "and c.source =#{maps.source} " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.isReceive != null '> " +
|
|
|
|
|
+ "and c.is_receive =#{maps.isReceive} " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.isDuplicate != null and maps.isDuplicate == 1 '> " +
|
|
|
|
|
+ "and c.is_duplicate =1 " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.isDuplicate != null and maps.isDuplicate == 2 '> " +
|
|
|
|
|
+ "and (c.is_duplicate =0 or c.is_duplicate is null) " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.tags != null '> " +
|
|
|
|
|
+ "and " +
|
|
|
|
|
+ "<foreach collection=\"maps.tags.split(',')\" item=\"tag\" open=\"(\" close=\")\" separator=\"OR\">" +
|
|
|
|
|
+ "find_in_set(#{tag},c.tags)" +
|
|
|
|
|
+ "</foreach> " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.companyUserNickName != null and maps.companyUserNickName !=\"\" '> " +
|
|
|
|
|
+ "and u.nick_name like CONCAT(#{maps.companyUserNickName},'%') " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.attritionLevel != null'> " +
|
|
|
|
|
+ "and ca.attrition_level = #{maps.attritionLevel} " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.intentionDegree != null and maps.intentionDegree != \"\" ' > " +
|
|
|
|
|
+ "and ca.intention_degree = #{maps.intentionDegree} " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.beginTime != null and maps.beginTime != \"\" '> " +
|
|
|
|
|
+ "and date_format(c.create_time,'%y%m%d') >= date_format(#{maps.beginTime},'%y%m%d') " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
|
|
|
|
|
+ "and date_format(c.create_time,'%y%m%d') <= date_format(#{maps.endTime},'%y%m%d') " +
|
|
|
|
|
+ "</if>" +
|
|
|
|
|
+ " order by c.customer_id desc "+
|
|
|
|
|
+ "</script>"})
|
|
|
|
|
+ List<CrmCustomerAllListQueryVO> selectCrmCustomerAllListQuery(@Param("maps") CrmCustomerAllListQueryParam param);
|
|
|
}
|
|
}
|