<iftest='tabType =="9" || (callbackLog != null and callbackLog != "") || (customerSourceType2 != null and customerSourceType2 != "" )'>
inner join (
SELECT
SELECT
c.id
c3.manager_id,c3.phone
FROM customer_merge c
FROM
<iftest='tabType =="9" || (callbackLog != null and callbackLog != "") || (customerSourceType2 != null and customerSourceType2 != "" )'>
customer_callback_log c2 right join customer c3 on c2.customer_id = c3.id
inner join (
where 1=1
SELECT
and c3.cityCode=#{cityCode}
c3.manager_id,c3.phone
AND c3.is_delete = 0
FROM
AND ( c3.isWaitCall = 0 OR c3.isWaitCall IS NULL )
customer_callback_log c2 right join customer c3 on c2.customer_id = c3.id
AND c3.manager_id IS NOT NULL
where 1=1
AND c3.STATUS IN ( 11, 0, 99 )
and c3.cityCode=#{cityCode}
<iftest='tabType =="9"'>
AND c3.is_delete = 0
and c3.customer_source_type=7
AND ( c3.isWaitCall = 0 OR c3.isWaitCall IS NULL )
</if>
AND c3.manager_id IS NOT NULL
<iftest="customerSourceType2 != null and customerSourceType2 != '' ">
AND c3.STATUS IN ( 11, 0, 99 )
and EXISTS (
<iftest='tabType =="9"'>
select customer_source_type from customer c8
and c3.customer_source_type=7
where c8.manager_id=c3.manager_id and c8.phone=c3.phone
</if>
and c8.customer_source_type=#{customerSourceType2}
<iftest="customerSourceType2 != null and customerSourceType2 != '' ">
)
and EXISTS (
</if>
select customer_source_type from customer c8
<iftest="callbackLog != null and callbackLog != '' ">
where c8.manager_id=c3.manager_id and c8.phone=c3.phone
and c2.content like CONCAT('%', #{callbackLog},'%')
and c8.customer_source_type=#{customerSourceType2}
</if>
)
group by c3.manager_id,c3.phone
</if>
) t1 on c.manager_id=t1.manager_id and c.phone=t1.phone
<iftest="callbackLog != null and callbackLog != '' ">
</if>
and c2.content like CONCAT('%', #{callbackLog},'%')
<iftest="(projectName != null and projectName != '') or (projectStatus != null and projectStatus != '')">
</if>
LEFT JOIN (
group by c3.manager_id,c3.phone
SELECT c1.manager_id, c1.phone FROM customer c1 inner join customer_project p1 on c1.id=p1.customer_id
) t1 on c.manager_id=t1.manager_id and c.phone=t1.phone
WHERE 1=1 and (c1.manager_id = #{userId} OR c1.manager_id IN ( SELECT id FROM user WHERE depturlpath LIKE ( SELECT concat( depturlpath, '/%' ) FROM user WHERE id = #{userId} ) ))
</if>
and c1.cityCode = #{cityCode} AND c1.is_delete = 0 AND c1.STATUS IN ( 11, 0, 99 ) AND ( c1.isWaitCall = 0 OR c1.isWaitCall IS NULL )
<iftest="(projectName != null and projectName != '') or (projectStatus != null and projectStatus != '')">
<iftest="projectName != null and projectName != '' ">
LEFT JOIN (
and p1.house_name LIKE CONCAT( '%', #{projectName}, '%' )
SELECT c1.manager_id, c1.phone FROM customer c1 inner join customer_project p1 on c1.id=p1.customer_id
</if>
WHERE 1=1 and (c1.manager_id = #{userId} OR c1.manager_id IN ( SELECT id FROM user WHERE depturlpath LIKE ( SELECT concat( depturlpath, '/%' ) FROM user WHERE id = #{userId} ) ))
<iftest="projectStatus != null and projectStatus != '' ">
and c1.cityCode = #{cityCode} AND c1.is_delete = 0 AND c1.STATUS IN ( 11, 0, 99 ) AND ( c1.isWaitCall = 0 OR c1.isWaitCall IS NULL )
and p1.STATUS = #{projectStatus}
<iftest="projectName != null and projectName != '' ">
</if>
and p1.house_name LIKE CONCAT( '%', #{projectName}, '%' )
<iftest="phone != null and phone != '' ">
</if>
AND (c1.phone LIKE CONCAT('%', #{phone},'%') OR c1.bak_phone1 LIKE CONCAT('%', #{phone},'%') OR
<iftest="projectStatus != null and projectStatus != '' ">
c1.bak_phone2 LIKE CONCAT('%', #{phone},'%') OR c1.bak_phone3 LIKE CONCAT('%', #{phone},'%') )
and p1.STATUS = #{projectStatus}
</if>
</if>
group by c1.manager_id,c1.phone
<iftest="phone != null and phone != '' ">
)t2 on c.manager_id = t2.manager_id AND c.phone = t2.phone
AND (c1.phone LIKE CONCAT('%', #{phone},'%') OR c1.bak_phone1 LIKE CONCAT('%', #{phone},'%') OR
</if>
c1.bak_phone2 LIKE CONCAT('%', #{phone},'%') OR c1.bak_phone3 LIKE CONCAT('%', #{phone},'%') )
<iftest="labelIdList != null and labelIdList.size() > 0 ">
</if>
inner join (select distinct customerId from customer_label cl where cl.labelId in
)t2 on c.manager_id = t2.manager_id AND c.phone = t2.phone
<iftest="sourceName != null and sourceName != '' ">
and cl.is_delete=0) m
left join (
on c.id=m.customerId
SELECT ct1.manager_id, ct1.phone FROM customer ct1 WHERE 1=1
</if>
and ct1.cityCode=#{cityCode} and ct1.is_delete = 0 AND ct1.STATUS IN ( 11, 0, 99 )
<iftest="sourceName != null and sourceName != '' ">
and (ct1.manager_id=#{userId} OR ct1.manager_id IN ( SELECT id FROM user WHERE depturlpath LIKE ( SELECT concat( depturlpath, '/%' ) FROM user WHERE id = #{userId} ) ))
left join (
AND ct1.act_source LIKE concat( '%', #{sourceName}, '%' )
SELECT ct1.manager_id, ct1.phone FROM customer ct1 WHERE 1=1
group by ct1.manager_id,ct1.phone
and ct1.cityCode=#{cityCode} and ct1.is_delete = 0 AND ct1.STATUS IN ( 11, 0, 99 )
) t4 on c.manager_id = t4.manager_id AND c.phone = t4.phone
and (ct1.manager_id=#{userId} OR ct1.manager_id IN ( SELECT id FROM user WHERE depturlpath LIKE ( SELECT concat( depturlpath, '/%' ) FROM user WHERE id = #{userId} ) ))
</if>
AND ct1.act_source LIKE concat( '%', #{sourceName}, '%' )
<iftest="customTimeTypeTwo != null and customTimeTypeTwo != '' ">
group by ct1.manager_id,ct1.phone
left join (
) t4 on c.manager_id = t4.manager_id AND c.phone = t4.phone
select ct2.manager_id,ct2.phone
</if>
from customer ct2 inner join customer_status_log csl on ct2.id=csl.customer_id
<iftest="customTimeTypeTwo != null and customTimeTypeTwo != '' ">
where csl.is_delete = 0 and csl.to_status_id = 1
left join (
AND csl.create_time >=#{customTimeStart}
select ct2.manager_id,ct2.phone
AND csl.create_time <=#{customTimeEnd}
from customer ct2 inner join customer_status_log csl on ct2.id=csl.customer_id
group by ct2.manager_id,ct2.phone
where csl.is_delete = 0 and csl.to_status_id = 1
) t5 on c.manager_id = t5.manager_id AND c.phone = t5.phone
AND csl.create_time >=#{customTimeStart}
</if>
AND csl.create_time <=#{customTimeEnd}
<iftest="customTimeTypeThree != null and customTimeTypeThree != '' ">
group by ct2.manager_id,ct2.phone
left join (
) t5 on c.manager_id = t5.manager_id AND c.phone = t5.phone
select ct2.manager_id,ct2.phone
</if>
from customer ct2 inner join customer_status_log csl on ct2.id=csl.customer_id
<iftest="customTimeTypeThree != null and customTimeTypeThree != '' ">
where csl.is_delete = 0 and csl.to_status_id = 2
left join (
AND csl.occur_time >=#{customTimeStart}
select ct2.manager_id,ct2.phone
AND csl.occur_time <=#{customTimeEnd}
from customer ct2 inner join customer_status_log csl on ct2.id=csl.customer_id
group by ct2.manager_id,ct2.phone
where csl.is_delete = 0 and csl.to_status_id = 2
) t5 on c.manager_id = t5.manager_id AND c.phone = t5.phone
AND csl.occur_time >=#{customTimeStart}
</if>
AND csl.occur_time <=#{customTimeEnd}
<iftest="customTimeTypeFour != null and customTimeTypeFour != '' ">
group by ct2.manager_id,ct2.phone
left join (
) t5 on c.manager_id = t5.manager_id AND c.phone = t5.phone
select ct2.manager_id,ct2.phone
</if>
from customer ct2 inner join customer_status_log csl on ct2.id=csl.customer_id
<iftest="customTimeTypeFour != null and customTimeTypeFour != '' ">
where csl.is_delete = 0 and csl.to_status_id = 3
left join (
AND csl.occur_time >=#{customTimeStart}
select ct2.manager_id,ct2.phone
AND csl.occur_time <=#{customTimeEnd}
from customer ct2 inner join customer_status_log csl on ct2.id=csl.customer_id
group by ct2.manager_id,ct2.phone
where csl.is_delete = 0 and csl.to_status_id = 3
) t5 on c.manager_id = t5.manager_id AND c.phone = t5.phone
AND csl.occur_time >=#{customTimeStart}
</if>
AND csl.occur_time <=#{customTimeEnd}
<iftest="customTimeTypeFive != null and customTimeTypeFive != '' ">
group by ct2.manager_id,ct2.phone
left join (
) t5 on c.manager_id = t5.manager_id AND c.phone = t5.phone
select ct2.manager_id,ct2.phone
</if>
from customer ct2 inner join customer_status_log csl on ct2.id=csl.customer_id
<iftest="customTimeTypeFive != null and customTimeTypeFive != '' ">
where csl.is_delete = 0 and csl.to_status_id = 4
left join (
AND csl.occur_time >=#{customTimeStart}
select ct2.manager_id,ct2.phone
AND csl.occur_time <=#{customTimeEnd}
from customer ct2 inner join customer_status_log csl on ct2.id=csl.customer_id
group by ct2.manager_id,ct2.phone
where csl.is_delete = 0 and csl.to_status_id = 4
) t5 on c.manager_id = t5.manager_id AND c.phone = t5.phone
AND csl.occur_time >=#{customTimeStart}
</if>
AND csl.occur_time <=#{customTimeEnd}
<iftest="customTimeTypeSix != null and customTimeTypeSix != '' ">
group by ct2.manager_id,ct2.phone
left join (
) t5 on c.manager_id = t5.manager_id AND c.phone = t5.phone
select ct2.manager_id,ct2.phone
</if>
from customer ct2 inner join customer_status_log csl on ct2.id=csl.customer_id
<iftest="customTimeTypeSix != null and customTimeTypeSix != '' ">
where csl.is_delete = 0 and csl.to_status_id = 5
left join (
AND csl.occur_time >=#{customTimeStart}
select ct2.manager_id,ct2.phone
AND csl.occur_time <=#{customTimeEnd}
from customer ct2 inner join customer_status_log csl on ct2.id=csl.customer_id
group by ct2.manager_id,ct2.phone
where csl.is_delete = 0 and csl.to_status_id = 5
) t5 on c.manager_id = t5.manager_id AND c.phone = t5.phone
AND csl.occur_time >=#{customTimeStart}
</if>
AND csl.occur_time <=#{customTimeEnd}
group by ct2.manager_id,ct2.phone
) t5 on c.manager_id = t5.manager_id AND c.phone = t5.phone
</if>
where 1=1
where 1=1
<iftest='tabType =="9" || (callbackLog != null and callbackLog != "") || (customerSourceType2 != null and customerSourceType2 != "" )'>
<iftest='tabType =="9" || (callbackLog != null and callbackLog != "") || (customerSourceType2 != null and customerSourceType2 != "" )'>
and t1.phone is not null
and t1.phone is not null
...
@@ -626,8 +616,7 @@
...
@@ -626,8 +616,7 @@
<iftest="userId != null and userId != '' ">
<iftest="userId != null and userId != '' ">
AND (
AND (
c.manager_id = #{userId}
c.manager_id = #{userId}
OR c.manager_id IN ( SELECT id FROM user WHERE depturlpath LIKE ( SELECT concat( depturlpath, '/%' ) FROM
OR c.manager_id IN ( SELECT id FROM user WHERE depturlpath LIKE ( SELECT concat( depturlpath, '/%' ) FROM user WHERE id = #{userId} ) )
user WHERE id = #{userId} ) )
)
)
</if>
</if>
<iftest="bindTimeStart != null and bindTimeStart != '' ">
<iftest="bindTimeStart != null and bindTimeStart != '' ">
...
@@ -636,8 +625,6 @@
...
@@ -636,8 +625,6 @@
<iftest="bindTimeEnd != null and bindTimeEnd != '' ">
<iftest="bindTimeEnd != null and bindTimeEnd != '' ">
AND c.bind_time <=#{bindTimeEnd}
AND c.bind_time <=#{bindTimeEnd}
</if>
</if>
<iftest="isNotBackFour != null and isNotBackFour != '' ">
<iftest="isNotBackFour != null and isNotBackFour != '' ">
and datediff( CURRENT_DATE, c.last_call_time ) >= 3
and datediff( CURRENT_DATE, c.last_call_time ) >= 3
AND datediff( CURRENT_DATE, c.last_call_time ) <= 7
AND datediff( CURRENT_DATE, c.last_call_time ) <= 7
...
@@ -655,14 +642,16 @@
...
@@ -655,14 +642,16 @@
<iftest="isNotBackEight != null and isNotBackEight != '' ">
<iftest="isNotBackEight != null and isNotBackEight != '' ">
and datediff( CURRENT_DATE, c.last_call_time ) >= 50
and datediff( CURRENT_DATE, c.last_call_time ) >= 50
</if>
</if>
<iftest="customTimeTypeOne != null and customTimeTypeOne != '' ">
AND c.last_call_time >=#{customTimeStart}
AND c.last_call_time <=#{customTimeEnd}
</if>
<iftest="isStar != null and isStar != '' ">
<iftest="isStar != null and isStar != '' ">
AND c.starCustomer =1
AND c.starCustomer =1
</if>
</if>
<iftest="isNotStar != null and isNotStar != '' ">
<iftest="isNotStar != null and isNotStar != '' ">
AND c.starCustomer =0
AND c.starCustomer =0
</if>
</if>
<iftest="starCustomer != null and starCustomer != '' ">
<iftest="starCustomer != null and starCustomer != '' ">
AND c.starCustomer =#{starCustomer}
AND c.starCustomer =#{starCustomer}
</if>
</if>
...
@@ -673,7 +662,9 @@
...
@@ -673,7 +662,9 @@
<iftest="isActive != null and isActive != '' ">
<iftest="isActive != null and isActive != '' ">
AND c.is_active = 1
AND c.is_active = 1
</if>
</if>
<iftest="isRecycled != null and isRecycled != '' ">
AND c.isRecycled =#{isRecycled}
</if>
<iftest='tabType =="8"'>
<iftest='tabType =="8"'>
AND ( c.is_active = 1 )
AND ( c.is_active = 1 )
</if>
</if>
...
@@ -689,18 +680,13 @@
...
@@ -689,18 +680,13 @@
<iftest='tabType =="2"'>
<iftest='tabType =="2"'>
and c.trace_status = 1
and c.trace_status = 1
</if>
</if>
<iftest='tabType =="0"'>
<iftest='tabType =="0"'>
AND ( SELECT count( * ) FROM customer_callback_log ccl WHERE ccl.customer_id = c.id ) = 0
AND ( SELECT count( * ) FROM customer_callback_log ccl WHERE ccl.customer_id = c.id ) = 0
AND ( SELECT count( * ) FROM customer_status_log csl WHERE csl.customer_id = c.id ) = 0
AND ( SELECT count( * ) FROM customer_status_log csl WHERE csl.customer_id = c.id ) = 0
</if>
</if>
</select>
<iftest="isRecycled != null and isRecycled != '' ">