apzl_leasing/calc/com/tenwa/reckon/executor/CarEvenRentExecutor.java
2018-06-03 22:26:41 +08:00

114 lines
4.1 KiB
Java

package com.tenwa.reckon.executor;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import com.amarsoft.app.util.ProductParamUtil;
import com.amarsoft.are.jbo.JBOTransaction;
import com.tenwa.reckon.bean.ConditionBean;
import com.tenwa.reckon.bean.FundRentPlanBean;
import com.tenwa.reckon.bean.TabCalBean;
import com.tenwa.reckon.constant.Scale;
import com.tenwa.reckon.help.CorpusServiceImpl;
import com.tenwa.reckon.help.InterestCalServiceImpl;
import com.tenwa.reckon.help.KnowingRentTools;
import com.tenwa.reckon.help.PlanDateServiceImpl;
import com.tenwa.reckon.help.RentPlanServiceImpl;
import com.tenwa.reckon.help.RentalServiceImpl;
import com.tenwa.reckon.util.RateTools;
import com.tenwa.reckon.util.TransRateHelper;
public class CarEvenRentExecutor extends FundRentPlanExecutor {
private String productId;
public CarEvenRentExecutor(JBOTransaction tx, String productId) {
super(tx);
this.productId = productId;
}
@Override
public FundRentPlanBean create(TabCalBean tcb,Integer startList) throws Exception {
FundRentPlanBean fpb = new FundRentPlanBean();
//删除租金计划
this.deleteRentPlan(tcb.getRentPlan_tb(), tcb, startList);
this.getPmtRentPlan(tcb.getCb(), fpb,tcb);
this.addRentPlan(fpb, tcb, startList);
return fpb;
}
public void getPmtRentPlan(ConditionBean cb, FundRentPlanBean frpb,TabCalBean tcb) throws Exception {
List<String> rentList = new ArrayList<String>();
initShareAndRetainage(tcb, cb);//初始化分摊本金与尾款
// 加载租金列表
if(cb.getRentOrRate().equals("knowing_rent")){
Integer grace = cb.getGrace();
if(grace > 0){
String preRate = RateTools.getPreRate(new BigDecimal(cb.getYearRate()).setScale(6,BigDecimal.ROUND_HALF_UP).toString(), cb.getIncomeNumberYear(),cb.getRateAdjustType());
String tempRent = new BigDecimal(cb.getCleanLeaseMoney()).multiply(new BigDecimal(preRate)).setScale(Scale.RENT_SCALE, BigDecimal.ROUND_HALF_UP).toString();
for(int i = 0 ; i < grace ; i++){
rentList.add(tempRent);
}
}
rentList.addAll(KnowingRentTools.convertKnowingBeanToStrList(tcb.getKnowingConfigs()));
}else{
RentalServiceImpl rsi = new RentalServiceImpl();
rentList = rsi.getRentListByCondWithZL(cb);
}
frpb.setRentList(rentList);
// 加载日期列表
PlanDateServiceImpl pdsi = new PlanDateServiceImpl(tx);
List<String> dateList = pdsi.getPlanDateList(cb, String.valueOf(frpb.getRentList().size()));
List<String> interestDateList=pdsi.getInterestDateList(cb);
//节假日调整
dateList=pdsi.getAdjustDate(dateList,cb.getPlanDateHoilday());
interestDateList=pdsi.getAdjustDate(interestDateList, cb.getInterestDateHoliday());
if("start_date".equals(cb.getInterestDayType())){
interestDateList=dateList;
}
frpb.setPlanDateList(dateList);
frpb.setInterestDateList(interestDateList);
List<String> year_rate = new ArrayList<String>();
for (int i = 0; i < frpb.getPlanDateList().size(); i++) {
year_rate.add(cb.getYearRate());
}
frpb.setYearRateList(year_rate);
// 加载利息列表
InterestCalServiceImpl icsi = new InterestCalServiceImpl();
List<String> interests = icsi.getInterestList(frpb.getRentList(), cb.getCleanLeaseMoney(), cb.getYearRate(), cb.getPeriodType(), cb.getGrace(), cb.getIncomeNumberYear(), cb.getEquipEndValue(),cb.getRateAdjustType());
frpb.setInterestBusinessList(interests);
// 加载本金列表
CorpusServiceImpl csi = new CorpusServiceImpl();
List<String> corpusList = csi.getCorpusList(frpb.getRentList(), frpb.getInterestBusinessList());
frpb.setCorpusBusinessList(corpusList);
//计算含税租金
if(tcb.getCb().getSettleMethod().equals("even_rent_rate")){
this.addRentRate(tcb.getCb(), frpb);
}
// 加载调整信息列表
RentPlanServiceImpl rpsi = new RentPlanServiceImpl();
rpsi.adjustLastRentPlanWithZL(frpb, cb.getCleanLeaseMoney(), cb.getEquipEndValue(), cb);
if("rate".equals(cb.getRentOrRate())){
rpsi.adjustFistAndLastRentPlan(frpb, tcb);
}
// 加载本金余额列表
List<String> corpusOverageBusinessList = TransRateHelper.getCorpusOvergeList(cb.getCleanLeaseMoney(), frpb.getCorpusBusinessList());
frpb.setCorpusOverageBusinessList(corpusOverageBusinessList);
}
}