网银收款核销-租金-生成核销修改

This commit is contained in:
chaojie.li 2025-04-17 14:36:07 +08:00
parent b9492a0147
commit 1862daebde
6 changed files with 493 additions and 67 deletions

View File

@ -0,0 +1,38 @@
<%@ page contentType="text/html; charset=GBK" %>
<%@ include file="/Frame/resources/include/include_begin.jspf" %>
<body>
<br/>
<br/>
<div style="text-align:center;">
<input type="checkbox" name="hireType" value="CORPUS" id="hireTypeCorpus" checked><label for="hireTypeCorpus">本金</label>
&nbsp;
<input type="checkbox" name="hireType" value="INTEREST" id="hireTypeInterest" checked><label for="hireTypeInterest">利息</label>
&nbsp;
<input type="checkbox" name="hireType" value="PENALTY" id="hireTypePenalty" checked><label for="hireTypePenalty">罚息</label>
</div>
<br/>
<br/>
<br/>
<br/>
<div style="text-align:center;">
<button type="button" onclick="confirm()">确定</button>
<button type="button" onclick="cancel()">取消</button>
</div>
</body>
<script type="text/javascript">
function confirm() {
let hireTypes = [];
$("input[name='hireType']:checked").each(function () {
hireTypes.push($(this).val());
});
if (hireTypes.length == 0) {
alert("请选择要核销的类型!");
}
parent.AsDialog.ClosePage(hireTypes.join(","));
}
function cancel() {
parent.AsDialog.ClosePage();
}
</script>
<%@ include file="/Frame/resources/include/include_end.jspf" %>

View File

