Commit 837c0f49 authored by 18083's avatar 18083

佣金支付改造

parent 691e1454
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: trd
$Date: 2024-3-27 下午03:50:31
$Revision: 1.0
$Purpose:佣金付款
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1"
baseTable="CSH_PAYMENT_REQ_LN" needAccessControl="false">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select t.contract_id ref_doc_id,
f.cashflow_id ref_doc_line_id,
t.document_category ref_doc_category,
hc.bp_id,
t.bp_id_agent_level1,
t.contract_id,
f.cashflow_id,
t.contract_number,
t.contract_name,
hc.bp_id bp_id_agent_level1,
(select hbm.bp_name from hls_bp_master hbm where hbm.bp_id = hc.bp_id) bp_id_agent_level1_n,
hc.finance_amount,
t.lease_start_date,
hc.overdue_max_days,
hc.comsn_amount amount_agent,
hc.comsn_amount amount,
t.currency currency_code,
(SELECT gc.currency_name
FROM gld_currency_v gc
WHERE gc.currency_code = t.currency) currency_name,
(select to_char(sysdate, 'yyyy-mm') || '-20' from dual) apply_pay_date
FROM con_contract_cashflow f
join con_contract t
on t.contract_id = f.contract_id
join hlcm_comsn_reconcilia hc
on t.contract_id = hc.contract_id
where EXISTS (SELECT 1
FROM CSH_PAYMENT_CASHFLOW_ID_TEMP tmp
WHERE tmp.session_id = ${/session/@session_id}
AND tmp.cashflow_id = f.cashflow_id)
#WHERE_CLAUSE#
]]></bm:query-sql>
</bm:operation>
</bm:operations>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: trd
$Date: 2024-3-26 下午03:42:50
$Revision: 1.0
$Purpose: 对账单查询
-->
<bm:model xmlns:s="leaf.plugin.script" xmlns:f="leaf.database.features"
xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select * from(
select hb.batch_number,
hc.batch_id,
hc.policy_hd_id,
hc.bp_id,
(select cc.contract_number
from con_contract cc
where cc.contract_id = hc.contract_id) contract_number,
(select cc.contract_name
from con_contract cc
where cc.contract_id = hc.contract_id) contract_name,
hc.bp_id bp_id_agent_level1,
(select hbm.bp_name from hls_bp_master hbm where hbm.bp_id = hc.bp_id) bp_id_agent_level1_n,
(select h.description
from con_contract cc,hls_division h
where cc.division= h.division and cc.contract_id = hc.contract_id) division_n,
hc.finance_amount,
(select to_char(cc.lease_start_date,'yyyy/mm/dd')
from con_contract cc
where cc.contract_id = hc.contract_id) lease_start_date,
(select cc.business_type
from con_contract cc
where cc.contract_id = hc.contract_id) con_business_type,
(select cc.business_type
from con_contract cc,hls_division hd
where cc.division= hd.division and cc.contract_id = hc.contract_id) con_business_type_n,
hc.rental_re_times,
hc.overdue_max_days,
hc.comsn_rate*100||'%' comsn_rate,
hc.comsn_amount,
(select sum(i.unearned_finance_income)
from con_unearned_finance_income i
where i.contract_id = hc.contract_id) net_interest_amount,
(select ccc.net_due_amount from con_contract_cashflow ccc where ccc.cashflow_id= hc.cashflow_id) net_comm_amount,
hc.cashflow_id,
hc.contract_id,
(select hd.policy_name from hlcm_comsn_policy_hd hd where hd.policy_hd_id=hc.policy_hd_id) policy_name
from hlcm_comsn_reconcilia_batch hb, hlcm_comsn_reconcilia hc
where hb.batch_id = hc.batch_id
and hb.wfl_status='APPROVED'
AND NOT EXISTS (
SELECT 1
FROM csh_payment_req_ln l,csh_payment_req_hd hd
WHERE l.ref_doc_line_id=hc.cashflow_id
AND l.ref_doc_category='CONTRACT'
and l.payment_req_id=hd.payment_req_id
and hd.approval_status in ('NEW','REJECT','APPROVED','APPROVING','RETURN')
)
AND ('Y' = 'Y' AND EXISTS
(SELECT 1
FROM aut_trx_user_authorize a1, aut_owner_user_authorize a2
WHERE a1.trx_category = 'CONTRACT'
AND a1.trx_id = hc.contract_id
AND trunc(SYSDATE) BETWEEN a1.start_date AND
nvl(a1.end_date, trunc(SYSDATE))
AND a1.user_id = a2.owner_user_id
AND a1.trx_category = a2.trx_category
AND a2.authorized_user_id = ${/session/@user_id}
AND trunc(SYSDATE) BETWEEN a2.start_date AND
nvl(a2.end_date, trunc(SYSDATE))))
AND NOT EXISTS (
SELECT 1
FROM csh_payment_req_ln l,csh_payment_req_hd hd
WHERE l.ref_doc_line_id=hc.cashflow_id
AND l.ref_doc_category='CONTRACT'
and l.payment_req_id=hd.payment_req_id
and hd.approval_status in ('NEW','REJECT','APPROVED','APPROVING','RETURN')
)
AND ('Y' = 'Y' AND EXISTS
(SELECT 1
FROM aut_trx_user_authorize a1, aut_owner_user_authorize a2
WHERE a1.trx_category = 'CONTRACT'
AND a1.trx_id = hc.contract_id
AND trunc(SYSDATE) BETWEEN a1.start_date AND
nvl(a1.end_date, trunc(SYSDATE))
AND a1.user_id = a2.owner_user_id
AND a1.trx_category = a2.trx_category
AND a2.authorized_user_id = ${/session/@user_id}
AND trunc(SYSDATE) BETWEEN a2.start_date AND
nvl(a2.end_date, trunc(SYSDATE))))
order by hc.overdue_max_days desc
) t1
#WHERE_CLAUSE#
#ORDER_BY_CLAUSE#
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:query-fields>
<bm:query-field name="batch_number"
queryExpression="t1.batch_number like &apos;%&apos;||${@batch_number}||&apos;%&apos;"/>
<bm:query-field name="contract_number"
queryExpression="t1.batch_number like &apos;%&apos;||${@contract_number}||&apos;%&apos;"/>
<bm:query-field name="bp_id_agent_level1_n" queryExpression="t1.bp_id_agent_level1_n like &apos;%&apos;||${@bp_id_agent_level1_n}||&apos;%&apos;"/>
<bm:query-field name="division_n" queryExpression="t1.division_n like &apos;%&apos;||${@division_n}||&apos;%&apos;"/>
<bm:query-field name="policy_name" queryExpression="t1.policy_name=${@policy_name}"/>
</bm:query-fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: 18083
$Date:
$Revision: 1.0
$Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select
t.bank_account_id bp_bank_account_id,
t.bank_account_code bp_bank_account_code,
t.bank_account_num bp_bank_account_num,
t.bank_account_name bp_bank_account_name,
t.bank_full_name bp_bank_full_name
from hls_bp_master_bank_account_v t
where t.bp_id = ${/parameter/@bp_id_agent_level1}
and t.enabled_flag = 'Y'
and rownum = 1
]]></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" needAccessControl="false">
<bm:operations>
<bm:operation name="query">
<bm:query-sql><![CDATA[
select h.policy_hd_id,
h.policy_name,
h.policy_ext_name,
h.division,
(select d.description
from hls_division d
where d.division = h.division) division_n
from hlcm_comsn_policy_hd h
where h.wfl_status = 'APPROVED'
and h.bp_id = ${@bp_id}
and exists
(select 1
from con_contract t
where t.data_class = 'NORMAL'
and t.bp_id_agent_level1 = h.bp_id
and t.division = h.division
and t.contract_status in ('INCEPT',
'REPURING',
'REPUR',
'TERMINATING',
'TERMINATE',
'ETING',
'ET',
'PENDING')
and trunc(t.lease_start_date) >= trunc(h.calc_start_date)
and trunc(t.lease_start_date) <= trunc(h.calc_end_date)
and (select count(1)
from con_contract_cashflow cc
where cc.contract_id = t.contract_id
and cc.cf_item = 1
and cc.cf_direction = 'INFLOW'
and cc.cf_status = 'RELEASE'
and cc.write_off_flag = 'FULL') >= h.rent_recovery_time
and exists (select 1
from con_contract_cashflow cc1
where cc1.contract_id = t.contract_id
and cc1.cf_item = 0
and cc1.write_off_flag = 'FULL')
and not exists
(select 1
from hlcm_comsn_reconcilia r
where r.contract_id = t.contract_id
and r.wfl_status in ('NEW', 'APPROVING', 'APPROVED')))
]]></bm:query-sql>
</bm:operation>
</bm:operations>
<bm:fields>
<bm:field name="policy_hd_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="POLICY_HD_ID" prompt="佣金政策id"/>
<bm:field name="policy_name" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="220" forDisplay="true" forQuery="true" physicalName="POLICY_NAME" prompt="佣金政策"/>
<bm:field name="policy_ext_name" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="120" forDisplay="true" forQuery="true" physicalName="POLICY_NAME" prompt="佣金政策简称"/>
<bm:field name="division" databaseType="NUMBER" datatype="java.lang.Long" physicalName="DIVISION" prompt="产品线"/>
<bm:field name="division_n" databaseType="VARCHAR2" datatype="java.lang.String" displayWidth="160" forDisplay="true" forQuery="true" physicalName="DIVISION_N" prompt="产品线"/>
</bm:fields>
<bm:query-fields>
<bm:query-field field="policy_name" queryExpression="t1.policy_name like &apos;%&apos;||${@policy_name}||&apos;%&apos;"/>
<bm:query-field field="policy_ext_name" queryExpression="t1.policy_ext_name like &apos;%&apos;||${@policy_ext_name}||&apos;%&apos;"/>
<bm:query-field field="division_n" queryExpression="t1.division_n like &apos;%&apos;||${@division_n}||&apos;%&apos;"/>
</bm:query-fields>
</bm:model>
<?xml version="1.0" encoding="UTF-8"?>
<!--
$Author: trd
$Date: 2024-1-19 上午11:15:04
$Revision: 1.0
$Purpose:
-->
<bm:model xmlns:bm="http://www.leaf-framework.org/schema/bm">
<bm:operations>
<bm:operation name="execute">
<bm:update-sql><![CDATA[
begin
csh_payment_comm_req_pkg.payment_comm_submit
(
p_payment_req_id=>${@payment_req_id},
p_user_id=>${/session/@user_id}
);
end;]]></bm:update-sql>
</bm:operation>
</bm:operations>
</bm:model>
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
and l.ref_doc_category = 'CONTRACT' and l.ref_doc_category = 'CONTRACT'
and l.ref_doc_id = cc.contract_id and l.ref_doc_id = cc.contract_id
and l.ref_doc_line_id = cf.cashflow_id and l.ref_doc_line_id = cf.cashflow_id
and cf.cf_item in ('40'))) v #WHERE_CLAUSE# and cf.cf_item in ('40','911'))) v #WHERE_CLAUSE#
ORDER BY transaction_date DESC, transaction_num ORDER BY transaction_date DESC, transaction_num
]]></bm:query-sql> ]]></bm:query-sql>
......
var override_queryfields = [
{
name : 'req_date_from',
queryexpression : "T1.req_date>=trunc(to_date(${@req_date_from},'yyyy-mm-dd'))"
},
{
name : 'req_date_to',
queryexpression : "trunc(T1.req_date)<=to_date(${@req_date_to},'yyyy-mm-dd')"
},
{
name:'payment_req_number',
queryexpression:"t1.payment_req_number like '%'||${@payment_req_number}||'%'"
}
];
var add_datafilters = [
{
name : '',
expression : "exists(select 1\n" +
" from csh_payment_req_ln l,con_contract cc,con_contract_cashflow cf\n" +
" where l.payment_req_id = t1.payment_req_id\n" +
" and l.ref_doc_category = 'CONTRACT'\n" +
" and l.ref_doc_id = cc.contract_id\n" +
" and l.ref_doc_line_id = cf.cashflow_id\n" +
" and cf.cf_item in ('911'))"
} ];
add_datafilter();
override();
...@@ -352,5 +352,8 @@ var enableLayoutConfig = { ...@@ -352,5 +352,8 @@ var enableLayoutConfig = {
'modules/cont/CON1370/con_asset_fee_detail.lview':true, 'modules/cont/CON1370/con_asset_fee_detail.lview':true,
'modules/hls/HLS303/bp_agent_bounty_create.lview':true, 'modules/hls/HLS303/bp_agent_bounty_create.lview':true,
'modules/hls/HLS303/bp_agent_bounty_detail.lview':true, 'modules/hls/HLS303/bp_agent_bounty_detail.lview':true,
'modules/acp/ACP522/ap_invoice_com_detail.lview':true 'modules/acp/ACP522/ap_invoice_com_detail.lview':true,
'modules/csh/CSH501R/csh_payment_comm_create_entrance.lview':true,
'modules/csh/CSH501R/csh_payment_comm_selected.lview':true,
'modules/csh/CSH501R/csh_payment_comm_req.lview':true
}; };
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<a:screen xmlns:a="http://www.leaf-framework.org/application" customizationEnabled="true" dynamiccreateenabled="true"
trace="true">
<a:init-procedure>
</a:init-procedure>
<a:view>
<a:link id="get_layout_code_link_id" model="cont.CON500.con_contract_get_layout_code" modelaction="update"/>
<a:link id="csh_payment_comm_create_link" url="${/request/@context_path}/modules/csh/CSH501R/csh_payment_comm_selected.lview"/>
<a:link id="csh501_csh_comm_req_link_id"
url="${/request/@context_path}/modules/csh/CSH501R/csh_payment_comm_req.lview"/>
<script type="text/javascript"><![CDATA[
//新增
window['${/parameter/@layout_code}_user_button1_layout_dynamic_click'] = function () {
var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
var url = $('csh_payment_comm_create_link').getUrl();
var win = new Leaf.Window({
url: url,
params: {
winid: 'csh_payment_req_comm_win_id',
ds_id: ds_id
},
title: '佣金付款申请页面',
id: 'csh_payment_req_comm_win_id',
fullScreen: true
});
win.on('close', function () {
$(ds_id).query();
});
};
function detail_link(id, name, query_only) {
var record = window['${/parameter/@layout_code}_hls_link_render_record'][id + '---' + name];
var ds_id = get_dsid_by_basetable(window['${/parameter/@layout_code}_layoutDataSetList'], 'csh_payment_req_hd');
var param = {};
param['payment_req_id'] = record.get('payment_req_id');
param['bp_id'] = record.get('bp_id_agent_level1');
param['business_type'] = record.get('business_type');
param['approval_status'] = record.get('approval_status');
if (record.get('approval_status') == 'NEW' || record.get('approval_status') == 'RETURN' || record.get('approval_status') == 'REJECT') {
param['function_usage'] = 'UPDATE';
param['function_code'] = 'CSH501D_COMM';
} else{
param['function_usage'] = 'QUERY';
param['function_code'] = 'SAVE_COMM';
param['download'] = 'Y';
}
param['winid'] = 'csh_payment_comm_update_window';
param['url_title'] = '佣金付款申请';
hls_doc_get_layout_code('get_layout_code_link_id', param, 'csh501_csh_comm_req_link_id', ds_id, '${/parameter/@layout_code}');
}
window['${/parameter/@layout_code}_dynamic_link_renderer'] = function (value, record, name, config_record) {
window['${/parameter/@layout_code}_hls_link_render_record'][record.id + '---' + name] = record;
if (name == 'payment_req_number' && value) {
link_function = 'detail_link';
return '<a href="javascript:window[\'' + link_function + '\'](\'' + record.id + '\',\'' + name + '\',\'' + config_record.get('query_only') + '\');">' + value + '</a>';
}
return value;
};
window['${/parameter/@layout_code}_on_layout_dynamic_grid_query'] = function (ds, qpara, bp_seq) {
aut_authority_list_validate_query(ds, qpara);
};
]]></script>
<a:screen-include screen="modules/cont/CON500/con_contract_get_layout_code.lview"/>
<a:screen-include
screen="modules/cont/CON500/con_contract_authority_list_validate.lview?document_category=PAYMENT_REQ&amp;function_code=CSH501R"/>
</a:view>
</a:screen>
<?xml version="1.0" encoding="UTF-8"?>
<a:service xmlns:a="http://www.leaf-framework.org/application" xmlns:s="leaf.plugin.script" trace="true">
<a:init-procedure>
<a:model-update model="hls.HLS811.hls_doc_file_templet_get_atm"/>
<s:server-script import="contract_print_path.js"><![CDATA[
importPackage(java.io);
importPackage(Packages.hls.plugin.docx4j);
importPackage(Packages.leaf.plugin.word2pdf);
importPackage(Packages.org.apache.commons.io);
//删除文件
function deleteFile(filePath) {
var file = new File(filePath);
if (file.exists()) {
file.delete();
}
}
//生成pdf
function wordToPdf(word_file_path,pdf_file_path) {
// word转pdf
var pdf_file_path_new = pdf_file_path + '.pdf';
var wordToPdf = new WordToPdf($instance('uncertain.ocm.IObjectRegistry'), "jacob-1.19-x64.dll");
wordToPdf.word2pdf(word_file_path, pdf_file_path_new);
//删除word文件
//deleteFile(word_file_path);
return pdf_file_path_new;
}
function copyFile(fOld, fNew) {
var fis = new java.io.FileInputStream(fOld);
var fos = new java.io.FileOutputStream(fNew);
var b = new java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024 * 4);
var len = -1;
while ((len = fis.read(b)) != -1) {
fos.write(b, 0, len);
}
fis.close();
fos.close();
}
function transfer(file_path, os) {
println(file_path);
var fis = new FileInputStream(file_path);
var b = new java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024 * 64);
var len = -1;
while ((len = fis.read(b)) != -1) {
os.write(b, 0, len);
}
fis.close();
}
function write_os_to_file(file, os) {
var fis = new FileInputStream(file);
var b = new java.lang.reflect.Array.newInstance(java.lang.Byte.TYPE, 1024 * 64);
var len = -1;
while ((len = fis.read(b)) != -1) {
os.write(b, 0, len);
}
fis.close();
}
function download_file(file_name, file_path) {
$ctx["__request_type__"] = 'file'; //to indicate this request is not a JSON_REQUEST
var resp = $ctx['_instance.javax.servlet.http.HttpServletResponse'];
resp.setHeader("Pragma", "No-cache");
resp.setHeader("Cache-Control", "no-cache, must-revalidate");
resp.setDateHeader("Expires", 0);
resp.setContentType("application/x-msdownload");
resp.setHeader("Content-disposition", "attachment; filename=" + encodeURI(file_name, 'UTF-8'));
var os = resp.getOutputStream();
//transfer(file_path, os);
write_os_to_file(file_path, os);
os.flush();
}
//按日期创建目录
function getDatePath() {
set_parameter_file_path();
var file_path = $ctx.parameter.pdf_path; //file_path = c:/hls_test_files/content_files/
var now = new Date()
y = now.getFullYear()
m = now.getMonth() + 1
m = m < 10 ? "0" + m : m
var datePath = file_path + y + "/" + m + "/";
return datePath; //datePath = d:/hls_test_files/fileupload/2018/04/
}
function collection_create_content() {
try {
var datePath = getDatePath();
FileUtils.forceMkdir(new File(datePath)); //根据日期创建目录
var attachment_batch_dl = $bm('hls.HLS811.hls_doc_file_templet_get_atm');
var result = attachment_batch_dl.queryAsMap({
document_id: $ctx.parameter.document_id,
document_table: $ctx.parameter.document_table,
batch_flag: $ctx.parameter.batch_flag,
content_id: $ctx.parameter.content_id
});
var from_file_data = result.getChildren();
for (var i = 0;i < from_file_data.length;i++) {
if (!$ctx.parameter.file_path) {
set_parameter_file_path();
}
var to_file_path = $ctx.parameter.file_path;
var record_data = from_file_data[i];
//if (record_data.file_exists_flag != 'Y') {
var to_file_name = record_data.to_file_name;
var from_file_path = record_data.file_path;
var guid_file_name_path = $bm('cont.CON500.con_contract_get_guid_file_name').queryAsMap();
var guid_file_name_tables = guid_file_name_path.getChildren();
to_file_path = datePath + guid_file_name_tables[0].guid_file_name + 'doc' + record_data.content_id;
copyFile(from_file_path, to_file_path);
try {
$bm('csh.CSH501.csh_transaction_return_print').update({
document_id: $ctx.parameter.document_id,
document_table: $ctx.parameter.document_table
});
var brwt = new BookmarksReplaceWithText($instance('leaf.database.service.IDatabaseServiceFactory'), $instance('uncertain.ocm.IObjectRegistry'), $ctx.getData());
brwt.replaceBookmarkFromContent(to_file_path.toString(), record_data.content_id.toString(), 'COMMON');
} catch (e) {
raise_app_error(e);
}
// word转pdf
var pdf_file_path=to_file_path;
var outputfilepath = wordToPdf(to_file_path,pdf_file_path);
//var outputfilename= record_data.to_file_name +'.pdf';
var filename_str = record_data.to_file_name;
var outputfilename= filename_str.substr(0, filename_str.length - 5) +'.pdf';
var pdf_file = new File(outputfilepath);
var file_size = 0;
if (pdf_file.exists()) {
file_size = pdf_file.length();
}
$bm('hls.HLS811.hls_file_content_copy_update').update({
table_name: 'HLS_DOC_FILE_CONTENT',
content_id: record_data.content_id,
file_name: outputfilename.toString(),
file_path: outputfilepath.toString(),
source_type: $ctx.parameter.source_type
});
//var resp = $ctx['_instance.javax.servlet.http.HttpServletResponse'];
//HlsFileUtil.downloadFile(encodeURI(to_file_path,'utf-8'),encodeURI(to_file_name,'utf-8'),resp);
//print(outputfilepath.toString());
//print(outputfilename.toString());
download_file(outputfilename.toString(),outputfilepath.toString());
}
$ctx.parameter.return_status = 'S';
$ctx.parameter.return_message = '执行成功';
} catch (e) {
$ctx.success = "true";
$ctx.parameter.return_status = 'E';
$ctx.parameter.return_message = $ctx.get('/error/@message') || String(e);
raise_app_error(e);
}
var result = {
result: $ctx.parameter.return_status,
message: $ctx.parameter.return_message
};
$ctx.parameter.json = JSON.stringify(result);
}
if ($ctx.parameter.return_status != 'E' && $ctx.parameter.return_status != 'TIMEOUT') {
collection_create_content();
}
]]></s:server-script>
</a:init-procedure>
<a:service-output/>
</a:service>
This diff is collapsed.
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