742 lines
29 KiB
XML
742 lines
29 KiB
XML
<?xml version="1.0" encoding="UTF-8"?>
|
|
<!DOCTYPE sqls SYSTEM "sql_definition.dtd">
|
|
<sqls>
|
|
<!--回访-->
|
|
<sql group="revisit">
|
|
|
|
<i id="getReflectList">
|
|
<![CDATA[
|
|
SELECT *
|
|
FROM REVISIT_REFLECT_TYPE
|
|
WHERE $like(REFLECT_NAME,qn)
|
|
AND del_flag=0
|
|
order by reflect_id
|
|
]]>
|
|
</i>
|
|
|
|
<i id="getReflectList2">
|
|
<![CDATA[
|
|
SELECT reflect_id,reflect_name
|
|
FROM REVISIT_REFLECT_TYPE
|
|
WHERE del_flag=0
|
|
order by reflect_id
|
|
]]>
|
|
</i>
|
|
|
|
<i id="addReflect">
|
|
<![CDATA[
|
|
insert into REVISIT_REFLECT_TYPE
|
|
(reflect_id,
|
|
reflect_name,
|
|
comments,
|
|
create_id)
|
|
values
|
|
(
|
|
{reflect_id},
|
|
{reflect_name},
|
|
{comments},
|
|
{create_id})
|
|
]]>
|
|
</i>
|
|
|
|
<i id="editReflect">
|
|
<![CDATA[
|
|
update REVISIT_REFLECT_TYPE
|
|
set reflect_name = {reflect_name},
|
|
comments={comments},
|
|
update_id = {update_id}
|
|
where reflect_id ={reflect_id}
|
|
]]>
|
|
</i>
|
|
|
|
<i id="getType">
|
|
<![CDATA[
|
|
select distinct spfl as id,
|
|
spfl as text
|
|
from hf_custinfo t
|
|
where $like(spfl,key)
|
|
order by spfl
|
|
]]>
|
|
</i>
|
|
|
|
<i id="getQuestionList">
|
|
<![CDATA[
|
|
select
|
|
D.QUESTION_ID,
|
|
D.question_type_name,
|
|
D.Question_Name
|
|
from revisit_question_detail d
|
|
where d.del_flag=0
|
|
and $equal(question_type_name,typeId)
|
|
order by question_type_name,question_id
|
|
]]>
|
|
</i>
|
|
|
|
<i id="addQuestion">
|
|
<![CDATA[
|
|
insert into REVISIT_QUESTION_DETAIL
|
|
(question_id,
|
|
question_type_name,
|
|
question_name,
|
|
create_id,
|
|
update_id)
|
|
values
|
|
(revisit_question_id.nextval,
|
|
{question_type_name},
|
|
{question_name},
|
|
{create_id},
|
|
{create_id})
|
|
]]>
|
|
</i>
|
|
|
|
<i id="editQuestion">
|
|
<![CDATA[
|
|
update REVISIT_QUESTION_DETAIL
|
|
set
|
|
question_name={question_name},
|
|
update_id = {update_id},
|
|
update_date = sysdate
|
|
where question_id ={question_id}
|
|
]]>
|
|
</i>
|
|
|
|
<i id="getCustInfo">
|
|
select t.*
|
|
from HF_CUSTINFO t
|
|
where $equal(t.cust_naem,cust_name)
|
|
and spmc in (select item_name from HF_SP_SETTING where is_show=1)
|
|
and $between(xsrq,searchbegindate,searchenddate)
|
|
and (is_hf is null or is_hf !=1 or(is_hf=1 and (is_success is null or is_success!=1)))
|
|
and del_flag!=1
|
|
order by t.spFl,t.id
|
|
</i>
|
|
|
|
<i id="getQuestion">
|
|
<![CDATA[
|
|
select distinct
|
|
D.QUESTION_ID,
|
|
D.question_type_name,
|
|
D.Question_Name
|
|
from revisit_question_detail d,hf_custinfo h
|
|
where d.del_flag=0
|
|
and d.question_type_name=h.spfl
|
|
and $equal(h.cust_naem,cust_name)
|
|
and (is_hf is null or is_hf !=1 or(is_hf=1 and (is_success is null or is_success!=1)))
|
|
order by question_type_name,question_id
|
|
]]>
|
|
</i>
|
|
|
|
<i id="getRevisitInfo">
|
|
select org_name,cust_naem,cust_tax_code,spmc,
|
|
is_hf,is_success,last_date,reflect_name,
|
|
case when state='-1' then ''
|
|
when state='0' then '待处理'
|
|
when state='1' then '已处理'
|
|
when state='2' then '处理中'
|
|
else '' end as state
|
|
from(
|
|
select h.org_name,cust_naem,h.cust_tax_code,
|
|
wmsys.wm_concat(spfl || '(' || spmc || ')' ) AS spmc,
|
|
wmsys.wm_concat(distinct
|
|
case when( is_hf is null or is_hf != 1)
|
|
THEN '未回访'
|
|
when(is_hf=1)
|
|
then '已回访'end) as is_hf,
|
|
wmsys.wm_concat(distinct
|
|
case when(is_hf=1 and( is_success is null or is_success != 1))
|
|
THEN '回访不成功'
|
|
when(is_hf=1 and is_success= 1)
|
|
then '回访成功'
|
|
when(is_hf!=1 or is_hf is null)
|
|
then ''
|
|
end) as is_success,
|
|
max(r.update_date) as last_date,max(rf.reflect_name) as reflect_name,
|
|
case when max(ex.state) is null or max(ex.state)=''
|
|
then '-1'
|
|
else max(ex.state) end as state
|
|
from hf_custinfo h
|
|
|
|
left join (select hr.log_id,hr.obj_id,hr.sp_id,hr.operate_date as update_date,row_number() OVER(PARTITION BY sp_id ORDER BY operate_date DESC) as rn from hf_log hr
|
|
where hr.type='answer' ) r
|
|
on r.sp_id = id
|
|
and r.rn=1
|
|
left join (select hl.log_id,hl.obj_id,hl.reflect_type_id from hf_log hl
|
|
where type='revisit') l
|
|
on l.log_id=r.obj_id
|
|
left join hf_excustomer_info ex
|
|
on cust_naem =ex.cust_name
|
|
left join revisit_reflect_type rf
|
|
on rf.reflect_id=l.reflect_type_id
|
|
where 1=1
|
|
and $like(h.org_name,org_name)
|
|
and h.org_name not in(select code_desc from revisit_base_code where code_type = 'no_orgname')
|
|
and $like(h.cust_naem,cust_name)
|
|
and h.spmc in (select item_name from HF_SP_SETTING where is_show=1)
|
|
and $like(h.spmc,sp_name)
|
|
and (({hf_state}=-1 and (h.is_hf !=1 or h.is_success!=1
|
|
or h.is_hf is null or h.is_success is null))
|
|
OR ({hf_state}=0 and (h.is_hf is null or h.is_hf!=1))
|
|
OR ({hf_state}=1 and h.is_hf=1 and h.is_success =1)
|
|
OR ({hf_state}=2 and h.is_hf=1 and h.is_success !=1))
|
|
and $equal(l.reflect_type_id,reflect)
|
|
and $between(h.xsrq,searchbegindate,searchenddate)
|
|
and (({type}='-1')
|
|
OR ({type}='0' and (h.type is null or h.type = ''))
|
|
OR ({type}='1' and (h.type='1'))
|
|
OR ({type}='2' and (h.type='2')))
|
|
and h.del_flag!=1
|
|
group by h.org_name,cust_naem,h.cust_tax_code
|
|
order by cust_naem)
|
|
where 1=1
|
|
and $equal(state,extype)
|
|
|
|
</i>
|
|
|
|
<i id="getRecordId">
|
|
select max(RECORD_ID) AS rid from HF_RECORD
|
|
where CUST_NAME={cust_name}
|
|
and CUST_TAX_CODE={cust_tax_code}
|
|
and SP_IDS={sp_ids}
|
|
</i>
|
|
|
|
<i id="checkRecord">
|
|
select count(1) from HF_RECORD
|
|
where CUST_NAME={cust_name}
|
|
and CUST_TAX_CODE={cust_tax_code}
|
|
and SP_IDS={sp_ids}
|
|
</i>
|
|
|
|
<i id="saveRecord">
|
|
insert into hf_record
|
|
(record_id,CUST_NAME,SP_IDS,
|
|
CUST_TAX_CODE,CREATE_ID,CREATE_DATE,UPDATE_ID,UPDATE_DATE)
|
|
values
|
|
({record_id},{cust_name},{sp_ids},
|
|
{cust_tax_code},{create_id},sysdate,{create_id},sysdate)
|
|
</i>
|
|
|
|
<i id="saveLog">
|
|
insert into hf_log
|
|
(log_id,obj_id,type,
|
|
operate_id,operate_name,operate_date,
|
|
ip,remark,reflect_type_id,is_success,
|
|
satisfy,suggestion,
|
|
video_path,sp_id,answers)
|
|
values
|
|
({log_id},{obj_id},{type},
|
|
{operate_id},{operate_name},sysdate,
|
|
{ip},{remark},{reflect_type_id},{is_success},
|
|
{satisfy},{suggestion},
|
|
{video_path},{sp_id},{answers})
|
|
</i>
|
|
|
|
<i id="updateCustInfo">
|
|
update hf_custinfo
|
|
set is_hf = {is_hf},
|
|
is_success = {is_success}
|
|
where id = {spid}
|
|
</i>
|
|
|
|
<i id="getContact">
|
|
select v.hf_name as contact,v.phone as mobile,v.source as source,v.mobile_mark from V_HFCONTACT_test2 v
|
|
where v.cust_name = {cust_name}
|
|
<!--select mobile,contact,source from (
|
|
select distinct hf_phone as mobile ,hf_name as contact,
|
|
'回访电话' as source
|
|
from hf_custinfo
|
|
where cust_naem = {cust_name}
|
|
and hf_phone is not null
|
|
and (type is null or type !='1')
|
|
and spmc in (select item_name from HF_SP_SETTING where is_show=1)
|
|
and $between(xsrq,searchbegindate,searchenddate)
|
|
union all
|
|
select distinct prepare_phone as mobile ,prepare_name as contact,'备用电话' as source
|
|
from hf_custinfo
|
|
where cust_naem = {cust_name}
|
|
and prepare_phone is not null
|
|
and spmc in (select item_name from HF_SP_SETTING where is_show=1)
|
|
and $between(xsrq,searchbegindate,searchenddate)
|
|
union all
|
|
select distinct hf_phone as mobile ,hf_name as contact,
|
|
'金融电话' as source
|
|
from hf_custinfo
|
|
where cust_naem = {cust_name}
|
|
and type ='1'
|
|
and spmc in (select item_name from HF_SP_SETTING where is_show=1)
|
|
and $between(xsrq,searchbegindate,searchenddate)
|
|
union all
|
|
select distinct mobile,contact,source
|
|
from (
|
|
select distinct c.tel3 as mobile,'' as contact,'CRM' as source
|
|
from crm_customer_info c
|
|
where c.cust_name = {cust_name}
|
|
union all
|
|
select distinct c.tel4 as mobile,'' as contact,'CRM' as source
|
|
from crm_customer_info c
|
|
where c.cust_name = {cust_name}
|
|
union all
|
|
select distinct c.tel5 as mobile,'' as contact,'CRM' as source
|
|
from crm_customer_info c
|
|
where c.cust_name = {cust_name}
|
|
union all
|
|
select distinct c.tel6 as mobile,'' as contact,'CRM' as source
|
|
from crm_customer_info c
|
|
where c.cust_name = {cust_name}
|
|
union all
|
|
select distinct c.tel7 as mobile,'' as contact,'CRM' as source
|
|
from crm_customer_info c
|
|
where c.cust_name = {cust_name}
|
|
)where mobile is not null
|
|
union all
|
|
select mobile,contact,source
|
|
from hf_contact
|
|
where flag='add'
|
|
and CUST_NAME={cust_name}
|
|
)
|
|
where mobile not in (select mobile from hf_contact where flag='remove'
|
|
and CUST_NAME={cust_name})-->
|
|
</i>
|
|
|
|
<i id="getContact_ALL">
|
|
select v.hf_name as contact,v.phone as mobile,v.source as source,v.mobile_mark,v.flag,v.operate_date from V_HFCONTACT_all v
|
|
where v.cust_name = {cust_name}
|
|
</i>
|
|
|
|
<i id="getDailiCust">
|
|
select distinct cust_naem as id,cust_naem as text
|
|
from hf_custinfo
|
|
where 1=1
|
|
and org_name not in(select code_desc from revisit_base_code where code_type = 'no_orgname')
|
|
and spmc in (select item_name from HF_SP_SETTING where is_show=1)
|
|
and (is_hf !=1 or is_success!=1 or is_hf is null or is_success is null)
|
|
and $between(xsrq,searchbegindate,searchenddate)
|
|
and $equal(hf_phone,dlphone)
|
|
and cust_naem !={cust_name}
|
|
and del_flag!=1
|
|
order by cust_naem
|
|
</i>
|
|
|
|
<i id="saveContact">
|
|
insert into hf_contact(id,CUST_NAME,CONTACT,MOBILE,
|
|
SOURCE,FLAG,OPERATOR_CODE,OPERATOR_NAME,VITAL,mobile_mark)
|
|
values({id},{cust_name},{contact},{mobile},{source},{flag},{userId},{userName},{remark},{mobile_mark})
|
|
</i>
|
|
|
|
<i id="isHasContact">
|
|
select * from hf_contact
|
|
where cust_name = {cust_name} and mobile={mobile}
|
|
</i>
|
|
|
|
<i id="isHasContact_add">
|
|
select * from V_hfcontact_test2
|
|
where cust_name = {cust_name} and phone={mobile}
|
|
</i>
|
|
|
|
<!--更新联系人-->
|
|
<i id="updateContact">
|
|
update hf_contact
|
|
set contact={contact},
|
|
flag={flag},
|
|
operator_code={operator_code},
|
|
operator_name={operator_name},
|
|
operate_date=sysdate,
|
|
mobile_mark={mobile_mark},
|
|
source={source}
|
|
where cust_name = {cust_name} and mobile={mobile}
|
|
</i>
|
|
|
|
<!--保存异常信息-->
|
|
<i id="saveException">
|
|
insert into HF_EXCUSTOMER_INFO
|
|
(ID,CUSTOMER_ID,CUST_NAME,CUST_TAX_CODE,FEEDBACK,CONTACTS_INFO,END_DATE,
|
|
CREATE_DATE,CUST_TYPE,ORG_ID,ORG_NAME,REVENUEID,REVENUENAME,INVOICE_ADDR,
|
|
LEGAL_PERSON,CUTSTYPE,CUTSREMARK,RUSTYPE,DEALTIME,ISTAXATION,REMARK,HF_REMARK)
|
|
values
|
|
({id},{customer_id},{cust_name},{cust_tax_code},{feedback},{contacts_info},{end_date},
|
|
{create_date},{cust_type},{org_id},{org_name},{revenueid},{revenuename},{invoice_addr},
|
|
{legal_person},{cutstype},{cutsremark},{rustype},{dealtime},{istaxation},{remark},{hf_remark})
|
|
</i>
|
|
|
|
<!--更新异常信息-->
|
|
<i id="updateException">
|
|
update HF_EXCUSTOMER_INFO
|
|
set feedback={feedback},
|
|
contacts_info={contacts_info},
|
|
hf_remark={hf_remark},
|
|
update_name={update_name},
|
|
update_date=sysdate,
|
|
rustype={rustype},
|
|
cutsremark={cutsremark},
|
|
dealtime={dealtime},
|
|
cutstype={cutstype},
|
|
state={state}
|
|
where 1=1
|
|
and id={id}
|
|
</i>
|
|
</sql>
|
|
|
|
<sql group="revisitItemSync">
|
|
|
|
<i id="getItemName">
|
|
<![CDATA[
|
|
select item_id,item_name
|
|
from (
|
|
select a.fid as item_id,
|
|
a.fname||'_'||b.item_f2 as item_name
|
|
from item a
|
|
left join item_t81 b
|
|
on a.fid=b.itemid
|
|
where a.fitemclassid=81
|
|
order by a.fid)
|
|
where $like(item_name,key)
|
|
]]>
|
|
</i>
|
|
|
|
<i id="getItemList">
|
|
<![CDATA[
|
|
select *
|
|
from REVISIT_ITEM_SYNCSETTING a
|
|
where $like(a.ITEM_id,itemId)
|
|
and del_flag=0
|
|
]]>
|
|
</i>
|
|
|
|
<i id="addItemSetting">
|
|
<![CDATA[
|
|
insert into revisit_Item_syncsetting
|
|
(id,item_id,item_name,is_sync,description,create_id,create_date,last_edit_id,last_edit_date)
|
|
values
|
|
({id},{item_id},{item_name},{is_sync},{description},{user_id},sysdate,
|
|
{user_id},sysdate)
|
|
]]>
|
|
</i>
|
|
|
|
<i id="editItemSetting">
|
|
<![CDATA[
|
|
update revisit_Item_syncsetting
|
|
set is_sync = {is_sync},
|
|
description = {description},
|
|
last_edit_id={user_id},
|
|
last_edit_date=sysdate
|
|
where id={id}
|
|
and del_flag=0
|
|
]]>
|
|
</i>
|
|
|
|
<i id="deleteItemSetting">
|
|
<![CDATA[
|
|
update revisit_Item_syncsetting
|
|
set del_flag = 1,
|
|
last_edit_id={user_id},
|
|
last_edit_date=sysdate
|
|
where id={id}
|
|
]]>
|
|
</i>
|
|
|
|
</sql>
|
|
|
|
<!--回访记录-->
|
|
<sql group="hfrecord">
|
|
|
|
<i id="getRecordList">
|
|
select
|
|
l.log_id,l.obj_id,l.type,l.operate_name,l.operate_date,l.remark||l.suggestion as remark,
|
|
case when l.is_success='0' then '回访不成功'
|
|
when l.is_success='1' then '回访成功'
|
|
when l.is_success='2' then '不需要回访' end as is_success,
|
|
e.reflect_name,r.cust_name,r.detail,lp.video_path,lp.remark as ph_remark,lp.log_id as logphone_id
|
|
from hf_log l
|
|
left join revisit_reflect_type e
|
|
on l.reflect_type_id = e.reflect_id
|
|
<!--left join (select a.record_id,a.cust_name,to_char(wm_concat(b.spfl||':'||b.spmc)) as detail
|
|
from hf_record a,hf_custinfo b
|
|
where instr(a.sp_ids,b.id) > 0
|
|
and b.cust_naem = a.cust_name
|
|
group by a.record_id,a.cust_name) r
|
|
on r.record_id=l.obj_id-->
|
|
left join (select a.obj_id,b.cust_naem as cust_name,
|
|
to_char(wm_concat(b.spfl||':'||b.spmc)) as detail
|
|
from hf_custinfo b,hf_log a
|
|
where a.sp_id=b.id
|
|
and a.type='answer'
|
|
group by a.obj_id,b.cust_naem) r
|
|
on r.obj_id=l.log_id
|
|
left join hf_log lp
|
|
on lp.type='phone'
|
|
and lp.obj_id=l.log_id
|
|
where l.type='revisit'
|
|
and l.is_success!='2'
|
|
and ({searchbegindate} is null or l.operate_date>=to_date({searchbegindate},'yyyy-mm-dd hh24:mi:ss'))
|
|
and ({searchenddate} is null or l.operate_date<=to_date({searchenddate},'yyyy-mm-dd hh24:mi:ss'))
|
|
and ({hf_state}=-1
|
|
or ({hf_state}=0 and l.is_success='1')
|
|
or ({hf_state}=2 and l.is_success='0'))
|
|
and $like(r.cust_name,cust_name)
|
|
and $like(r.detail,sp_name)
|
|
and $equal(l.operate_id,operate_name)
|
|
order by l.operate_date desc
|
|
</i>
|
|
|
|
<i id="getLogByCustName">
|
|
select l.log_id,l.operate_name,l.operate_date,s.detail,
|
|
case when l.is_success='1' then '回访成功'
|
|
when l.is_success='0' then '回访不成功'
|
|
when l.is_success='2' then '不需要回访' end as is_success,
|
|
e.reflect_name,l.suggestion
|
|
from hf_log l
|
|
left join (select r.record_id,r.cust_name,to_char(wm_concat(b.spfl||':'||b.spmc)) as detail
|
|
from hf_record r,hf_custinfo b
|
|
where r.cust_name={cust_name}
|
|
and instr(r.sp_ids,b.id) > 0
|
|
and b.cust_naem = r.cust_name
|
|
group by r.record_id,r.cust_name) s
|
|
on s.record_id = l.obj_id
|
|
left join revisit_reflect_type e
|
|
on l.reflect_type_id = e.reflect_id
|
|
where l.type='revisit'
|
|
and l.obj_id=s.record_id
|
|
order by operate_date desc
|
|
</i>
|
|
|
|
<i id="getAnswerByLogId">
|
|
select l.log_id,case when l.is_success='0' then '回访不成功'
|
|
when l.is_success='1' then '回访成功' else l.is_success end as is_success,
|
|
l.sp_id,c.spfl||':'||c.spmc as spmc,l.answers,l.remark
|
|
from hf_log l
|
|
left join hf_custinfo c
|
|
on l.sp_id= c.id
|
|
where l.type in('answer','noneed')
|
|
and l.obj_id={log_id}
|
|
</i>
|
|
|
|
<i id="getPhoneByLogId">
|
|
select *
|
|
from hf_log l
|
|
where l.type='phone'
|
|
and l.obj_id={log_id}
|
|
</i>
|
|
|
|
<i id="getHfLogList">
|
|
|
|
select l.log_id,l.obj_id,l.type,l.operate_name,to_char(l.operate_date,'yyyy-mm-dd hh24:mi:ss') as operate_date,
|
|
l.suggestion as remark,
|
|
case when l.is_success='0' then '回访不成功'
|
|
when l.is_success='1' then '回访成功' end as is_success,
|
|
e.reflect_name,r.cust_name,r.detail,lp.phone_rec
|
|
from hf_log l
|
|
left join revisit_reflect_type e
|
|
on l.reflect_type_id = e.reflect_id
|
|
inner join (select a.obj_id,b.cust_naem as cust_name,
|
|
to_char(wm_concat(b.spfl||':'||b.spmc)) as detail
|
|
from hf_custinfo b,hf_log a
|
|
where a.sp_id=b.id
|
|
and a.type='answer'
|
|
and $like(b.cust_naem,cust_name)
|
|
and (({type}='-1')
|
|
OR ({type}='0' and (b.type is null or b.type = ''))
|
|
OR ({type}='1' and (b.type='1'))
|
|
OR ({type}='2' and (b.type='2')))
|
|
group by a.obj_id,b.cust_naem) r
|
|
on r.obj_id=l.log_id
|
|
left join (select obj_id,
|
|
'' as phone_rec
|
|
from hf_log where type='phone' group by obj_id)lp
|
|
on lp.obj_id=l.log_id
|
|
where l.type='revisit'
|
|
and $equal(l.reflect_type_id,reflect)
|
|
and ({searchbegindate} is null or l.operate_date>=to_date({searchbegindate},'yyyy-mm-dd hh24:mi:ss'))
|
|
and ({searchenddate} is null or l.operate_date<=to_date({searchenddate},'yyyy-mm-dd hh24:mi:ss'))
|
|
and l.is_success !='2'
|
|
and $equal(l.is_success,hf_state)
|
|
order by l.operate_date desc
|
|
</i>
|
|
|
|
<i id="getHfResultList">
|
|
select org_name,cust_naem as cust_name,cust_tax_code,
|
|
spfl,xsrq,spmc,ywy,price,hf_name,hf_phone,prepare_name,prepare_phone,
|
|
case when h.is_success='0' then '回访不成功'
|
|
when h.is_success='1' then '回访成功' end as is_success,
|
|
e.reflect_name,
|
|
v.suggestion
|
|
from hf_custinfo h
|
|
left join (select * from (select l.*,ROW_NUMBER() OVER(PARTITION BY l.sp_id ORDER BY operate_date DESC) as rn from hf_log l
|
|
where l.type='answer') where rn=1)r
|
|
on r.sp_id = h.id
|
|
left join (select * from hf_log where type='revisit')v
|
|
on v.log_id=r.obj_id
|
|
left join revisit_reflect_type e
|
|
on v.reflect_type_id = e.reflect_id
|
|
where 1=1
|
|
and h.is_hf=1
|
|
and $equal(h.org_name,org_name)
|
|
and $like(h.cust_naem,cust_name)
|
|
and $equal(h.is_success,hf_state)
|
|
and $between(h.xsrq,searchbegindate,searchenddate)
|
|
and h.del_flag!=1
|
|
and (({type}='-1')
|
|
OR ({type}='0' and (h.type is null or h.type = ''))
|
|
OR ({type}='1' and (h.type='1'))
|
|
OR ({type}='2' and (h.type='2')))
|
|
and $equal(e.reflect_id,reflect)
|
|
order by h.cust_naem,h.xsrq
|
|
</i>
|
|
|
|
<!--获取会员和非会员回访结果-->
|
|
<!-- <i id="getHyHfResult">
|
|
select count(1)
|
|
from hf_custinfo h
|
|
left join (select * from (select l.*,ROW_NUMBER() OVER(PARTITION BY l.sp_id ORDER BY operate_date DESC) as rn from hf_log l
|
|
where l.type='answer') where rn=1)r
|
|
on r.sp_id = h.id
|
|
left join (select * from hf_log where type='revisit')v
|
|
on v.log_id=r.obj_id
|
|
left join revisit_reflect_type e
|
|
on v.reflect_type_id = e.reflect_id
|
|
where 1=1
|
|
and h.is_hf=1
|
|
and $equal(h.is_success,hf_state)
|
|
and $between(h.xsrq,searchbegindate,searchenddate)
|
|
and h.del_flag!=1
|
|
and (({type}='-1')
|
|
OR ({type}='0' and (h.type is null or h.type = ''))
|
|
OR ({type}='1' and (h.type='1'))
|
|
OR ({type}='2' and (h.type='2')))
|
|
and (({ishy}='-1')
|
|
OR ({ishy}='1' and h.spmc like '%培训费%')
|
|
OR ({ishy}='0' and h.spmc not like '%培训费%'))
|
|
order by h.cust_naem,h.xsrq
|
|
</i>-->
|
|
<!--获取托管回访结果-->
|
|
<i id="getHyHfResult">
|
|
select count(1)
|
|
from hf_custinfo h
|
|
left join (select * from (select l.*,ROW_NUMBER() OVER(PARTITION BY l.sp_id ORDER BY operate_date DESC) as rn from hf_log l
|
|
where l.type='answer') where rn=1)r
|
|
on r.sp_id = h.id
|
|
left join (select * from hf_log where type='revisit')v
|
|
on v.log_id=r.obj_id
|
|
left join revisit_reflect_type e
|
|
on v.reflect_type_id = e.reflect_id
|
|
where 1=1
|
|
and h.is_hf=1
|
|
and $equal(h.is_success,hf_state)
|
|
and $between(h.xsrq,searchbegindate,searchenddate)
|
|
and h.del_flag!=1
|
|
and (({type}='-1')
|
|
OR ({type}='0' and (h.type is null or h.type = ''))
|
|
OR ({type}='1' and (h.type='1'))
|
|
OR ({type}='2' and (h.type='2')))
|
|
and (({ishy}='-1')
|
|
OR ({ishy}='1' and (h.spmc like '%托管%' or h.spmc like '%51信享云台%'))
|
|
OR ({ishy}='0' and (h.spmc not like '%培训费%' and h.spmc not like '%51信享云台%')))
|
|
order by h.cust_naem,h.xsrq
|
|
</i>
|
|
<!--获取回访结果类型-->
|
|
<i id="getHfResultType">
|
|
select result_type,
|
|
case when result_type='回访成功' then 1
|
|
when result_type='其他' then 3
|
|
else 2 end as rowtype
|
|
from(
|
|
select distinct case when h.is_success='1' then '回访成功'
|
|
when h.is_success='0' and e.reflect_name is not null then e.reflect_name
|
|
else '其他' end as result_type
|
|
from hf_custinfo h
|
|
left join (select * from (select l.*,ROW_NUMBER() OVER(PARTITION BY l.sp_id ORDER BY operate_date DESC) as rn from hf_log l
|
|
where l.type='answer') where rn=1)r
|
|
on r.sp_id = h.id
|
|
left join (select * from hf_log where type='revisit')v
|
|
on v.log_id=r.obj_id
|
|
left join revisit_reflect_type e
|
|
on v.reflect_type_id = e.reflect_id
|
|
where 1=1
|
|
and h.is_hf=1
|
|
and $between(h.xsrq,searchbegindate,searchenddate)
|
|
and h.del_flag!=1
|
|
and (({type}='-1')
|
|
OR ({type}='0' and (h.type is null or h.type = ''))
|
|
OR ({type}='1' and (h.type='1'))
|
|
OR ({type}='2' and (h.type='2')))
|
|
group by r.operate_name,e.reflect_name,h.is_success)
|
|
order by rowtype
|
|
</i>
|
|
<!--获取金融回访结果类型-->
|
|
<i id="getJRHfResultType">
|
|
select question_id,question_name from REVISIT_QUESTION_DETAIL t
|
|
where t.question_type_name='金融'
|
|
order by question_id
|
|
</i>
|
|
<!--获取金融回访结果明细-->
|
|
<i id="getJRHfResultList">
|
|
select h.org_name,h.cust_naem,h.cust_tax_code,
|
|
h.spfl,h.xsrq,h.spmc,h.hf_name,h.hf_phone,h.dkjg,h.fkrq,
|
|
h.fkje,h.ykqx,h.ywy,h.lilv,h.sdsj,h.ssqy,h.sxzt,h.sxed,h.sfyx,
|
|
case when h.is_success='0' then '回访不成功'
|
|
when h.is_success='1' then '回访成功' end as hf_result,
|
|
e.reflect_name,
|
|
v.suggestion,
|
|
r.answers,
|
|
to_char(r.operate_date,'yyyy/mm/dd hh24:mi:ss') as operate_date,
|
|
r.sp_id
|
|
from hf_custinfo h
|
|
left join (select * from (select l.*,ROW_NUMBER() OVER(PARTITION BY l.sp_id ORDER BY operate_date DESC) as rn from hf_log l
|
|
where l.type='answer') where rn=1)r
|
|
on r.sp_id = h.id
|
|
left join (select * from hf_log where type='revisit')v
|
|
on v.log_id=r.obj_id
|
|
left join revisit_reflect_type e
|
|
on v.reflect_type_id = e.reflect_id
|
|
where 1=1
|
|
and h.is_hf=1
|
|
and $equal(h.org_name,org_name)
|
|
and $like(h.cust_naem,cust_name)
|
|
and $equal(h.is_success,hf_state)
|
|
and $between(h.xsrq,searchbegindate,searchenddate)
|
|
and h.del_flag!=1
|
|
and h.type='1'
|
|
and $equal(e.reflect_id,reflect)
|
|
order by h.sdsj
|
|
</i>
|
|
</sql>
|
|
|
|
|
|
<!--异常-->
|
|
<sql group="hfexception">
|
|
|
|
<i id="getDealType">
|
|
<![CDATA[
|
|
SELECT code_id as id,code_desc as name
|
|
FROM revisit_base_code
|
|
WHERE del_flag=0
|
|
and code_type='ex_dealtype'
|
|
order by code_id
|
|
]]>
|
|
</i>
|
|
|
|
<i id="saveExState">
|
|
<![CDATA[
|
|
update hf_excustomer_info
|
|
set rustype={rustype},
|
|
cutsremark={cutsremark},
|
|
dealtime={dealtime},
|
|
update_date=sysdate,
|
|
update_name={update_name},
|
|
cutstype={cutstype},
|
|
remark={remark},
|
|
state={state}
|
|
where id={id}
|
|
]]>
|
|
</i>
|
|
|
|
<i id="saveExLog">
|
|
insert into HF_EX_LOG
|
|
(ID,CREATE_DATE,CREATE_NAME,ACTION,REMARK,OBJ_ID,
|
|
INFO,CUST_TYPE,MIAOSHU)
|
|
values
|
|
({id},{create_date},{create_name},{action},{remark},{obj_id},
|
|
{info},{cust_type},{miaoshu})
|
|
</i>
|
|
</sql>
|
|
|
|
</sqls>
|