@ -53,12 +53,14 @@
dwTemp.MultiSelect = true;
}
dwTemp.setPageSize(10);
//dwTemp.setParameter("contract_number", "BQAP(AH)201811220001");
dwTemp.genHTMLObjectWindow(businessType+","+subjectId+","+factDate);
//0、是否展示 1、 权限控制 2、 展示类型 3、按钮显示名称 4、按钮解释文字 5、按钮触发事件代码 6、 7、 8、 9、图标CSS层叠样式 10、风格
String sButtons[][] = {
{"ReadOnly".equals(rightType)?"false":"true","","Button","生成本次租金收款","生成本次租金收款","createRundIncome()","","","","btn_icon_add",""}
{"ReadOnly".equals(rightType)?"false":"true","","Button","生成本次租金收款","生成本次租金收款","showSelectHireTypeDialog()","","","","btn_icon_add",""}
};
// createRundIncome()
%><%@include file="/Frame/resources/include/ui/include_list.jspf"%>
<script type="text/javascript">
var portionCollectionID = "";
@ -69,10 +71,10 @@
var phaseInput = $("<input type='checkbox' style='vertical-align:middle;display:none;' id='period'/><label for='period' id='periodLabel' style='vertical-align:middle;display:none;'><a>允许隔期回笼</a></label>");
$("#ListButtonArea").append(phaseInput);
$("#period").attr("onclick","setCheckBox()");
TableFactory.afterSearch = function(){
setCheckBoxEvent();//搜索页面和排序后执行
}
setCheckBoxEvent();
// TableFactory.afterSearch = function(){
// setCheckBoxEvent();//搜索页面和排序后执行
// }
// setCheckBoxEvent();
// $("#DW_CheckAll_myiframe0").remove();
})
@ -105,111 +107,160 @@
}
}
function checkInputData(i){
function checkInputData(i) {
// if(getCheckedRows(0).length == 0) {
// return;
// }
TableBuilder.iCurrentRow['myiframe0'] = i;
TableBuilder.displaySelectedRows('myiframe0');
if($("#period").attr("checked") != "checked"){
if ($("#period").attr("checked") != "checked") {
var checkedRows = getCheckedRows(0);
var paymentNumber = getItemValue(0,i,"payment_number");
var thisPlanList = getItemValue(0,i,"plan_list");
if(s_c_p[0] != 0 && i == 0){
var prevUncheckedRows = TablePage.getUncheckedRowsByPageIndex(s_c_p[0]-1);
if(TablePage.pageUncheckedData[s_c_p[0]-1]){
for(var p=0;p<prevUncheckedRows.length;p++){
var prevPaymentNumber = TablePage.getUncheckedItemValueByPageIndex(prevUncheckedRows[p],"PAYMENT_NUMBER",s_c_p[0]-1);
var prevPlanList = TablePage.getUncheckedItemValueByPageIndex(prevUncheckedRows[p],"PLAN_LIST",s_c_p[0]-1);
if(prevPaymentNumber == paymentNumber && prevPlanList == thisPlanList-1){
var paymentNumber = getItemValue(0, i, "payment_number");
var thisPlanList = getItemValue(0, i, "plan_list");
if (s_c_p[0] != 0 && i == 0) {
var prevUncheckedRows = TablePage.getUncheckedRowsByPageIndex(s_c_p[0] - 1);
if (TablePage.pageUncheckedData[s_c_p[0] - 1]) {
for (var p = 0; p < prevUncheckedRows.length; p++) {
var prevPaymentNumber = TablePage.getUncheckedItemValueByPageIndex(prevUncheckedRows[p], "PAYMENT_NUMBER", s_c_p[0] - 1);
var prevPlanList = TablePage.getUncheckedItemValueByPageIndex(prevUncheckedRows[p], "PLAN_LIST", s_c_p[0] - 1);
if (prevPaymentNumber == paymentNumber && prevPlanList == thisPlanList - 1) {
alert("操作失败,不允许隔期回笼,请重新选择!");
$("input[onclick='checkInputData("+i+")']").removeAttr("checked");
$("input[onclick='checkInputData(" + i + ")']").removeAttr("checked");
return false;
}
}
}else{
var sResult = AsControl.RunJsp("/Tenwa/Lease/Flow/Rent/RentIncome/GetPrevRentPlan.jsp","paymentNumber="+paymentNumber+"&planList="+(thisPlanList-1));
if(thisPlanList == 1){
} else {
var sResult = AsControl.RunJsp("/Tenwa/Lease/Flow/Rent/RentIncome/GetPrevRentPlan.jsp", "paymentNumber=" + paymentNumber + "&planList=" + (thisPlanList - 1));
if (thisPlanList == 1) {
sResult = "SUCCESS";
}
if(sResult != "SUCCESS"){
if (sResult != "SUCCESS") {
alert("操作失败,不允许隔期回笼,请重新选择!");
$("input[onclick='checkInputData("+i+")']").removeAttr("checked");
$("input[onclick='checkInputData(" + i + ")']").removeAttr("checked");
return false;
}
}
}
var flag = true;
var cancelFlag = true;
for(var j=0;j<DZ[0][2].length;j++){
if(paymentNumber == getItemValue(0,j,"payment_number")){
var planList = getItemValue(0,j,"plan_list");
if(parseInt(planList) < parseInt(thisPlanList)){
for (var j = 0; j < DZ[0][2].length; j++) {
if (paymentNumber == getItemValue(0, j, "payment_number")) {
var planList = getItemValue(0, j, "plan_list");
if (parseInt(planList) < parseInt(thisPlanList)) {
flag = false;
for(var k=0;k<checkedRows.length;k++){
if(checkedRows[k] == j){
for (var k = 0; k < checkedRows.length; k++) {
if (checkedRows[k] == j) {
flag = true;
break;
}
}
}
if(parseInt(planList) > parseInt(thisPlanList)){
if (parseInt(planList) > parseInt(thisPlanList)) {
cancelFlag = true;
for(var k=0;k<checkedRows.length;k++){
if(checkedRows[k] == j){
for (var k = 0; k < checkedRows.length; k++) {
if (checkedRows[k] == j) {
cancelFlag = false;
break;
}
}
}
if(!cancelFlag){
if (!cancelFlag) {
break;
}
}
}
var rentOverResult = AsControl.RunJsp("/Tenwa/Lease/Flow/Rent/RentIncome/GetBeforeRentOver.jsp","paymentNumber="+paymentNumber+"&planList="+thisPlanList);
if(!flag && rentOverResult=="false"){
var rentOverResult = AsControl.RunJsp("/Tenwa/Lease/Flow/Rent/RentIncome/GetBeforeRentOver.jsp", "paymentNumber=" + paymentNumber + "&planList=" + thisPlanList);
if (!flag && rentOverResult == "false") {
alert("操作失败,不允许隔期回笼,请重新选择!");
$("input[onclick='checkInputData("+i+")']").removeAttr("checked");
$("input[onclick='checkInputData(" + i + ")']").removeAttr("checked");
return false;
}
if(!cancelFlag && rentOverResult=="false"){
if (!cancelFlag && rentOverResult == "false") {
alert("操作失败,不允许隔期回笼,请重新选择!");
$("input[onclick='checkInputData("+i+")']").prop("checked","true");
$("input[onclick='checkInputData(" + i + ")']").prop("checked", "true");
return false;
}
}
if($.inArray(i, getCheckedRows(0)) == -1){
if ($.inArray(i, getCheckedRows(0)) == -1) {
return false;
}
var thisRowMoney = removeFomatedNumber(getItemValue(0,i,"rent_over"));//最后一次选中的收款余额
thisRowMoney = eval(thisRowMoney + "+" + removeFomatedNumber(getItemValue(0,i,"penalty_over")));//最后一次选中的收款余额
var overmoneys = getItemValueArray(0,"rent_over");
var otherOverMoneys = TablePage.getCheckedItemValueArrayWithOtherPage("rent_over",s_c_p[0]);//获取所有除当前页面外的其他页面
var overPenaltyMoneys = getItemValueArray(0,"penalty_over");
var otherOverPenaltyMoneys = TablePage.getCheckedItemValueArrayWithOtherPage("penalty_over",s_c_p[0]);//获取改成所有除当前页面外的其他页面
var thisRowMoney = removeFomatedNumber(getItemValue(0, i, "rent_over"));//最后一次选中的收款余额
thisRowMoney = eval(thisRowMoney + "+" + removeFomatedNumber(getItemValue(0, i, "penalty_over")));//最后一次选中的收款余额
var overmoneys = getItemValueArray(0, "rent_over");
var otherOverMoneys = TablePage.getCheckedItemValueArrayWithOtherPage("rent_over", s_c_p[0]);//获取所有除当前页面外的其他页面
var overPenaltyMoneys = getItemValueArray(0, "penalty_over");
var otherOverPenaltyMoneys = TablePage.getCheckedItemValueArrayWithOtherPage("penalty_over", s_c_p[0]);//获取改成所有除当前页面外的其他页面
var prepareIncomeMoney = 0;
for(var j=0;j<overmoneys.length;j++){
prepareIncomeMoney = eval(prepareIncomeMoney +"+"+ removeFomatedNumber(overmoneys[j]));
prepareIncomeMoney = eval(prepareIncomeMoney +"+"+ removeFomatedNumber(overPenaltyMoneys[j]));
for (var j = 0; j < overmoneys.length; j++) {
prepareIncomeMoney = eval(prepareIncomeMoney + "+" + removeFomatedNumber(overmoneys[j]));
prepareIncomeMoney = eval(prepareIncomeMoney + "+" + removeFomatedNumber(overPenaltyMoneys[j]));
}
for(var j=0;j<otherOverMoneys.length;j++){
prepareIncomeMoney = eval(prepareIncomeMoney +"+"+ otherOverMoneys[j]);
prepareIncomeMoney = eval(prepareIncomeMoney +"+"+ otherOverPenaltyMoneys[j]);
for (var j = 0; j < otherOverMoneys.length; j++) {
prepareIncomeMoney = eval(prepareIncomeMoney + "+" + otherOverMoneys[j]);
prepareIncomeMoney = eval(prepareIncomeMoney + "+" + otherOverPenaltyMoneys[j]);
}
prepareIncomeMoney = prepareIncomeMoney.toFixed(2);
thisRowMoney = thisRowMoney.toFixed(2);
if(prepareIncomeMoney-thisRowMoney>=mayopeMoney){
if (prepareIncomeMoney - thisRowMoney >= mayopeMoney) {
alert("操作失败网银可核销金额已为0。");
$("input[onclick='checkInputData("+i+")']").removeAttr("checked");
$("input[onclick='checkInputData(" + i + ")']").removeAttr("checked");
return false;
}else if(mayopeMoney-(prepareIncomeMoney-thisRowMoney)>0 && mayopeMoney-(prepareIncomeMoney-thisRowMoney)<thisRowMoney){
portionCollectionID = getItemValue(0,i,"ID");
portionMoney = mayopeMoney-(prepareIncomeMoney-thisRowMoney);
} else if (mayopeMoney - (prepareIncomeMoney - thisRowMoney) > 0 && mayopeMoney - (prepareIncomeMoney - thisRowMoney) < thisRowMoney) {
portionCollectionID = getItemValue(0, i, "ID");
portionMoney = mayopeMoney - (prepareIncomeMoney - thisRowMoney);
alert("网银余额只能核销部分此笔租金!");
}
}
function showSelectHireTypeDialog() {
var id = getItemValueArray(0, "id") + "," + TablePage.getCheckedItemValueArrayWithOtherPage("id", s_c_p[0]);
if ("," == id) {
alert("请先选择需要收款的租金计划");
return;
}
let contractId = getItemValue(0, 0, "contract_id");
AsDialog.PopView("/Tenwa/Lease/Flow/Rent/RentIncome/SelectHireTypeDialog.jsp", '',
"resizable=yes;dialogWidth=350px;dialogHeight=150px;center:yes;status:no;statusbar:no",
function (returnValue) {
var result = AsControl.RunJavaMethod("com.tenwa.reckon.executor.RentCalHelper", "isAutoBuckleByPlanId", "planId=" + id);
if (result == "false") {
alert("选中的租金有正在卡扣中!请稍后再试!");
return;
}
let params = {
currUserId: "<%=CurUser.getUserID()%>",
currOrgId: "<%=CurUser.getOrgID()%>",
contractId: contractId,
planIDs: id,
flowunid: "<%=flowunid%>",
hireTypes: returnValue
};
console.info(params, "params")
try {
var sResult = AsControl.RunJavaMethodTransCustom("com.tenwa.flow.rent.rentincome.RentIncomeMethod", "generateRentIncomeData",
JSON.stringify({params: JSON.stringify(params)}));
console.info(sResult, 'sResult');
debugger;
if ("SUCCESS" == sResult) {
alert("操作成功,请到本次收款明细中查看!");
reloadSelf();
// setCheckBoxEvent();
TablePage.pageCheckedData = {};
TablePage.pageUncheckedData = {};
} else if ("ERROR" == sResult) {
alert("生成失败");
} else {
alert(sResult);
}
} catch (e) {
alert(e.message);
}
}, "选择核销类型");
}
function createRundIncome(){
var id = getItemValueArray(0,"id")+","+TablePage.getCheckedItemValueArrayWithOtherPage("id",s_c_p[0]);
if("," == id){

View File

@ -2,7 +2,12 @@
<fenixs namespace="flow.FundCollectionFlow">
<fenix id="queryRentPlanList">
select lrpi.id,
lrpi.quot_id,
lrpi.cust_id,
lrpi.project_id,
lrpi.project_plan_number,
lrpi.contract_id,
lrpi.contract_plan_number,
lrpi.contract_number,
lrpi.payment_number,
lrpi.customer_name as customername,
@ -25,7 +30,12 @@
else '部分回笼' end as planstatus,
round(lrpi.penalty_sum + lrpi.penalty_sum_temp, 2) as penalty_sum
from (select lrp.id,
lrp.quot_id,
lrp.cust_id,
lrp.project_id,
lrp.project_plan_number,
lrp.contract_id,
lrp.contract_plan_number,
lci.contract_number,
lrp.payment_number,
lul.customer_name,
@ -86,14 +96,20 @@
and lri.payment_number = lrp.payment_number
and lri.plan_list = lrp.plan_list
), 0), 2) as penalty_sum_temp,
@if{?factDate != empty}
getrentpenalty(lrp.payment_number, lrp.plan_list, ${factDate}) as penalty
@else{}
getrentpenalty(lrp.payment_number, lrp.plan_list, date_format(now(), '%Y/%m/%d')) as penalty
@end{}
from lc_rent_plan lrp
left join lb_contract_info lci on lrp.contract_id = lci.id
left join lb_union_lessee lul on lrp.contract_id = lul.contract_id and lul.is_main = 'Y'
left join customer_account ca on ca.contract_id = lci.id
where lrp.plan_status &lt;&gt; '已回笼'
<andEqual field="lrp.id" value="planId" match="?planId != empty" />
<andIn field="lrp.id" value="planIds" match="?planIds != empty" />
<andEqual field="lul.customer_name" value="customername" match="?customername != empty" />
<andEqual field="lci.id" value="contractId" match="?contractId != empty" />
<andEqual field="lci.contract_number" value="contract_number" match="?contract_number != empty" />
<andGreaterThanEqual field="lrp.plan_date" value="plan_dateStart" match="?plan_dateStart != empty" />
<andLessThanEqual field="lrp.plan_date" value="plan_dateEnd" match="?plan_dateEnd != empty" />

View File

@ -8,6 +8,7 @@ import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.BizObjectManager;
import com.amarsoft.are.jbo.JBOException;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.lang.DataElement;
import com.amarsoft.awe.dw.handler.BusinessProcessData;
import com.amarsoft.awe.dw.ui.htmlfactory.ListHtmlWithASDataObjectGenerator;
import com.amarsoft.awe.dw.ui.htmlfactory.QueryParamObject;
@ -37,13 +38,20 @@ public class FenixListHtmlGenerator extends ListHtmlWithASDataObjectGenerator {
System.out.println("SQL参数:" + this.paramstr);
System.out.println("分页参数:pageSize=" + this.pageSize + "curPage=" + this.curPage + "pageCount=" + this.pageCount + "rowCount="
+ this.rowCount + "");
Map<String, Object> paramMap = new HashMap<>();
// 初始化查询参数
List<DataElement> initParameters = this.asObj.getInitParameters();
for (DataElement dataElement : initParameters) {
paramMap.put(dataElement.getName(), dataElement.getString());
}
//获得查询条件
List<QueryParamObject> queryParams = this.getQeuryParmObjects();
if (this.asObj.getLazyLoad() && queryParams.size() == 0) {
if (this.asObj.getLazyLoad() && paramMap.size() == 0 && queryParams.size() == 0) {
this.searchedDataList = new ArrayList<BizObject>();
return;
}
Map<String, Object> paramMap = new HashMap<>();
if (StrUtil.isNotBlank(this.paramstr)) {
paramMap.put("paramstr", this.paramstr);
}

View File

@ -1,22 +1,29 @@
package com.tenwa.flow.rent.rentincome;
import java.math.BigDecimal;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
import cn.hutool.db.Entity;
import cn.hutool.db.handler.EntityHandler;
import cn.hutool.db.handler.EntityListHandler;
import cn.hutool.db.handler.NumberHandler;
import com.amarsoft.are.ARE;
import com.amarsoft.are.log.Log;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import com.tenwa.lease.service.LCOccupyRentListService;
import com.tenwa.util.JsonUtil;
import com.tenwa.util.SqlRunnerUtil;
import org.apache.commons.lang3.tuple.Pair;
import org.springframework.web.context.ContextLoader;
import org.springframework.web.context.WebApplicationContext;
@ -49,6 +56,8 @@ import com.tenwa.reckon.util.UUIDUtil;
public class RentIncomeMethod {
protected static Log logger = ARE.getLog();
private String planIDs;
private String flowunid;
private String overCorpuss;
@ -67,6 +76,8 @@ public class RentIncomeMethod {
private String orgid;
private String deductDocId;
private String params;
public String getDeductDocId() {
return deductDocId;
}
@ -202,6 +213,15 @@ public class RentIncomeMethod {
public void setNewFactMoney(String newFactMoney) {
this.newFactMoney = newFactMoney;
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
/**
* ×â½ðºËÏú
*/
@ -251,7 +271,8 @@ public class RentIncomeMethod {
} else {
for (int j = 0; j < paymentOrders.get("RMO-01").size(); j++) {
paymentOrder[Integer.parseInt(paymentOrders.get("RMO-01").get(j).get("rmosortno")) - 1] = paymentOrders.get("RMO-01").get(j).get("rmoname");
}
}
}
if ("penalty_income".equals(penaltyRule)) {
Penaltys[i] = "0.00";
@ -451,6 +472,246 @@ public class RentIncomeMethod {
return "SUCCESS";
}
public String generateRentIncomeData(JBOTransaction tx) throws Exception {
// 获取请求参数
ObjectMapper objectMapper = JsonUtil.getObjectMapper();
JsonNode jsonNode = objectMapper.readTree(params);
String contractId = jsonNode.get("contractId").textValue();
String planIDsParam = jsonNode.get("planIDs").textValue();
String flowunidParam = jsonNode.get("flowunid").textValue();
String hireTypesParam = jsonNode.get("hireTypes").textValue();
String currUserId = jsonNode.get("currUserId").textValue();
String currOrgId = jsonNode.get("currOrgId").textValue();
List<String> planIDList = Arrays.asList(planIDsParam.split(","));
List<String> hireTypeList = Arrays.asList(hireTypesParam.split(","));
Transaction transaction = Transaction.createTransaction(tx);
LCOccupyRentListService lcOccupyRentListService = LCOccupyRentListService.getInstance();
// 查询核销使用的网银
BizObjectManager ebankTempBOM = JBOFactory.getBizObjectManager(LC_EBANK_TEMP.CLASS_NAME, tx);
BizObject ebankTempBizObj = ebankTempBOM.createQuery("FLOWUNID=:FLOWUNID").setParameter("FLOWUNID", flowunidParam).getSingleResult(true);
String factDateStr = ebankTempBizObj.getAttribute("FACT_DATE").getString();
Date factDate = new SimpleDateFormat("yyyy/MM/dd").parse(factDateStr);
// 可核销金额
BigDecimal mayopeMoney = new BigDecimal(ebankTempBizObj.getAttribute("MAYOPE_MONEY").getString());
//
AtomicReference<BigDecimal> moneyAmtRef = new AtomicReference<>(mayopeMoney);
// 查询核销的租金计划及计划剩余金额等信息
Map<String, Object> sqlParamMap = new HashMap<>();
// sqlParamMap.put("planIds", planIDList);
sqlParamMap.put("contractId", contractId);
sqlParamMap.put("factDate", factDateStr);
List<Entity> entityList = SqlRunnerUtil.query(transaction, "flow.FundCollectionFlow.queryRentPlanList", sqlParamMap, new EntityListHandler());
entityList.sort(Comparator.comparingInt(o -> o.getInt("plan_list")));
// 查询核销顺序
BizObjectManager lbContractInfoBOM = JBOFactory.getBizObjectManager(LB_CONTRACT_INFO.CLASS_NAME, tx);
BizObject lbContractInfoBizObj = lbContractInfoBOM.createQuery("ID=:contractId").setParameter("contractId", contractId).getSingleResult(false);
Map<String, List<Map<String, String>>> paymentOrders = ProductParamUtil
.getProductComponentDecisionTable(lbContractInfoBizObj.getAttribute("PRODUCT_ID").getString(), "PRD0307", "rmoname", "rmosortno");
// 罚息核销规则
String penaltyRule = ProductParamUtil
.getProductParameterValue(lbContractInfoBizObj.getAttribute("PRODUCT_ID").getString(), "PRD0307", "PenaltyRule", "PenaltyRule");
Pair<List<String>, List<String>> paymentOrderPair = getHirePaymentOrder(paymentOrders, hireTypeList);
int hirePlanCount = planIDList.size();
int hireTimes = 0;
List<String> paymentOrder = null;
for (Entity entity : entityList) {
String planId = entity.getStr("id");
String paymentNumber = entity.getStr("payment_number");
Integer planList = entity.getInt("plan_list");
String planDate = entity.getStr("plan_date");
BigDecimal corpusOver = entity.getBigDecimal("corpus_over");
BigDecimal interestOver = entity.getBigDecimal("interest_over");
BigDecimal penaltyOver = entity.getBigDecimal("penalty_over");
if ((hireTypeList.contains("CORPUS") && corpusOver.compareTo(BigDecimal.ZERO) == 1)
|| (hireTypeList.contains("INTEREST") && interestOver.compareTo(BigDecimal.ZERO) == 1)
|| (hireTypeList.contains("PENALTY") && penaltyOver.compareTo(BigDecimal.ZERO) == 1)
) {
hireTimes++;
if (hireTimes <= hirePlanCount) {
if (!planIDList.contains(planId)) {
throw new RuntimeException("ERROR@期次【" + planList + "】尚未核销,不可以跨期核销");
}
if (moneyAmtRef.get().compareTo(BigDecimal.ZERO) < 1) {
throw new RuntimeException("ERROR@网银可核销金额不足");
}
// 保存租金占用
lcOccupyRentListService.save(tx, paymentNumber, planList, planId, "网银收款", flowunidParam);
// 获取核销顺序
if (factDate.compareTo(new SimpleDateFormat("yyyy/MM/dd").parse(planDate)) > 0) {
paymentOrder = paymentOrderPair.getLeft();
} else {
paymentOrder = paymentOrderPair.getRight();
}
// 判断罚息是否核销
if("penalty_income".equals(penaltyRule)) {
penaltyOver = BigDecimal.ZERO;
}
Map<String, BigDecimal> moneyOverMap = ImmutableMap.of("CORPUS", corpusOver, "INTEREST", interestOver, "PENALTY", penaltyOver);
Map<String, BigDecimal> hireResMap = hireMoney(paymentOrder, moneyAmtRef, moneyOverMap);
BigDecimal incomeCorpus = hireResMap.containsKey("CORPUS") ? hireResMap.get("CORPUS") : BigDecimal.ZERO;
BigDecimal incomeInterest = hireResMap.containsKey("INTEREST") ? hireResMap.get("INTEREST") : BigDecimal.ZERO;
BigDecimal incomePenalty = hireResMap.containsKey("PENALTY") ? hireResMap.get("PENALTY") : BigDecimal.ZERO;
// 保存租金实收临时表
BizObjectManager rentIncomeTempBOM = JBOFactory.getBizObjectManager(LC_RENT_INCOME_TEMP.CLASS_NAME, tx);
BizObject rentIncomeTempBizObj = rentIncomeTempBOM.newObject();
rentIncomeTempBizObj.setAttributeValue("QUOT_ID", entity.getStr("quot_id"));
rentIncomeTempBizObj.setAttributeValue("CUST_ID", entity.getStr("cust_id"));
rentIncomeTempBizObj.setAttributeValue("PROJECT_ID", entity.getStr("project_id"));
rentIncomeTempBizObj.setAttributeValue("PROJECT_PLAN_NUMBER", entity.getStr("project_plan_number"));
rentIncomeTempBizObj.setAttributeValue("CONTRACT_ID", entity.getStr("contract_id"));
rentIncomeTempBizObj.setAttributeValue("CONTRACT_PLAN_NUMBER", entity.getStr("contract_plan_number"));
rentIncomeTempBizObj.setAttributeValue("PAYMENT_NUMBER", paymentNumber);
rentIncomeTempBizObj.setAttributeValue("EBANK_NUMBER", ebankTempBizObj.getAttribute("EBANK_NUMBER").getString());
rentIncomeTempBizObj.setAttributeValue("PLAN_ID", planId);
rentIncomeTempBizObj.setAttributeValue("PLAN_LIST", planList);
rentIncomeTempBizObj.setAttributeValue("INTEREST_ADJUST", 0);
rentIncomeTempBizObj.setAttributeValue("SETTLE_METHOD", "settlemethod6");
rentIncomeTempBizObj.setAttributeValue("HIRE_LIST", getPlanHireList(planId));
rentIncomeTempBizObj.setAttributeValue("HIRE_DATE", factDateStr);
rentIncomeTempBizObj.setAttributeValue("CHARGE_WAY", "Collection");
rentIncomeTempBizObj.setAttributeValue("HIRE_OBJECT", ebankTempBizObj.getAttribute("CLIENT_NAME").getString());
rentIncomeTempBizObj.setAttributeValue("RENT", incomeCorpus.add(incomeInterest));
rentIncomeTempBizObj.setAttributeValue("CORPUS", incomeCorpus);
rentIncomeTempBizObj.setAttributeValue("INTEREST", incomeInterest);
rentIncomeTempBizObj.setAttributeValue("PENALTY", incomePenalty);
rentIncomeTempBizObj.setAttributeValue("CORPUS_ADJUST", 0);
rentIncomeTempBizObj.setAttributeValue("PENALTY_ADJUST", 0);
rentIncomeTempBizObj.setAttributeValue("OWN_BANK", ebankTempBizObj.getAttribute("OWN_BANK").getString());
rentIncomeTempBizObj.setAttributeValue("OWN_ACCOUNT", ebankTempBizObj.getAttribute("OWN_ACCOUNT").getString());
rentIncomeTempBizObj.setAttributeValue("OWN_NUMBER", ebankTempBizObj.getAttribute("OWNACC_NUMBER").getString());
rentIncomeTempBizObj.setAttributeValue("HIRE_BANK", ebankTempBizObj.getAttribute("CLIENT_BANK").getString());
rentIncomeTempBizObj.setAttributeValue("HIRE_ACCOUNT", ebankTempBizObj.getAttribute("CLIENT_ACCOUNT").getString());
rentIncomeTempBizObj.setAttributeValue("HIRE_NUMBER", ebankTempBizObj.getAttribute("CLIENT_ACC_NUMBER").getString());
//安鹏要求改为当前日期
//boLRIT.setAttributeValue("ACCOUNTING_DATE", boEb.getAttribute("FACT_DATE").getString());
rentIncomeTempBizObj.setAttributeValue("ACCOUNTING_DATE", StringFunction.getToday());
rentIncomeTempBizObj.setAttributeValue("ROLL_BACK", 0);
rentIncomeTempBizObj.setAttributeValue("COIN", entity.getStr("COIN"));
rentIncomeTempBizObj.setAttributeValue("IS_FLOWING", 0);
rentIncomeTempBizObj.setAttributeValue("FLOWUNID", flowunidParam);
rentIncomeTempBizObj.setAttributeValue("INPUTUSERID", currUserId);
rentIncomeTempBizObj.setAttributeValue("INPUTORGID", currOrgId);
rentIncomeTempBizObj.setAttributeValue("INPUTTIME", StringFunction.getTodayNow());
rentIncomeTempBizObj.setAttributeValue("UPDATEUSERID", currUserId);
rentIncomeTempBizObj.setAttributeValue("UPDATEORGID", currOrgId);
rentIncomeTempBizObj.setAttributeValue("UPDATETIME", StringFunction.getTodayNow());
rentIncomeTempBOM.saveObject(rentIncomeTempBizObj);
}
}
}
// 核销总共使用金额
BigDecimal allFactMoney = mayopeMoney.subtract(moneyAmtRef.get());
// 保存网银过程表
BizObjectManager lcEbankProcessBOM = JBOFactory.getBizObjectManager(LC_EBANK_PROCESS.CLASS_NAME, tx);
BizObject lcEbankProcessBizObj = lcEbankProcessBOM.createQuery("FLOWUNID=:FLOWUNID").setParameter("FLOWUNID", flowunidParam).getSingleResult(true);
BigDecimal processMoney = new BigDecimal(lcEbankProcessBizObj.getAttribute("PROCESS_MONEY").getString());
lcEbankProcessBizObj.setAttributeValue("PROCESS_MONEY", processMoney.add(allFactMoney));
lcEbankProcessBOM.saveObject(lcEbankProcessBizObj);
// 保存网银 MAYOPE_MONEY可核销金额 HAD_MONEY已核销金额
//剩余可核销金额=上次的剩余可核销金额-本次核销金额
//已核销金额 = 到账总金额 - 剩余可核销金额
// BigDecimal mayMoney = new BigDecimal(ebankTempBizObj.getAttribute("MAYOPE_MONEY").getDouble());
BigDecimal factMoney = new BigDecimal(ebankTempBizObj.getAttribute("FACT_MONEY").getString());
// BigDecimal mayMoneyNew = mayopeMoney.subtract(allFactMoney);
ebankTempBizObj.setAttributeValue("MAYOPE_MONEY", moneyAmtRef.get());
ebankTempBizObj.setAttributeValue("HAD_MONEY", factMoney.subtract(moneyAmtRef.get()).toString());
ebankTempBOM.saveObject(ebankTempBizObj);
return "SUCCESS";
}
/**
* 获取核销次数
* @param planID
* @return
* @throws JBOException
*/
private Integer getPlanHireList(String planID) throws JBOException {
List<BizObject> boLCRI = JBOFactory.createBizObjectQuery(LC_RENT_INCOME.CLASS_NAME, "PLAN_ID=:PLAN_ID").setParameter("PLAN_ID", planID)
.getResultList(false);
List<BizObject> boLCRIT = JBOFactory.createBizObjectQuery(LC_RENT_INCOME_TEMP.CLASS_NAME, "PLAN_ID=:PLAN_ID and IS_FLOWING = 0").setParameter("PLAN_ID", planID)
.getResultList(false);
return boLCRI.size() + boLCRIT.size() + 1;
}
/**
* 获取核销类型和核销顺序列表
* @param paymentOrders
* @param hireTypeList
* @return
*/
private Pair<List<String>, List<String>> getHirePaymentOrder(Map<String, List<Map<String, String>>> paymentOrders, List<String> hireTypeList) {
Function<List<Map<String, String>>, List<String>> hireTypeConvertFunc = tempList -> tempList.stream()
.map(tempMap -> {
String rmoname = tempMap.get("rmoname");
if("本金".equals(rmoname)) {
tempMap.put("hireType", "CORPUS");
} else if("利息".equals(rmoname)) {
tempMap.put("hireType", "INTEREST");
} else if("罚息".equals(rmoname)) {
tempMap.put("hireType", "PENALTY");
}
return tempMap;
})
.filter(o -> o.containsKey("hireType") && hireTypeList.contains(o.get("hireType")))
.sorted(Comparator.comparing(o -> Integer.valueOf(o.get("rmosortno"))))
.map(tempMap -> tempMap.get("hireType"))
.collect(Collectors.toList());
return Pair.of(hireTypeConvertFunc.apply(paymentOrders.get("RMO-02")), hireTypeConvertFunc.apply(paymentOrders.get("RMO-01")));
// for (int j = 0; j < paymentOrders.get("RMO-02").size(); j++) {
// String hireType = hireTypeConvertFunc.apply(paymentOrders.get("RMO-02").get(j).get("rmoname"));
// if(hireTypeList.contains(hireType)) {
// paymentOrderLeft.add(hireType);
// }
// }
// List<String> paymentOrderRight = new ArrayList<>();
// for (int j = 0; j < paymentOrders.get("RMO-01").size(); j++) {
// String hireType = hireTypeConvertFunc.apply(paymentOrders.get("RMO-01").get(j).get("rmoname"));
// if(hireTypeList.contains(hireType)) {
//// paymentOrderRight[Integer.parseInt(paymentOrders.get("RMO-01").get(j).get("rmosortno")) - 1] = hireType;
// paymentOrderRight.add(hireType);
// }
// }
// return Pair.of(paymentOrderLeft, paymentOrderRight);
}
private Map<String, BigDecimal> hireMoney(List<String> paymentOrder, AtomicReference<BigDecimal> moneyAmtRef, Map<String, BigDecimal> hireMap) {
Map<String, BigDecimal> resMap = new HashMap<>();
System.out.println("paymentOrder:" + paymentOrder);
System.out.println("moneyAmt:" + moneyAmtRef.get());
System.out.println("hireMap:" + hireMap);
for (String hireType : paymentOrder) {
BigDecimal overMoney = hireMap.get(hireType);
BigDecimal incomeMoney;
if (moneyAmtRef.get().compareTo(overMoney) >= 0) {
incomeMoney = overMoney;
moneyAmtRef.set(moneyAmtRef.get().subtract(overMoney));
} else {
incomeMoney = moneyAmtRef.get();
moneyAmtRef.set(BigDecimal.ZERO);
}
logger.info(hireType + ": overMoney:" + overMoney + ", incomeMoney:" + incomeMoney + ", moneyAmt:" + moneyAmtRef.get());
resMap.put(hireType, incomeMoney);
}
return resMap;
}
/**
* ±£Ö¤½ðµÖ¿Û
*/

View File

@ -0,0 +1,52 @@
package com.tenwa.lease.service;
import com.amarsoft.are.jbo.*;
import com.amarsoft.are.util.StringFunction;
import com.tenwa.cgbbank.dao.LBCgb0032LogDao;
import com.tenwa.reckon.util.UUIDUtil;
import jbo.com.tenwa.lease.comm.LC_OCCUPY_RENT_LIST;
/**
* @program: apzl_leasing
* @description:
* @author: 李超杰
* @create: 2025-04-14 15:00
*/
public class LCOccupyRentListService {
private static LCOccupyRentListService instance = new LCOccupyRentListService();
private LCOccupyRentListService() {
}
public static LCOccupyRentListService getInstance() {
return instance;
}
public BizObjectManager getBizObjectManager(JBOTransaction jboTransaction) throws JBOException {
return JBOFactory.getBizObjectManager(LC_OCCUPY_RENT_LIST.CLASS_NAME, jboTransaction);
}
/**
* 保存租金计划占用
* @param jboTran
* @param paymentNumber
* @param planList
* @param planId
* @param flowName
* @param flowunid
* @throws JBOException
*/
public void save(JBOTransaction jboTran, String paymentNumber, Integer planList, String planId, String flowName, String flowunid) throws JBOException {
BizObjectManager bizObjectManager = getBizObjectManager(jboTran);
BizObject boLORL = bizObjectManager.newObject();
boLORL.setAttributeValue(LC_OCCUPY_RENT_LIST.ID, UUIDUtil.getUUID());
boLORL.setAttributeValue(LC_OCCUPY_RENT_LIST.PAYMENT_NUMBER, paymentNumber);
boLORL.setAttributeValue(LC_OCCUPY_RENT_LIST.PLAN_LIST, planList);
boLORL.setAttributeValue(LC_OCCUPY_RENT_LIST.PLAN_ID, planId);
boLORL.setAttributeValue(LC_OCCUPY_RENT_LIST.FLOW_NAME, flowName);
boLORL.setAttributeValue(LC_OCCUPY_RENT_LIST.FLOWUNID, flowunid);
boLORL.setAttributeValue(LC_OCCUPY_RENT_LIST.INPUTTIME, StringFunction.getTodayNow());
bizObjectManager.saveObject(boLORL);
}
}