Commit d5bc8bb5 authored by chenzhuo's avatar chenzhuo

合同查询接口调整

parent 8bf1657c
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
and rownum =1) cf_item, --项目 and rownum =1) cf_item, --项目
to_char(nvl(cc.due_amount, 0), to_char(nvl(cc.due_amount, 0),
'FM9,999,999,999,990.00') due_amount, --应付金额 'FM9,999,999,999,990.00') due_amount, --应付金额
to_char(nvl(cc.received_amount, 0), to_char(nvl(cc.due_amount, 0)-nvl(cc.received_amount, 0),
'FM9,999,999,999,990.00') received_amount, --已付金额 'FM9,999,999,999,990.00') received_amount, --已付金额
(case (case
when cc.write_off_flag = 'FULL' then when cc.write_off_flag = 'FULL' then
......
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
(select hm.id_card_no (select hm.id_card_no
from hls_bp_master hm from hls_bp_master hm
where hm.bp_id = t1.bp_id_tenant) id_card_no_tenant, where hm.bp_id = t1.bp_id_tenant) id_card_no_tenant,
(select hm.bp_class
from hls_bp_master hm
where hm.bp_id = t1.bp_id_tenant) bp_id_tenant_type,
t1.bp_id_agent_level1, t1.bp_id_agent_level1,
(select hm.bp_name (select hm.bp_name
from hls_bp_master hm from hls_bp_master hm
...@@ -26,16 +29,25 @@ ...@@ -26,16 +29,25 @@
WHERE i.contract_id = t1.contract_id WHERE i.contract_id = t1.contract_id
AND i.equipment_type = 'MAIN') machine_number, --机号 AND i.equipment_type = 'MAIN') machine_number, --机号
t1.contract_status, t1.contract_status,
(SELECT v.code_value_name (select v.code_value_name
FROM sys_code_values_v v from sys_code_values_v v
WHERE v.code = 'CON500_CONTRACT_STATUS' where v.code = decode(t1.sign_type,
AND v.code_value = t1.contract_status) AS contract_status_n, 'PAPER_SIGN',
'PAPER_SIGN_STATUS',
'ELE_SIGN',
'ELE_SIGN_STATUS')
and v.code_enabled_flag = 'Y'
and v.code_value = t1.contract_status
and v.code_value_enabled_flag = 'Y') AS contract_status_n,
(select ci.modelcd (select ci.modelcd
from con_contract_lease_item ci from con_contract_lease_item ci
where ci.contract_id = t1.contract_id where ci.contract_id = t1.contract_id
and ci.equipment_type = 'MAIN') modelcd, --机型 and ci.equipment_type = 'MAIN') modelcd, --机型
to_char(t1.lease_start_date, 'yyyy-mm-dd') lease_start_date, --合同开始日期 to_char(t1.lease_start_date, 'yyyy-mm-dd') lease_start_date, --合同开始日期
to_char(t1.et_date, 'yyyy-mm-dd') lease_end_date, --合同结束日期 (select to_char(ccc.due_date,'yyyy-MM-dd') from con_contract_cashflow ccc
where ccc.contract_id = t1.contract_id and ccc.cf_item = 1
and ccc.times = (select max(cc.times) from con_contract_cashflow cc where cc.contract_id = ccc.contract_id
and ccc.cf_item = 1)) lease_end_date, --合同结束日期
(select to_char(cc.due_date, 'dd') (select to_char(cc.due_date, 'dd')
from con_contract_cashflow cc from con_contract_cashflow cc
where cc.contract_id = t1.contract_id where cc.contract_id = t1.contract_id
...@@ -44,22 +56,157 @@ ...@@ -44,22 +56,157 @@
and rownum = 1) due_day, --还款日 and rownum = 1) due_day, --还款日
(NVL(t1.down_payment, 0) + NVL(t1.residual_value, 0) + (NVL(t1.down_payment, 0) + NVL(t1.residual_value, 0) +
NVL(t1.total_rental, 0)) total_sign, --总金额 NVL(t1.total_rental, 0)) total_sign, --总金额
t1.dd_bank_account_name, --还款账户名称 t1.bank_branch_num, --还款银行账号
t1.dd_bank_branch_name, --还款银行名称 t1.bank_account_name, --还款账户名称
t1.dd_bank_account_num, --还款银行账号 (select ba.bank_full_name
from hls_bp_master_bank_account ba
where ba.bank_account_id = t1.bank_account_id) bank_full_name, --还款银行名称
t1.lease_times, --期数 t1.lease_times, --期数
(select to_char(sum(cc.due_amount),'FM9,999,999,999,990.00') from con_contract_cashflow cc (select to_char(sum(cc.due_amount), 'FM9,999,999,999,990.00')
from con_contract_cashflow cc
where cc.contract_id = t1.contract_id
and cc.cf_direction = 'INFLOW'
and cc.cf_status = 'RELEASE') due_amount_all --应还总额
from con_contract t1, con_contract_change_req cr
where t1.data_class = 'NORMAL'
and t1.contract_id = cr.contract_id
and t1.contract_status in
(select v.code_value
from sys_code_values_v v
where v.code = decode(t1.sign_type,
'PAPER_SIGN',
'PAPER_SIGN_STATUS',
'ELE_SIGN',
'ELE_SIGN_STATUS')
and v.code_enabled_flag = 'Y'
and v.code_value_enabled_flag = 'Y')
and ((${@account_type} = 'PE' and exists
(select 1
from con_contract_bp ccb, hls_bp_master hb
where ccb.bp_id = hb.bp_id
and ccb.contract_id = t1.contract_id
and (ccb.bp_category in ('TENANT', 'GUARANTOR'))
and (ccb.id_card_no = ${@id_no} or ccb.id_no_sp = ${@id_no}))))
or (${@account_type} = 'AG' and exists
(select 1
from hls_bp_master_signer hs
where hs.hls_bp_signer_id = t1.signer
and hs.id_card = ${@id_no}))
or (${@account_type} = 'AG' and exists
(select 1
from con_contract_bp cb
where cb.contract_id = t1.contract_id
and cb.bp_category = 'GUARANTOR'
and cb.bp_class = 'ORG'
and cb.id_card_no_leg = ${@id_no}))
or (${@account_type} = 'LP' and exists
(select 1
from con_contract_bp cb, hls_bp_master hb
where cb.bp_id = hb.bp_id
and hb.social_code = ${@id_no}))
union all
select t1.contract_id,
t1.ele_flow_id,
t1.contract_number,
t1.bp_id_tenant,
(select hm.bp_name
from hls_bp_master hm
where hm.bp_id = t1.bp_id_tenant) bp_id_tenant_n,
(select hm.id_card_no
from hls_bp_master hm
where hm.bp_id = t1.bp_id_tenant) id_card_no_tenant,
(select hm.bp_class
from hls_bp_master hm
where hm.bp_id = t1.bp_id_tenant) bp_id_tenant_type,
t1.bp_id_agent_level1,
(select hm.bp_name
from hls_bp_master hm
where hm.bp_id = t1.bp_id_agent_level1) bp_id_agent_level1_n,
(select hm.id_card_no_leg
from hls_bp_master hm
where hm.bp_id = t1.bp_id_agent_level1) id_card_no_agent,
(SELECT i.machine_number
FROM con_contract_lease_item i
WHERE i.contract_id = t1.contract_id
AND i.equipment_type = 'MAIN') machine_number, --机号
t1.contract_status,
(select v.code_value_name
from sys_code_values_v v
where v.code = decode(t1.sign_type,
'PAPER_SIGN',
'PAPER_SIGN_STATUS',
'ELE_SIGN',
'ELE_SIGN_STATUS')
and v.code_value = t1.contract_status
and v.code_enabled_flag = 'Y'
and v.code_value_enabled_flag = 'Y') AS contract_status_n,
(select ci.modelcd
from con_contract_lease_item ci
where ci.contract_id = t1.contract_id
and ci.equipment_type = 'MAIN') modelcd, --机型
to_char(t1.lease_start_date, 'yyyy-mm-dd') lease_start_date, --合同开始日期
(select to_char(ccc.due_date,'yyyy-MM-dd') from con_contract_cashflow ccc
where ccc.contract_id = t1.contract_id and ccc.cf_item = 1
and ccc.times = (select max(cc.times) from con_contract_cashflow cc where cc.contract_id = ccc.contract_id
and ccc.cf_item = 1)) lease_end_date, --合同结束日期
(select to_char(cc.due_date, 'dd')
from con_contract_cashflow cc
where cc.contract_id = t1.contract_id
and cc.times = 1
and cc.cf_item = '1'
and rownum = 1) due_day, --还款日
(NVL(t1.down_payment, 0) + NVL(t1.residual_value, 0) +
NVL(t1.total_rental, 0)) total_sign, --总金额
t1.bank_branch_num, --还款银行账号
t1.bank_account_name, --还款账户名称
(select ba.bank_full_name
from hls_bp_master_bank_account ba
where ba.bank_account_id = t1.bank_account_id) bank_full_name, --还款银行名称
t1.lease_times, --期数
(select to_char(sum(cc.due_amount), 'FM9,999,999,999,990.00')
from con_contract_cashflow cc
where cc.contract_id = t1.contract_id where cc.contract_id = t1.contract_id
and cc.cf_direction = 'INFLOW' and cc.cf_direction = 'INFLOW'
and cc.cf_status = 'RELEASE') due_amount_all --应还总额 and cc.cf_status = 'RELEASE') due_amount_all --应还总额
from con_contract t1 from con_contract t1
where t1.data_class = 'NORMAL' where t1.data_class = 'NORMAL'
and t1.ec_sign_type in ('INITIATE', 'SIGNING') and t1.contract_status in
and t1.contract_id in (select v.code_value
(select distinct cs.contract_id from sys_code_values_v v
from con_contract_ele_signer cs where v.code = decode(t1.sign_type,
where cs.id_no = ${@id_no} 'PAPER_SIGN',
and cs.id_type = ${@id_type})) v #WHERE_CLAUSE# 'PAPER_SIGN_STATUS',
'ELE_SIGN',
'ELE_SIGN_STATUS')
and v.code_enabled_flag = 'Y'
and v.code_value_enabled_flag = 'Y')
and ((${@account_type} = 'PE' and exists
(select 1
from con_contract_bp ccb, hls_bp_master hb
where ccb.bp_id = hb.bp_id
and ccb.contract_id = t1.contract_id
and (ccb.bp_category in ('TENANT', 'GUARANTOR') and
(ccb.id_card_no = ${@id_no} or ccb.id_no_sp = ${@id_no})))) or
(${@account_type} = 'AG' and exists
(select 1
from hls_bp_master_signer hs
where hs.hls_bp_signer_id = t1.signer
and hs.id_card = ${@id_no})) or
(${@account_type} = 'AG' and exists
(select 1
from con_contract_bp cb
where cb.contract_id = t1.contract_id
and cb.bp_category = 'GUARANTOR'
and cb.bp_class = 'ORG'
and cb.id_card_no_leg = ${@id_no})) or
(${@account_type} = 'LP' and exists
(select 1
from con_contract_bp cb, hls_bp_master hb
where cb.bp_id = hb.bp_id
and hb.social_code = ${@id_no})))
) v #WHERE_CLAUSE#
]]></bm:query-sql> ]]></bm:query-sql>
</bm:operation> </bm:operation>
</bm:operations> </bm:operations>
...@@ -68,6 +215,7 @@ ...@@ -68,6 +215,7 @@
<bm:field name="ele_flow_id"/> <bm:field name="ele_flow_id"/>
<bm:field name="contract_number"/> <bm:field name="contract_number"/>
<bm:field name="bp_id_tenant_n"/> <bm:field name="bp_id_tenant_n"/>
<bm:field name="bp_id_tenant_type"/>
<bm:field name="bp_id_agent_level1_n"/> <bm:field name="bp_id_agent_level1_n"/>
<bm:field name="machine_number"/> <bm:field name="machine_number"/>
<bm:field name="contract_status"/> <bm:field name="contract_status"/>
...@@ -77,14 +225,14 @@ ...@@ -77,14 +225,14 @@
<bm:field name="lease_end_date"/> <bm:field name="lease_end_date"/>
<bm:field name="due_day"/> <bm:field name="due_day"/>
<bm:field name="total_sign"/> <bm:field name="total_sign"/>
<bm:field name="dd_bank_branch_name"/> <bm:field name="bank_full_name"/>
<bm:field name="dd_bank_account_name"/> <bm:field name="bank_account_name"/>
<bm:field name="dd_bank_account_num"/> <bm:field name="bank_branch_num"/>
<bm:field name="lease_times"/> <bm:field name="lease_times"/>
<bm:field name="due_amount_all"/> <bm:field name="due_amount_all"/>
</bm:fields> </bm:fields>
<bm:query-fields> <bm:query-fields>
<bm:query-field name="contract_number" queryExpression="v.contract_number = '%'||${@contract_number}||'%' "/> <bm:query-field name="contract_number" queryExpression="v.contract_number like '%'||${@contract_number}||'%' "/>
<bm:query-field name="contract_status" queryExpression="v.contract_status = ${@contract_status}"/> <bm:query-field name="contract_status_n" queryExpression="v.contract_status_n = ${@contract_status}"/>
</bm:query-fields> </bm:query-fields>
</bm:model> </bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select decode(v.con_num,0,'N','Y') statusFlag from (
select count(1) con_num from con_contract cc
where cc.data_class = 'NORMAL'
and cc.sign_type = 'ELE_SIGN'
and cc.sign_contract_status = 'SIGNING'
and cc.ec_sign_type in ('INITIATE', 'SIGNING')
and cc.contract_id in (
select distinct t.contract_id from CON_CONTRACT_ELE_SIGNER t
where t.bp_name = ${@bp_name}
and t.id_no = ${@id_no}
and t.id_type = 'IdCard')) v
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="statusFlag"/>
</bm:fields>
</bm:model>
...@@ -9,30 +9,30 @@ ...@@ -9,30 +9,30 @@
var contract_list_map; var contract_list_map;
var inputData = $ctx.parameter.inputData; var inputData = $ctx.parameter.inputData;
var contractStatus = $ctx.parameter.contractStatus; var contractStatus = $ctx.parameter.contractStatus;
if (inputData == null){ if (inputData == null || inputData == ""){
if(contractStatus == null){ if(contractStatus == null || contractStatus == ""){
contract_list_map = contract_list_bm.queryAsMap({ contract_list_map = contract_list_bm.queryAsMap({
id_no:$ctx.parameter.idNo, id_no:$ctx.parameter.idNo,
id_type:$ctx.parameter.idType account_type:$ctx.parameter.accountType
}); });
}else{ }else{
contract_list_map = contract_list_bm.queryAsMap({ contract_list_map = contract_list_bm.queryAsMap({
id_no:$ctx.parameter.idNo, id_no:$ctx.parameter.idNo,
id_type:$ctx.parameter.idType, account_type:$ctx.parameter.accountType,
contract_status:contractStatus contract_status:contractStatus
}); });
} }
}else{ }else{
if(contractStatus == null){ if(contractStatus == null || contractStatus == ""){
contract_list_map = contract_list_bm.queryAsMap({ contract_list_map = contract_list_bm.queryAsMap({
id_no:$ctx.parameter.idNo, id_no:$ctx.parameter.idNo,
id_type:$ctx.parameter.idType, account_type:$ctx.parameter.accountType,
contract_number:inputData contract_number:inputData
}); });
}else{ }else{
contract_list_map = contract_list_bm.queryAsMap({ contract_list_map = contract_list_bm.queryAsMap({
id_no:$ctx.parameter.idNo, id_no:$ctx.parameter.idNo,
id_type:$ctx.parameter.idType, account_type:$ctx.parameter.accountType,
contract_number:inputData, contract_number:inputData,
contract_status:contractStatus contract_status:contractStatus
}); });
...@@ -57,7 +57,6 @@ ...@@ -57,7 +57,6 @@
for (var i = 0;i < contract_list_details.length;i++) { for (var i = 0;i < contract_list_details.length;i++) {
var contract_list_detail = contract_list_details[i]; var contract_list_detail = contract_list_details[i];
var contract_id = contract_list_detail.contract_id; var contract_id = contract_list_detail.contract_id;
//if(ec_sign_type == 'NEW'||ec_sign_type == 'INITIATE' ||ec_sign_type == 'SIGNING') {
var cashflowList = []; var cashflowList = [];
//合同现金流信息查询 //合同现金流信息查询
var lease_items_bm = $bm('wx.WX100.con_cashflow_info'); var lease_items_bm = $bm('wx.WX100.con_cashflow_info');
...@@ -80,13 +79,15 @@ ...@@ -80,13 +79,15 @@
var docsList = []; var docsList = [];
var file_list_bm = $bm('wx.WX100.con_file_download'); var file_list_bm = $bm('wx.WX100.con_file_download');
var file_list_map = file_list_bm.queryAsMap({ var file_list_map = file_list_bm.queryAsMap({
contract_id: contract_id contract_id: contract_id,
id_no:$ctx.parameter.idNo
}); });
var file_list_details = file_list_map.getChildren(); var file_list_details = file_list_map.getChildren();
for (var j = 0; j < file_list_details.length; j++) { for (var j = 0; j < file_list_details.length; j++) {
docsList.push({ docsList.push({
fileName: file_list_details[j].file_name, fileName: file_list_details[j].file_name,
fileUrl: file_list_details[j].file_path fileUrl: file_list_details[j].file_path,
attachmentId: file_list_details[j].attachment_id
}); });
} }
Contracts.push({ Contracts.push({
...@@ -94,6 +95,7 @@ ...@@ -94,6 +95,7 @@
"flowId": contract_list_detail.ele_flow_id, "flowId": contract_list_detail.ele_flow_id,
"contractNumber": contract_list_detail.contract_number, "contractNumber": contract_list_detail.contract_number,
"telentName": contract_list_detail.bp_id_tenant_n, "telentName": contract_list_detail.bp_id_tenant_n,
"telentType":contract_list_detail.bp_id_tenant_type,
"agentName": contract_list_detail.bp_id_agent_level1_n, "agentName": contract_list_detail.bp_id_agent_level1_n,
"serialNo": contract_list_detail.machine_number, "serialNo": contract_list_detail.machine_number,
"contractStatus": contract_list_detail.contract_status_n, "contractStatus": contract_list_detail.contract_status_n,
...@@ -102,14 +104,13 @@ ...@@ -102,14 +104,13 @@
"endDay":contract_list_detail.lease_end_date, "endDay":contract_list_detail.lease_end_date,
"dueDay":contract_list_detail.due_day, "dueDay":contract_list_detail.due_day,
"signAmt": contract_list_detail.total_sign, "signAmt": contract_list_detail.total_sign,
"bank":contract_list_detail.dd_bank_branch_name, "bank":contract_list_detail.bank_full_name,
"bankName":contract_list_detail.dd_bank_account_name, "bankName":contract_list_detail.bank_account_name,
"bankNum":contract_list_detail.dd_bank_account_num, "bankNum":contract_list_detail.bank_branch_num,
"dueAmountAll":contract_list_detail.due_amount_all, "dueAmountAll":contract_list_detail.due_amount_all,
"cashflowList":cashflowList, "cashflowList":cashflowList,
"docsList": docsList "docsList": docsList
}); });
// }
} }
} }
$ctx.parameter.json = JSON.stringify(result); $ctx.parameter.json = JSON.stringify(result);
......
<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:ns1="leaf.application.action" xmlns:p="uncertain.proc" xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
<a:init-procedure>
<s:server-script import="app/app_login_check.js"><![CDATA[
function con_bp_master_query() {
var statusFlag_map;
var statusFlag;
try {
var statusFlag_query = $bm('wx.WX100.con_contract_status_query');
statusFlag_map = statusFlag_query.queryAsMap({
bp_name:$ctx.parameter.name,
id_no:$ctx.parameter.idNo
});
var statusFlag_details = statusFlag_map.getChildren();
statusFlag = statusFlag_details[0].statusFlag;
$ctx.parameter.return_status = '0';
$ctx.parameter.return_message = '执行成功';
} catch (e) {
$ctx.success = "false";
$ctx.parameter.return_status = '1';
$ctx.parameter.return_message = String(e);
statusFlag = 'Y'
}
//返回结果
var result = {
code: $ctx.parameter.return_status,
message: $ctx.parameter.return_message,
statusFlag: statusFlag
};
$ctx.parameter.json = JSON.stringify(result);
}
if ($ctx.parameter.return_status != 'E' && $ctx.parameter.return_status != 'TIMEOUT') {
con_bp_master_query();
}
]]></s:server-script>
</a:init-procedure>
<a:service-output output="/parameter/@json"/>
</a:service>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment