diff --git a/WebContent/Accounting/LoanSimulation/LoanBasicInfo.jsp b/WebContent/Accounting/LoanSimulation/LoanBasicInfo.jsp index 46faab073..a26082d5f 100644 --- a/WebContent/Accounting/LoanSimulation/LoanBasicInfo.jsp +++ b/WebContent/Accounting/LoanSimulation/LoanBasicInfo.jsp @@ -73,18 +73,30 @@ tx.commit(); } /*根据参数判断 是否去数据库查询*/ - - String sTempletNo = "LoanSimulationBasicInfo";//--模板号-- - ASObjectModel doTemp = new ASObjectModel(sTempletNo); - + + // 是否灵活产品 + String flexible = Sqlca.getString( "select attribute5 from business_type where typeno = '" + productId + "'" ); + String templateNo = "LoanSimulationBasicInfo"; + if ( "Y".equals( flexible ) ) { + templateNo = "LoanSimulationBasicFlexibleInfo"; + } + ASObjectModel doTemp = new ASObjectModel(templateNo); + Map> productRates = ProductParamUtil.getProductComponentType(productId, "PRD0350"); Map productRate = productRates.get("product_rate"); - String termType = productRate.get("TermType")== null ? "" : productRate.get("TermType"); - String termMin = productRate.get("TermScope-MIN"); - String termMax = productRate.get("TermScope-MAX"); - String isFixedRate = productRate.get("isFixedRate"); - String rateTermMin = productRate.get("RateTermScope-MIN"); - String rateTermMax = productRate.get("RateTermScope-MAX"); + String termType = productRate == null || productRate.get("TermType") == null ? "" : productRate.get("TermType"); + String termMin = ""; + String termMax = ""; + String isFixedRate = ""; + String rateTermMin = ""; + String rateTermMax = ""; + if ( productRate != null ) { + termMin = productRate.get("TermScope-MIN"); + termMax = productRate.get("TermScope-MAX"); + isFixedRate = productRate.get("isFixedRate"); + rateTermMin = productRate.get("RateTermScope-MIN"); + rateTermMax = productRate.get("RateTermScope-MAX"); + } if("02".equals(termType)){ doTemp.setColumnAttribute("INCOME_NUMBER", "coleditstyle", "1"); @@ -95,6 +107,14 @@ }else{ doTemp.setReadOnly("YEAR_RATE", true); } + + if ( "Y".equals( flexible ) ) { + doTemp.setReadOnly( "YEAR_RATE", false ); + doTemp.setHtmlEvent( "YEAR_RATE", "onchange", "changeYearRate" ); // 年利率事件 + doTemp.setHtmlEvent( "RENT_VALUE", "onchange", "changeRentValue" ); // 预计租金事件 + doTemp.setDefaultValue( "GPS_DIFFERENCE", ProductParamUtil.getProductParameterValue( productId, "PRD0390", "GPSDifference", "GPSDifference" ) ); + } + /*设置字段事件*/ doTemp.setHtmlEvent("SETTLE_METHOD", "onchange", "changeSettleMethod");//租金计算方式 doTemp.setHtmlEvent("RENT_OR_RATE", "onchange", "rentOrRateChange");//租金推算方法 @@ -241,7 +261,6 @@ $(function(){ //changeSettleMethod2(); //changeRateType(); //CalcControl.RentOrRateView(); - var inerNumber = $("#INCOME_NUMBER").val(); $("#INCOME_NUMBER").empty(); var inNumber=calcRules['incomeNumber']['INCOME_NUMBER']; @@ -265,6 +284,18 @@ $(function(){ // getRatioByMoney(getObj(0, "EQUIP_AMT")); }); +function changeYearRate() { + if ( getItemValue( 0, 0, 'YEAR_RATE' ) !== '' ) { + setItemValue( 0, 0, 'RENT_VALUE', '0.00' ); + } +} + +function changeRentValue() { + if ( getItemValue( 0, 0, 'RENT_VALUE' ) !== '' ) { + setItemValue( 0, 0, 'YEAR_RATE', '0.000000' ); + } +} + function financingCar(){ var financingCar = getItemValue(0, 0, "EQUIP_AMT")-getItemValue(0, 0, "FIRST_PAYMENT"); setItemValue(0, 0, "financing_car", financingCar); @@ -482,7 +513,7 @@ CalcControl.RateFloatTypeInit=function(){ CalcControl.SettleMethodView=function(){ var method=getItemValue(0,getRow(),"SETTLE_METHOD"); //按计算方式 显示按钮 和分段测算录入页面 - document.all("A_Group_even_subsection").style.display="none"; + // document.all("A_Group_even_subsection").style.display="none"; if("true"=="<%=isShowButton%>"){ var button = document.getElementById("InfoButtonArea").getElementsByTagName('a')[0]; if(method == 'irregular_rent'){ @@ -492,7 +523,7 @@ CalcControl.SettleMethodView=function(){ button.title = '租金测算'; button.childNodes[2].childNodes[1].innerText = '租金测算'; if(method=='even_subsection'){ - document.all("A_Group_even_subsection").style.display="block"; + // document.all("A_Group_even_subsection").style.display="block"; } } } @@ -521,11 +552,11 @@ CalcControl.SettleMethodView=function(){ //日期 //计划日期 - var plan; + var plan = ""; if(method=="even_subsection"||method=="irregular_rent"||method==""){ plan=""; }else{ - plan=calcRules['method'][method]["date_proc"].split(","); + // plan=calcRules['method'][method]["date_proc"].split(","); } var planflag={}; for(var i=0;i' ) { + setEnable( 'YEAR_RATE' ); + setEnable( 'RENT_VALUE' ); + } } CalcControl.RentOrRateInit=function(){ var rentOrRate = getItemValue(0,getRow(),"RENT_OR_RATE");//租金推算方式 @@ -1113,12 +1147,26 @@ function saveRecord(sPostEvents){ return; } } + + if ( 'Y' === '<%=flexible%>' ) { + var yearRate = getItemValue( 0, 0, 'YEAR_RATE' ); + var rentValue = getItemValue( 0, 0, 'RENT_VALUE' ); + if ( Number( yearRate ) === 0 && Number( rentValue ) === 0 ) { + alert( '灵活产品下,请在测算年利率或预计租金中填值' ); + return; + } else if ( Number( yearRate ) === 0 ) { + setItemValue( 0, 0, 'RENT_OR_RATE', 'rent' ); + } else { + setItemValue( 0, 0, 'RENT_OR_RATE', 'rate' ); + } + } + // 如果是不规则租金测算的话,那么仅保存商务报价。 var settleMethod = getItemValue(0,getRow(),"SETTLE_METHOD"); if(settleMethod == 'irregular_rent'){ as_save("myiframe0"); }else{ - as_save("myiframe0","run()"); + as_save("myiframe0","run()"); } } @@ -1294,15 +1342,15 @@ function rentOrRateChange(){ function changeSettleMethod3(){ var method="<%=dwTemp.getData().get("SETTLE_METHOD")%>"; //按计算方式 显示按钮 和分段测算录入页面 - document.all("A_Group_even_subsection").style.display="none"; + // document.all("A_Group_even_subsection").style.display="none"; if(method=='even_subsection'){ - document.all("A_Group_even_subsection").style.display="block"; + // document.all("A_Group_even_subsection").style.display="block"; } <%-- var param="CompClientID=<%=compClientID%>&flowunid=<%=flowunid%>&plannumber=<%=plannumber%>&planCName=<%=planCName%>&IsHistory=<%=ishistory%>&NodeNo=<%=nodeNo%>&calType=<%=calType%>&method="+method; AsControl.OpenView("/Accounting/LoanSimulation/condition_plan.jsp",param, "frame_list"); --%> var rentOrRate ="<%=dwTemp.getData().get("RENT_OR_RATE")%>";//租金推算方式 - document.all("A_Group_calc_config").style.display="none"; + // document.all("A_Group_calc_config").style.display="none"; if(rentOrRate == 'knowing_rent'){//已知租金规则 只能固定利率 document.all("A_Group_calc_config").style.display="block"; var param="CompClientID=<%=compClientID%>&flowunid=<%=flowunid%>&plannumber=<%=plannumber%>&planCName=<%=planCName%>&IsHistory=<%=ishistory%>&NodeNo=<%=nodeNo%>&calType=<%=calType%>"; @@ -1322,11 +1370,11 @@ function changeSettleMethod3(){ } //日期 //计划日期 - var plan; + var plan = ""; if(method=="even_subsection"||method=="irregular_rent"||method==""){ plan=""; }else{ - plan=calcRules['method'][method]["date_proc"].split(","); + // plan=calcRules['method'][method]["date_proc"].split(","); } var planflag={}; for(var i=0;i - + diff --git a/WebContent/WEB-INF/etc/app/component/component-parameter-config.xml b/WebContent/WEB-INF/etc/app/component/component-parameter-config.xml index f8b2f597c..fdd447cdb 100644 --- a/WebContent/WEB-INF/etc/app/component/component-parameter-config.xml +++ b/WebContent/WEB-INF/etc/app/component/component-parameter-config.xml @@ -178,7 +178,7 @@ - + @@ -196,4 +196,4 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/WebContent/WEB-INF/etc/jbo/jbo_calc.xml b/WebContent/WEB-INF/etc/jbo/jbo_calc.xml index 36106c6e0..f8c0475b7 100644 --- a/WebContent/WEB-INF/etc/jbo/jbo_calc.xml +++ b/WebContent/WEB-INF/etc/jbo/jbo_calc.xml @@ -770,6 +770,12 @@ + + + + + + @@ -1064,6 +1070,12 @@ + + + + + + @@ -1398,7 +1410,12 @@ - + + + + + + @@ -2750,6 +2767,12 @@ + + + + + + @@ -3326,6 +3349,12 @@ + + + + + + diff --git a/calc/com/tenwa/reckon/bean/ConditionBean.java b/calc/com/tenwa/reckon/bean/ConditionBean.java index 641d63845..cb0dc16ba 100644 --- a/calc/com/tenwa/reckon/bean/ConditionBean.java +++ b/calc/com/tenwa/reckon/bean/ConditionBean.java @@ -165,6 +165,13 @@ public class ConditionBean implements Cloneable{ private String finalPayment; //尾款 private String finalPaymentMethod; //尾款处置方式 private String productType; //增加一个产品类型字段方便判断 + + private String flexible; // 是否灵活产品 + private String operatingRate; // 运营费率 + private String GPSDifference; // GPS差额 + private String riskAccrualRatio; // 风险计提比率 + private String strategicCoefficient; // 战略系数 + private String strategyROA; // 战略系数 //**********************************************************************【众联车贷测算参与融资资金项结束!】 /*********************************************************************************** @@ -1757,4 +1764,52 @@ public class ConditionBean implements Cloneable{ public void setProductType(String productType) { this.productType = productType; } + + public String getFlexible() { + return flexible; + } + + public void setFlexible(String flexible) { + this.flexible = flexible; + } + + public String getOperatingRate() { + return operatingRate; + } + + public void setOperatingRate(String operatingRate) { + this.operatingRate = operatingRate; + } + + public String getGPSDifference() { + return GPSDifference; + } + + public void setGPSDifference(String GPSDifference) { + this.GPSDifference = GPSDifference; + } + + public String getRiskAccrualRatio() { + return riskAccrualRatio; + } + + public void setRiskAccrualRatio(String riskAccrualRatio) { + this.riskAccrualRatio = riskAccrualRatio; + } + + public String getStrategicCoefficient() { + return strategicCoefficient; + } + + public void setStrategicCoefficient(String strategicCoefficient) { + this.strategicCoefficient = strategicCoefficient; + } + + public String getStrategyROA() { + return strategyROA; + } + + public void setStrategyROA(String strategyROA) { + this.strategyROA = strategyROA; + } } diff --git a/calc/com/tenwa/reckon/bean/TabCalBean.java b/calc/com/tenwa/reckon/bean/TabCalBean.java index 081e15232..1f8586c15 100644 --- a/calc/com/tenwa/reckon/bean/TabCalBean.java +++ b/calc/com/tenwa/reckon/bean/TabCalBean.java @@ -48,6 +48,7 @@ public class TabCalBean { private String docId; private String productId; private String productType; + private Map> productRevenues; public String getProductType() { return productType; @@ -413,5 +414,11 @@ public class TabCalBean { this.calcFund = calcFund; } - + public Map> getProductRevenues() { + return productRevenues; + } + + public void setProductRevenues(Map> productRevenues) { + this.productRevenues = productRevenues; + } } diff --git a/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java b/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java index 781469e86..c4dd44fbd 100644 --- a/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java +++ b/calc/com/tenwa/reckon/executor/CreateTransactionExecutor.java @@ -23,6 +23,7 @@ import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.are.util.json.JSONEncoder; import com.amarsoft.are.util.json.JSONObject; +import com.amarsoft.awe.util.ASResultSet; import com.amarsoft.awe.util.SqlObject; import com.tenwa.comm.exception.BusinessException; import com.tenwa.comm.util.jboutil.DataOperatorUtil; @@ -106,19 +107,26 @@ public class CreateTransactionExecutor implements Transaction { JSONObject jsonObject = JSONObject.createObject(); String irr = ""; JBOTransaction tx=null; + ASResultSet rs = null; try { tx=JBOFactory.createJBOTransaction(); TabCalBean bean = TbBeanTools.getTabInfo(calType, flowunid,plannumber,productId); this.deletePayCondition(this.getFlowunid(),bean.getPlanCName(), bean.getPlanCValue(), tx); DictTools.setYearRate(bean); + //获取产品类型 + com.amarsoft.awe.util.Transaction Sqlca = com.amarsoft.awe.util.Transaction.createTransaction(tx); + rs = Sqlca.getASResultSet(new SqlObject("select attribute2, attribute5 from business_type where typeno='"+productId+"'")); + String productType = ""; + if ( rs.next() ) { + productType = rs.getString( "attribute2" ); + bean.getCb().setFlexible( rs.getString( "attribute5" ) ); + } String yearRate = bean.getCb().getYearRate(); this.preHandle(bean.getCb(),bean); + checkYearRate( bean.getCb(), bean, new BigDecimal( bean.getCb().getYearRate() ) ); if(bean.getCb().getRentOrRate().equals("rent")&&new BigDecimal(bean.getCb().getIncomeNumber()).multiply(new BigDecimal(bean.getCb().getRentValue())).compareTo(new BigDecimal(bean.getCb().getCleanLeaseMoney()))<0){ throw new BusinessException("按租金算年利率租金总和必须大于融资额"); } - //获取产品类型 - com.amarsoft.awe.util.Transaction Sqlca = com.amarsoft.awe.util.Transaction.createTransaction(tx); - String productType = Sqlca.getString(new SqlObject("select attribute2 from business_type where typeno='"+productId+"'")); bean.setProductType(productType); bean.getCb().setProductType(productType); jsonObject.appendElement("year_rate", yearRate); @@ -137,7 +145,11 @@ public class CreateTransactionExecutor implements Transaction { // TODO Auto-generated catch block e1.printStackTrace(); } - jsonObject.appendElement("message",e.getMessage()); + String message = e.getMessage(); + if ( message == null ) { + message = "测算失败"; + } + jsonObject.appendElement("message", message); return JSONEncoder.encode(jsonObject); }catch (Exception e) { try { @@ -149,6 +161,11 @@ public class CreateTransactionExecutor implements Transaction { e.printStackTrace(); return irr; }finally{ + try { + if ( rs != null ) rs.close(); + } catch ( Exception e ) { + e.printStackTrace(); + } if(tx!=null){ try { tx.commit(); @@ -161,6 +178,24 @@ public class CreateTransactionExecutor implements Transaction { } + public void checkYearRate( ConditionBean cb, TabCalBean tcb, BigDecimal yearRate ) throws BusinessException { + if ( "Y".equals( cb.getFlexible() ) ) { + // 灵活产品验证年利率区间 + try { + Map> productRevenues = ProductParamUtil.getProductComponentType( tcb.getProductId(), "PRD0390" ); + tcb.setProductRevenues( productRevenues ); + String rateMin = productRevenues.get( "CostInterestRate" ).get( "CostInterestRate-MIN" ); + String rateMax = productRevenues.get( "CostInterestRate" ).get( "CostInterestRate-MAX" ); + if ( !( yearRate.compareTo( new BigDecimal( rateMax ) ) <= 0 && yearRate.compareTo( new BigDecimal( rateMin ) ) >= 0 ) ) { + throw new BusinessException( "年利率: " + yearRate.setScale( 6, 4 ).toString() + ",不在产品配置区间范围内" ); + } + } catch ( Exception e ) { + e.printStackTrace(); + throw new BusinessException( e.getMessage() ); + } + } + } + /** * 正常测算 */ diff --git a/calc/com/tenwa/reckon/help/ConditionHelper.java b/calc/com/tenwa/reckon/help/ConditionHelper.java index 5da8a21bb..888572c48 100644 --- a/calc/com/tenwa/reckon/help/ConditionHelper.java +++ b/calc/com/tenwa/reckon/help/ConditionHelper.java @@ -13,6 +13,7 @@ import com.amarsoft.are.jbo.BizObjectManager; import com.amarsoft.are.jbo.JBOFactory; import com.amarsoft.are.jbo.JBOTransaction; import com.amarsoft.are.util.json.JSONObject; +import com.tenwa.comm.exception.BusinessException; import com.tenwa.comm.util.jboutil.DataOperatorUtil; import com.tenwa.reckon.bean.ConditionBean; import com.tenwa.reckon.bean.FundRentPlanBean; @@ -81,6 +82,56 @@ public class ConditionHelper { //更新保证金抵扣 params.put("CAUTION_DEDUCTION_MONEY",cb.getCautionDeductionMoney()); params.put("CAUTION_MONEY_REMAIN",cb.getCautionMoneyRemain()); + + if ( "Y".equals( cb.getFlexible() ) ) { + // 灵活产品计算其他项 + try { + Map> productRevenues = bean.getProductRevenues(); + String roaMin = productRevenues.get( "StrategyROA" ).get( "StrategyROA-MIN" ); + String roaMax = productRevenues.get( "StrategyROA" ).get( "StrategyROA-MAX" ); + // 1 + 税差 + BigDecimal tax = BigDecimal.ONE.add( new BigDecimal( cb.getRate() ) ); + // 利息和 + List interestBusinessList = rentPlan.getInterestBusinessList(); + BigDecimal allInterest = BigDecimal.ZERO; + for ( String interestBusiness : interestBusinessList ) { + allInterest = allInterest.add( new BigDecimal( interestBusiness ) ); + } + // 手续费 + BigDecimal handlingChargeMoney = new BigDecimal( cb.getHandlingChargeMoney() ); + // GPS差额 + BigDecimal gpsDifference = new BigDecimal( cb.getGPSDifference() ); + // 收入 + BigDecimal in = allInterest.divide( tax, 2, 4 ).add( handlingChargeMoney.divide( tax, 2, 4 ) ).add( gpsDifference.divide( tax, 2, 4 ) ); + // 租赁年限 + int leaseTerm = cb.getLeaseTerm(); + // 融资额 + BigDecimal cleanLeaseMoney = new BigDecimal( cb.getCleanLeaseMoney() ); + // 成本 + BigDecimal cost = cleanLeaseMoney.add( new BigDecimal( cb.getCautionMoney() ).multiply( new BigDecimal( leaseTerm ) ) ).divide( tax, 2, 4 ); + // 运营费率 + String operatingRate = productRevenues.get( "OperatingRate" ).get( "OperatingRate" ); + // 运营费用 + BigDecimal operatingExpenses = cleanLeaseMoney.multiply( new BigDecimal( operatingRate ) ); + // 风险计提比率 + String riskAccrualRatio = productRevenues.get( "RiskAccrualRatio" ).get( "RiskAccrualRatio" ); + // 风险计提 + BigDecimal withdrawalRisk = cleanLeaseMoney.multiply( new BigDecimal( riskAccrualRatio ) ); + // ROA + BigDecimal roa = in.subtract( cost ).subtract( operatingExpenses ).subtract( withdrawalRisk ).multiply( new BigDecimal( 0.75 ) ).divide( cleanLeaseMoney, 2, 4 ).multiply( new BigDecimal( 2 ) ); + if ( !( roa.compareTo( new BigDecimal( roaMin ) ) >= 0 && roa.compareTo( new BigDecimal( roaMax ) ) <= 0 ) ) { + throw new BusinessException( "ROA不在区间范围内" ); + } + // 战略系数 + String strategicCoefficient = productRevenues.get( "StrategicCoefficient" ).get( "StrategicCoefficient" ); + params.put( "OPERATING_RATE", operatingRate ); + params.put( "RISK_ACCRUAL_RATIO", riskAccrualRatio ); + params.put( "STRATEGIC_COEFFICIENT", strategicCoefficient ); + params.put( "STRATEGY_ROA", roa.toString() ); + } catch ( Exception e ) { + throw new BusinessException( e.getMessage() ); + } + } this.updateCondition(bean, params); return params; }