Commit aef1f821 authored by chenzhuo's avatar chenzhuo

公众号合同查询接口

parent 80dd9ee9
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:fields>
<bm:field name="times"/>
<bm:field name="due_year"/>
<bm:field name="due_date"/>
<bm:field name="cf_item"/>
<bm:field name="due_amount"/>
<bm:field name="received_amount"/>
<bm:field name="cf_status"/>
<bm:field name="cf_status_n"/>
</bm:fields>
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select cc.times, --期数
to_char(cc.due_date, 'YYYY') due_year, --支付年
to_char(cc.due_date, 'MM-dd') due_year, --支付日期
(select h.description from hls_cashflow_item h
where h.cf_item = cc.cf_item
and h.enabled_flag = 'Y'
and rownum =1) cf_item, --项目
to_char(nvl(cc.due_amount, 0),
'FM9,999,999,999,990.00') due_amount, --应付金额
to_char(nvl(cc.received_amount, 0),
'FM9,999,999,999,990.00') received_amount, --已付金额
(case
when cc.write_off_flag = 'FULL' then
'PAID'
when cc.overdue_status = 'Y' then
'OVERDUE'
else
'TOPAY'
end) as cf_status,
(case
when cc.write_off_flag = 'FULL' then
'已支付'
when cc.overdue_status = 'Y' then
'已逾期'
else
'待支付'
end) as cf_status_n --支付状态
from con_contract_cashflow cc
where cc.contract_id = ${@contract_id}
and cc.cf_item = 1
order by cc.times
]]></bm:query-sql>
</bm:operation>
</bm:operations>
</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 *
from (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,
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 = 'CON500_CONTRACT_STATUS'
AND v.code_value = t1.contract_status) 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, --合同开始日期
to_char(t1.et_date, 'yyyy-mm-dd') 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.dd_bank_account_name, --还款账户名称
t1.dd_bank_branch_name, --还款银行名称
t1.dd_bank_account_num, --还款银行账号
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
and cc.cf_direction = 'INFLOW'
and cc.cf_status = 'RELEASE') due_amount_all --应还总额
from con_contract t1
where t1.data_class = 'NORMAL'
and t1.ec_sign_type in ('INITIATE', 'SIGNING')
and t1.contract_id in
(select distinct cs.contract_id
from con_contract_ele_signer cs
where cs.id_no = ${@id_no}
and cs.id_type = ${@id_type})) v #WHERE_CLAUSE#
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="contract_id"/>
<bm:field name="ele_flow_id"/>
<bm:field name="contract_number"/>
<bm:field name="bp_id_tenant_n"/>
<bm:field name="bp_id_agent_level1_n"/>
<bm:field name="machine_number"/>
<bm:field name="contract_status"/>
<bm:field name="contract_status_n"/>
<bm:field name="modelcd"/>
<bm:field name="lease_start_date"/>
<bm:field name="lease_end_date"/>
<bm:field name="due_day"/>
<bm:field name="total_sign"/>
<bm:field name="dd_bank_branch_name"/>
<bm:field name="dd_bank_account_name"/>
<bm:field name="dd_bank_account_num"/>
<bm:field name="lease_times"/>
<bm:field name="due_amount_all"/>
</bm:fields>
<bm:query-fields>
<bm:query-field name="contract_number" queryExpression="v.contract_number = '%'||${@contract_number}||'%' "/>
<bm:query-field name="contract_status" queryExpression="v.contract_status = ${@contract_status}"/>
</bm:query-fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:fields>
<bm:field name="file_name"/>
<bm:field name="file_path"/>
</bm:fields>
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select faa.file_name, faa.file_path
FROM fnd_atm_attachment_multi m1, fnd_atm_attachment faa
WHERE m1.table_name = 'CON_CONTRACT'
AND m1.attachment_id = faa.attachment_id
AND m1.table_pk_value in
(select pc.check_id
from PRJ_CDD_ITEM_CHECK pc
where pc.cdd_item_id in
(select pi.cdd_item_id
from prj_cdd_item pi
where pi.cdd_item in ('CONTRACT','LEASE_ITEM_REQ','TN_GU_INFO','GUARANTEE_LETTER_OEC','CHECK_INFO','SPOUSE_COMMITMENT','PUR_CONTRACT','CASHFLOW_INFO','ITEM_TRAN_NOTICE','PAYMENT_REQ','MORT_CONTRACT','ET_TREATY')
and pi.cdd_list_id =
(select cc.cdd_list_id
from con_contract cc
where cc.contract_id = ${@contract_id}
and cc.data_class = 'NORMAL')))
]]></bm:query-sql>
</bm:operation>
</bm:operations>
</bm:model>
<?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_contract_query() {
var contract_list_details;
try {
var contract_list_bm = $bm('wx.WX100.con_contract_list_query');
var contract_list_map;
var inputData = $ctx.parameter.inputData;
var contractStatus = $ctx.parameter.contractStatus;
if (inputData == null){
if(contractStatus == null){
contract_list_map = contract_list_bm.queryAsMap({
id_no:$ctx.parameter.idNo,
id_type:$ctx.parameter.idType
});
}else{
contract_list_map = contract_list_bm.queryAsMap({
id_no:$ctx.parameter.idNo,
id_type:$ctx.parameter.idType,
contract_status:contractStatus
});
}
}else{
if(contractStatus == null){
contract_list_map = contract_list_bm.queryAsMap({
id_no:$ctx.parameter.idNo,
id_type:$ctx.parameter.idType,
contract_number:inputData
});
}else{
contract_list_map = contract_list_bm.queryAsMap({
id_no:$ctx.parameter.idNo,
id_type:$ctx.parameter.idType,
contract_number:inputData,
contract_status:contractStatus
});
}
}
contract_list_details = contract_list_map.getChildren();
$ctx.parameter.return_status = '0';
$ctx.parameter.return_message = '执行成功';
} catch (e) {
$ctx.success = "true";
$ctx.parameter.return_status = '1';
$ctx.parameter.return_message = String(e);
}
//返回结果
var result = {
code: $ctx.parameter.return_status,
message: $ctx.parameter.return_message,
Contracts: []
};
var Contracts = result.Contracts;
if (contract_list_details) {
for (var i = 0;i < contract_list_details.length;i++) {
var contract_list_detail = contract_list_details[i];
var contract_id = contract_list_detail.contract_id;
//if(ec_sign_type == 'NEW'||ec_sign_type == 'INITIATE' ||ec_sign_type == 'SIGNING') {
var cashflowList = [];
//合同现金流信息查询
var lease_items_bm = $bm('wx.WX100.con_cashflow_info');
var lease_details_map = lease_items_bm.queryAsMap({
contract_id: contract_id
});
var lease_details = lease_details_map.getChildren();
for (var j = 0; j < lease_details.length; j++) {
cashflowList.push({
time: lease_details[j].times,
dueYear: lease_details[j].due_year,
dueDate:lease_details[j].due_date,
cfItem:lease_details[j].cf_item,
dueAmt:lease_details[j].due_amount,
unDueAmt:lease_details[j].received_amount,
dueStatus:lease_details[j].cf_status_n
});
}
//合同附件信息查询
var docsList = [];
var file_list_bm = $bm('wx.WX100.con_file_download');
var file_list_map = file_list_bm.queryAsMap({
contract_id: contract_id
});
var file_list_details = file_list_map.getChildren();
for (var j = 0; j < file_list_details.length; j++) {
docsList.push({
fileName: file_list_details[j].file_name,
fileUrl: file_list_details[j].file_path
});
}
Contracts.push({
"contractNo": contract_list_detail.contract_id,
"flowId": contract_list_detail.ele_flow_id,
"contractNumber": contract_list_detail.contract_number,
"telentName": contract_list_detail.bp_id_tenant_n,
"agentName": contract_list_detail.bp_id_agent_level1_n,
"serialNo": contract_list_detail.machine_number,
"contractStatus": contract_list_detail.contract_status_n,
"modelNo":contract_list_detail.modelcd,
"firstDay":contract_list_detail.lease_start_date,
"endDay":contract_list_detail.lease_end_date,
"dueDay":contract_list_detail.due_day,
"signAmt": contract_list_detail.total_sign,
"bank":contract_list_detail.dd_bank_branch_name,
"bankName":contract_list_detail.dd_bank_account_name,
"bankNum":contract_list_detail.dd_bank_account_num,
"dueAmountAll":contract_list_detail.due_amount_all,
"cashflowList":cashflowList,
"docsList": docsList
});
// }
}
}
$ctx.parameter.json = JSON.stringify(result);
}
if ($ctx.parameter.return_status != 'E' && $ctx.parameter.return_status != 'TIMEOUT') {
con_contract_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