opt import history sql

This commit is contained in:
Donghuang 2021-10-05 12:43:46 +08:00
parent 13df0934e3
commit 552b5505fe

View File

@ -162,16 +162,24 @@
join ( join (
<![CDATA[ <![CDATA[
select called_number select c.phone
from br_call_detail_record rec from br_calling_list_historical c
where start_stamp > date(now() - interval 21 day)
and tenant_id = #{arg.tenantId} join br_call_detail_record cdr
and answer_stamp is not null on c.phone = cdr.called_number
group by called_number
having count(answer_stamp) > 0 where cdr.start_stamp > date(now() - interval 21 day)
and cdr.tenant_id = #{arg.tenantId}
and cdr.answer_stamp is not null
and c.tenant_id = #{arg.tenantId}
and c.campaign_id = #{arg.campaignId}
and c.export_batch_key = #{arg.exportBatchKey}
group by cdr.called_number
having count(cdr.id) > 0
]]> ]]>
) t1 ) t1
on c.phone = t1.called_number on c.phone = t1.phone
set c.active = 0, set c.active = 0,
c.note = 'Answered', c.note = 'Answered',
@ -189,15 +197,23 @@
join ( join (
<![CDATA[ <![CDATA[
select called_number select c.phone
from br_call_detail_record rec from br_calling_list_historical c
where start_stamp > date(now() - interval 21 day)
and tenant_id = #{arg.tenantId} join br_call_detail_record cdr
group by called_number on c.phone = cdr.called_number
having count(start_stamp) > 6
where cdr.start_stamp > date(now() - interval 21 day)
and cdr.tenant_id = #{arg.tenantId}
and c.tenant_id = #{arg.tenantId}
and c.campaign_id = #{arg.campaignId}
and c.export_batch_key = #{arg.exportBatchKey}
group by cdr.called_number
having count(cdr.id) > 6
]]> ]]>
) t1 ) t1
on c.phone = t1.called_number on c.phone = t1.phone
set c.active = 0, set c.active = 0,
c.note = 'Exceed 6 Times', c.note = 'Exceed 6 Times',
@ -208,6 +224,7 @@
and c.campaign_id = #{arg.campaignId} and c.campaign_id = #{arg.campaignId}
and c.export_batch_key = #{arg.exportBatchKey} and c.export_batch_key = #{arg.exportBatchKey}
and c.active = 1 and c.active = 1
</update> </update>
<update id="removeCalledTwiceToday"> <update id="removeCalledTwiceToday">
@ -215,15 +232,23 @@
join ( join (
<![CDATA[ <![CDATA[
select called_number select c.phone
from br_call_detail_record rec from br_calling_list_historical c
where start_stamp > date(now())
and tenant_id = #{arg.tenantId} join br_call_detail_record cdr
group by called_number on c.phone = cdr.called_number
having count(start_stamp) > 1
where cdr.start_stamp > date(now())
and cdr.tenant_id = #{arg.tenantId}
and c.tenant_id = #{arg.tenantId}
and c.campaign_id = #{arg.campaignId}
and c.export_batch_key = #{arg.exportBatchKey}
group by cdr.called_number
having count(cdr.id) > 1
]]> ]]>
) t1 ) t1
on c.phone = t1.called_number on c.phone = t1.phone
set c.active = 0, set c.active = 0,
c.note = 'Exceed 1 Times Today', c.note = 'Exceed 1 Times Today',
@ -241,15 +266,23 @@
join ( join (
<![CDATA[ <![CDATA[
select called_number select c.phone
from br_call_detail_record rec from br_calling_list_historical c
where start_stamp > now() - interval 4 hour
and tenant_id = #{arg.tenantId} join br_call_detail_record cdr
group by called_number on c.phone = cdr.called_number
having count(start_stamp) > 0
where cdr.start_stamp > now() - interval 4 hour
and cdr.tenant_id = #{arg.tenantId}
and c.tenant_id = #{arg.tenantId}
and c.campaign_id = #{arg.campaignId}
and c.export_batch_key = #{arg.exportBatchKey}
group by cdr.called_number
having count(cdr.id) > 0
]]> ]]>
) t1 ) t1
on c.phone = t1.called_number on c.phone = t1.phone
set c.active = 0, set c.active = 0,
c.note = 'Called In 4 Hours', c.note = 'Called In 4 Hours',