|
|
@@ -1137,4 +1137,395 @@ public interface CrmCustomerMapper extends BaseMapper<CrmCustomer> {
|
|
|
* @return CRM客户
|
|
|
*/
|
|
|
CrmCustomer selectCrmCustomerByCallphoneLogId(@Param("callphoneLogId") Long callphoneLogId);
|
|
|
+
|
|
|
+ // ==================== 条件分配:统计和查询ID ====================
|
|
|
+
|
|
|
+ /** 公海客户条件统计 */
|
|
|
+ @Select({"<script> " +
|
|
|
+ "select count(1) from crm_customer c " +
|
|
|
+ "where c.is_line=0 and is_del=0 and c.is_pool=1 " +
|
|
|
+ "<if test = 'maps.companyId != null '> " +
|
|
|
+ "and c.company_id =#{maps.companyId} " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.address != null and maps.address !=\"\" '> " +
|
|
|
+ "and c.address like CONCAT('%',#{maps.address},'%') " +
|
|
|
+ "</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.visitStatus != null and maps.visitStatus !=\"\" '> " +
|
|
|
+ "and c.visit_status IN " +
|
|
|
+ "<foreach collection=\"maps.visitStatus.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.customerType != null '> " +
|
|
|
+ "and c.customer_type IN " +
|
|
|
+ "<foreach collection=\"maps.customerType.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isReceive != null '> " +
|
|
|
+ "and c.is_receive =#{maps.isReceive} " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.source != null and maps.source !=\"\" '> " +
|
|
|
+ "and c.source IN " +
|
|
|
+ "<foreach collection=\"maps.source.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</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.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>" +
|
|
|
+ "<if test = 'maps.deptId != null and maps.deptId != 0 '> " +
|
|
|
+ "AND (c.dept_id = #{maps.deptId} OR c.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) " +
|
|
|
+ "</if>" +
|
|
|
+ "${maps.params.dataScope}"+
|
|
|
+ "</script>"})
|
|
|
+ int countCrmFullCustomerByCondition(@Param("maps") CrmFullCustomerListQueryParam param);
|
|
|
+
|
|
|
+ /** 公海客户条件查询ID */
|
|
|
+ @Select({"<script> " +
|
|
|
+ "select c.customer_id from crm_customer c " +
|
|
|
+ "where c.is_line=0 and is_del=0 and c.is_pool=1 " +
|
|
|
+ "<if test = 'maps.companyId != null '> " +
|
|
|
+ "and c.company_id =#{maps.companyId} " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.address != null and maps.address !=\"\" '> " +
|
|
|
+ "and c.address like CONCAT('%',#{maps.address},'%') " +
|
|
|
+ "</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.visitStatus != null and maps.visitStatus !=\"\" '> " +
|
|
|
+ "and c.visit_status IN " +
|
|
|
+ "<foreach collection=\"maps.visitStatus.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.customerType != null '> " +
|
|
|
+ "and c.customer_type IN " +
|
|
|
+ "<foreach collection=\"maps.customerType.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isReceive != null '> " +
|
|
|
+ "and c.is_receive =#{maps.isReceive} " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.source != null and maps.source !=\"\" '> " +
|
|
|
+ "and c.source IN " +
|
|
|
+ "<foreach collection=\"maps.source.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</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.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>" +
|
|
|
+ "<if test = 'maps.deptId != null and maps.deptId != 0 '> " +
|
|
|
+ "AND (c.dept_id = #{maps.deptId} OR c.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) " +
|
|
|
+ "</if>" +
|
|
|
+ "${maps.params.dataScope}"+
|
|
|
+ " order by c.customer_id desc limit 1000 "+
|
|
|
+ "</script>"})
|
|
|
+ List<Long> selectCrmFullCustomerIdsByCondition(@Param("maps") CrmFullCustomerListQueryParam param);
|
|
|
+
|
|
|
+ /** 我的客户条件统计 */
|
|
|
+ @Select({"<script> " +
|
|
|
+ "select count(1) from crm_customer_user cu inner join crm_customer c on c.customer_user_id=cu.customer_user_id " +
|
|
|
+ "where cu.is_pool=0 " +
|
|
|
+ "<if test = 'maps.companyId != null '> " +
|
|
|
+ "and cu.company_id =#{maps.companyId} " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.companyUserId != null '> " +
|
|
|
+ "and cu.company_user_id =#{maps.companyUserId} " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.address != null and maps.address !=\"\" '> " +
|
|
|
+ "and c.address like CONCAT('%',#{maps.address},'%') " +
|
|
|
+ "</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 cu.status IN " +
|
|
|
+ "<foreach collection=\"maps.status.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.visitStatus != null and maps.visitStatus !=\"\"'> " +
|
|
|
+ "and c.visit_status IN " +
|
|
|
+ "<foreach collection=\"maps.visitStatus.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>" +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isHisOrder != null and maps.isHisOrder==1 '> " +
|
|
|
+ "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id ) > 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isHisOrder != null and maps.isHisOrder==0 '> " +
|
|
|
+ "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id ) = 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isManualCall != null and maps.isManualCall==1 '> " +
|
|
|
+ "and (select ifnull(count(1),0) from crm_customer_call_log ccl where ccl.customer_id=c.customer_id and ccl.call_time > 0) > 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isManualCall != null and maps.isManualCall==0 '> " +
|
|
|
+ "and (select ifnull(count(1),0) from crm_customer_call_log ccl where ccl.customer_id=c.customer_id and ccl.call_time > 0) = 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.customerType != null '> " +
|
|
|
+ "and c.customer_type IN " +
|
|
|
+ "<foreach collection=\"maps.customerType.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.source != null and maps.source !=\"\" '> " +
|
|
|
+ "and c.source IN " +
|
|
|
+ "<foreach collection=\"maps.source.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.tags != null and maps.tags!=\"\" '> " +
|
|
|
+ "and " +
|
|
|
+ "<foreach collection=\"maps.tags.split(',')\" item=\"tag\" open=\"(\" close=\")\" separator=\"OR\">" +
|
|
|
+ "find_in_set(#{tag},c.tags)" +
|
|
|
+ "</foreach> " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.customerCreateTime != null '> " +
|
|
|
+ " AND date_format(c.create_time,'%y%m%d') >= date_format(#{maps.customerCreateTime[0]},'%y%m%d') " +
|
|
|
+ " AND date_format(c.create_time,'%y%m%d') <= date_format(#{maps.customerCreateTime[1]},'%y%m%d') " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.beginTime != null and maps.beginTime != \"\" '> " +
|
|
|
+ "and date_format(c.receive_time,'%y%m%d') >= date_format(#{maps.beginTime},'%y%m%d') " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
|
|
|
+ "and date_format(c.receive_time,'%y%m%d') <= date_format(#{maps.endTime},'%y%m%d') " +
|
|
|
+ "</if>" +
|
|
|
+ "</script>"})
|
|
|
+ int countCrmMyCustomerByCondition(@Param("maps") CrmMyCustomerListQueryParam param);
|
|
|
+
|
|
|
+ /** 我的客户条件查询ID */
|
|
|
+ @Select({"<script> " +
|
|
|
+ "select c.customer_id from crm_customer_user cu inner join crm_customer c on c.customer_user_id=cu.customer_user_id " +
|
|
|
+ "where cu.is_pool=0 " +
|
|
|
+ "<if test = 'maps.companyId != null '> " +
|
|
|
+ "and cu.company_id =#{maps.companyId} " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.companyUserId != null '> " +
|
|
|
+ "and cu.company_user_id =#{maps.companyUserId} " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.address != null and maps.address !=\"\" '> " +
|
|
|
+ "and c.address like CONCAT('%',#{maps.address},'%') " +
|
|
|
+ "</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 cu.status IN " +
|
|
|
+ "<foreach collection=\"maps.status.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.visitStatus != null and maps.visitStatus !=\"\"'> " +
|
|
|
+ "and c.visit_status IN " +
|
|
|
+ "<foreach collection=\"maps.visitStatus.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>" +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isHisOrder != null and maps.isHisOrder==1 '> " +
|
|
|
+ "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id ) > 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isHisOrder != null and maps.isHisOrder==0 '> " +
|
|
|
+ "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id ) = 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isManualCall != null and maps.isManualCall==1 '> " +
|
|
|
+ "and (select ifnull(count(1),0) from crm_customer_call_log ccl where ccl.customer_id=c.customer_id and ccl.call_time > 0) > 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isManualCall != null and maps.isManualCall==0 '> " +
|
|
|
+ "and (select ifnull(count(1),0) from crm_customer_call_log ccl where ccl.customer_id=c.customer_id and ccl.call_time > 0) = 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.customerType != null '> " +
|
|
|
+ "and c.customer_type IN " +
|
|
|
+ "<foreach collection=\"maps.customerType.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.source != null and maps.source !=\"\" '> " +
|
|
|
+ "and c.source IN " +
|
|
|
+ "<foreach collection=\"maps.source.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.tags != null and maps.tags!=\"\" '> " +
|
|
|
+ "and " +
|
|
|
+ "<foreach collection=\"maps.tags.split(',')\" item=\"tag\" open=\"(\" close=\")\" separator=\"OR\">" +
|
|
|
+ "find_in_set(#{tag},c.tags)" +
|
|
|
+ "</foreach> " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.customerCreateTime != null '> " +
|
|
|
+ " AND date_format(c.create_time,'%y%m%d') >= date_format(#{maps.customerCreateTime[0]},'%y%m%d') " +
|
|
|
+ " AND date_format(c.create_time,'%y%m%d') <= date_format(#{maps.customerCreateTime[1]},'%y%m%d') " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.beginTime != null and maps.beginTime != \"\" '> " +
|
|
|
+ "and date_format(c.receive_time,'%y%m%d') >= date_format(#{maps.beginTime},'%y%m%d') " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.endTime != null and maps.endTime != \"\" '> " +
|
|
|
+ "and date_format(c.receive_time,'%y%m%d') <= date_format(#{maps.endTime},'%y%m%d') " +
|
|
|
+ "</if>" +
|
|
|
+ " order by cu.customer_user_id desc limit 1000 "+
|
|
|
+ "</script>"})
|
|
|
+ List<Long> selectCrmMyCustomerIdsByCondition(@Param("maps") CrmMyCustomerListQueryParam param);
|
|
|
+
|
|
|
+ /** 客户管理条件统计 */
|
|
|
+ @Select({"<script> " +
|
|
|
+ "select count(1) from crm_customer c " +
|
|
|
+ "where 1=1 " +
|
|
|
+ "<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.visitStatus != null '> " +
|
|
|
+ "and c.visit_status IN " +
|
|
|
+ "<foreach collection=\"maps.visitStatus.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isBuy != null and maps.isBuy==1 '> " +
|
|
|
+ "and c.buy_count > 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isBuy != null and maps.isBuy==0 '> " +
|
|
|
+ "and (c.buy_count = 0 or c.buy_count is null) " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isHisOrder != null and maps.isHisOrder==1 '> " +
|
|
|
+ "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id ) > 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isHisOrder != null and maps.isHisOrder==0 '> " +
|
|
|
+ "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id ) = 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.customerType != null '> " +
|
|
|
+ "and c.customer_type IN " +
|
|
|
+ "<foreach collection=\"maps.customerType.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.source != null and maps.source !=\"\" '> " +
|
|
|
+ "and c.source IN " +
|
|
|
+ "<foreach collection=\"maps.source.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isReceive != null '> " +
|
|
|
+ "and c.is_receive =#{maps.isReceive} " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isLine != null '> " +
|
|
|
+ "and c.is_line =#{maps.isLine} " +
|
|
|
+ "</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.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>" +
|
|
|
+ "<if test = 'maps.deptId != null and maps.deptId != 0 '> " +
|
|
|
+ "AND (c.dept_id = #{maps.deptId} OR c.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) " +
|
|
|
+ "</if>" +
|
|
|
+ "${maps.params.dataScope}"+
|
|
|
+ "</script>"})
|
|
|
+ int countCrmCustomerByCondition(@Param("maps") CrmCustomerListQueryParam param);
|
|
|
+
|
|
|
+ /** 客户管理条件查询ID */
|
|
|
+ @Select({"<script> " +
|
|
|
+ "select c.customer_id from crm_customer c " +
|
|
|
+ "where 1=1 " +
|
|
|
+ "<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.visitStatus != null '> " +
|
|
|
+ "and c.visit_status IN " +
|
|
|
+ "<foreach collection=\"maps.visitStatus.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isBuy != null and maps.isBuy==1 '> " +
|
|
|
+ "and c.buy_count > 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isBuy != null and maps.isBuy==0 '> " +
|
|
|
+ "and (c.buy_count = 0 or c.buy_count is null) " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isHisOrder != null and maps.isHisOrder==1 '> " +
|
|
|
+ "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id ) > 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isHisOrder != null and maps.isHisOrder==0 '> " +
|
|
|
+ "and (select ifnull(count(1),0) from crm_customer_his_order h where h.customer_id=c.customer_id ) = 0 " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.customerType != null '> " +
|
|
|
+ "and c.customer_type IN " +
|
|
|
+ "<foreach collection=\"maps.customerType.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.source != null and maps.source !=\"\" '> " +
|
|
|
+ "and c.source IN " +
|
|
|
+ "<foreach collection=\"maps.source.split(',')\" item='item' index='index' open='(' separator=',' close=')'> #{item} </foreach>"+
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isReceive != null '> " +
|
|
|
+ "and c.is_receive =#{maps.isReceive} " +
|
|
|
+ "</if>" +
|
|
|
+ "<if test = 'maps.isLine != null '> " +
|
|
|
+ "and c.is_line =#{maps.isLine} " +
|
|
|
+ "</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.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>" +
|
|
|
+ "<if test = 'maps.deptId != null and maps.deptId != 0 '> " +
|
|
|
+ "AND (c.dept_id = #{maps.deptId} OR c.dept_id IN ( SELECT t.dept_id FROM company_dept t WHERE find_in_set(#{maps.deptId}, ancestors) )) " +
|
|
|
+ "</if>" +
|
|
|
+ "${maps.params.dataScope}"+
|
|
|
+ " order by c.customer_id desc limit 1000 "+
|
|
|
+ "</script>"})
|
|
|
+ List<Long> selectCrmCustomerIdsByCondition(@Param("maps") CrmCustomerListQueryParam param);
|
|
|
}
|