apzl_leasing/src_tenwa/com/tenwa/handler/LCFundPaymentTempInfoHandler.java
2022-07-22 18:35:19 +08:00

147 lines
5.9 KiB
Java

package com.tenwa.handler;
import com.amarsoft.app.util.ProductParamUtil;
import com.amarsoft.are.jbo.BizObject;
import com.amarsoft.are.jbo.JBOFactory;
import com.amarsoft.are.jbo.JBOTransaction;
import com.amarsoft.awe.dw.handler.impl.CommonHandler;
import com.amarsoft.dict.als.cache.CodeCache;
import com.amarsoft.dict.als.object.Item;
import com.tenwa.comm.util.jboutil.DataOperatorUtil;
import jbo.app.tenwa.calc.LC_FUND_INCOME_TEMP;
import jbo.com.tenwa.lease.comm.LB_CONTRACT_INFO_TEMP;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class LCFundPaymentTempInfoHandler extends CommonHandler {
@Override
protected void afterUpdate(JBOTransaction tx, BizObject bo) throws Exception {
String lendingType = bo.getAttribute("LENDING_TYPE").toString();
String id = bo.getAttribute("ID").toString();
BizObject bo1 = JBOFactory.createBizObjectQuery(LC_FUND_INCOME_TEMP.CLASS_NAME,"ID=:id")
.setParameter("id",id).getSingleResult(false);
String flowunid = bo1.getAttribute("flowunid").getString();
String sql = "update O set O.LENDING_TYPE='"+lendingType+"' where O.flowunid='"+flowunid+"'";
JBOFactory.createBizObjectQuery(LB_CONTRACT_INFO_TEMP.CLASS_NAME,sql).executeUpdate();
}
@Override
protected void initDisplayForEdit(BizObject bo) throws Exception {
String productId = this.asPage.getParameter("ProductId");
//»ñÈ¡×ø¿ÛÏî
Map<String, Map<String, String>> params = ProductParamUtil.getProductComponentType(productId, "PRD0315");
List<String> deductFeeType = new ArrayList<String>();
for(Entry<String, Map<String, String>> feeTypes : params.entrySet()) {
if(!feeTypes.getValue().containsKey("isBalance")) {
continue;
}
String isBalance = feeTypes.getValue().get("isBalance");
if("yes".equals(isBalance)) {
deductFeeType.add(feeTypes.getKey());
}
}
Item[] items = CodeCache.getItems("FeeType");
String fundList = "";
for(Item item : items) {
for(String feetype : deductFeeType) {
if(feetype.equals(item.getRelativeCode())) {
if(fundList.length() != 0) {
fundList += ",";
}
fundList += "'" + item.getItemNo() + "'";
break;
}
}
}
if(fundList==null||"".equals(fundList)){
fundList="0";
}
String contractId = bo.getAttribute("CONTRACT_ID").getString();
//·Ö¶ÎÈÚ
List<Map<String, String>> dataBySql = DataOperatorUtil.getDataBySql("select SETTLE_METHOD from lc_calc_condition where CONTRACT_ID='"+bo.getAttribute("CONTRACT_ID").getString()+"'");
if(dataBySql!=null && dataBySql.size()>0 ) {
String settleMethod = dataBySql.get(0).get("SETTLE_METHOD");
if(settleMethod!=null && settleMethod.equals("segmented_financing")) {
Map<String, List<Map<String, String>>> configs = ProductParamUtil.getProductComponentDecisionTable( productId, "PRD0301","IsBalanceLending");
if(configs!=null && configs.size()>0 ) {
List<Map<String, String>> list = configs.get("segmented_financing");
if( list!=null && list.size()>0 ) {
String IsBalanceLending = list.get(0).get("IsBalanceLending");
if(IsBalanceLending!=null && IsBalanceLending.equals("Y")) {
fundList += ",'feetype27'";
}
}
}
}
}
//°²ÅôÌùÏ¢²»µÖ¿Û
//±±ÆûµÄÓеIJúÆ·¿ÉÒÔÌùÏ¢²î¶î·Å¿î
/*if(fundList.length() > 0) {
fundList += ",";
}
fundList += "'feetype27'";*/
String flowunid = this.asPage.getParameter("ObjectNo");
@SuppressWarnings("unchecked")
List<BizObject> boLFITs = JBOFactory.createBizObjectQuery(LC_FUND_INCOME_TEMP.CLASS_NAME,
"flowunid = '" + flowunid + "' and fee_type in (" + fundList + ") ").getResultList(false);
BigDecimal cleanLeaseMoney = new BigDecimal("0");
cleanLeaseMoney = cleanLeaseMoney.add(new BigDecimal(bo.getAttribute("FACT_MONEY").getString()));
BigDecimal deductMoney = new BigDecimal(0);//·Ö¶ÎÈÚÓпÉÄܶà¸öÌùÏ¢¼Æ»®
for(BizObject boLFIT : boLFITs) {
BigDecimal factMoney = new BigDecimal(boLFIT.getAttribute("FACT_MONEY").getString());
String feeType = boLFIT.getAttribute("FEE_TYPE").getString();
if(factMoney.compareTo(BigDecimal.ZERO) > 0) {
switch(feeType) {
case "feetype1":
cleanLeaseMoney = cleanLeaseMoney.add(factMoney);
bo.setAttributeValue("HANDLING_CHARGE_MONEY", factMoney);
this.asDataObject.setVisible("HANDLING_CHARGE_MONEY", true);
break;
case "feetype2":
cleanLeaseMoney = cleanLeaseMoney.add(factMoney);
bo.setAttributeValue("CAUTION_MONEY", factMoney);
this.asDataObject.setVisible("CAUTION_MONEY", true);
break;
case "feetype24":
cleanLeaseMoney = cleanLeaseMoney.add(factMoney);
bo.setAttributeValue("GPS_FEE", factMoney);
this.asDataObject.setVisible("GPS_FEE", true);
break;
case "feetype27":
cleanLeaseMoney = cleanLeaseMoney.add(factMoney);
deductMoney = deductMoney.add(factMoney);
// bo.setAttributeValue("DEALER_DISCOUNT", deductMoney);
// this.asDataObject.setVisible("DEALER_DISCOUNT", true);
bo.setAttributeValue("DISCOUNT_INTEREST", deductMoney);
this.asDataObject.setVisible("DISCOUNT_INTEREST", true);
break;
case "feetype5":
cleanLeaseMoney = cleanLeaseMoney.add(factMoney);
bo.setAttributeValue("FIRST_PAYMENT", factMoney);
this.asDataObject.setVisible("FIRST_PAYMENT", true);
break;
case "feetype32":
cleanLeaseMoney = cleanLeaseMoney.add(factMoney);
bo.setAttributeValue("PERSONAL_INSURANCE", factMoney);
this.asDataObject.setVisible("PERSONAL_INSURANCE", true);
break;
case "feetype33":
cleanLeaseMoney = cleanLeaseMoney.add(factMoney);
bo.setAttributeValue("DISCOUNT_INTEREST", factMoney);
this.asDataObject.setVisible("DISCOUNT_INTEREST", true);
break;
}
}
}
bo.setAttributeValue("CLEAN_LEASE_MONEY", cleanLeaseMoney);
}
}