diff --git a/src_tenwa/com/tenwa/flow/util/CalculateUtil.java b/src_tenwa/com/tenwa/flow/util/CalculateUtil.java new file mode 100644 index 000000000..50fc58e0a --- /dev/null +++ b/src_tenwa/com/tenwa/flow/util/CalculateUtil.java @@ -0,0 +1,58 @@ +package com.tenwa.flow.util; + +import java.util.HashMap; +import java.util.Map; + +import com.amarsoft.app.util.ProductParamUtil; +import com.tenwa.reckon.util.NumTools; +import com.tenwa.reckon.util.NumberUtils; +import com.tenwa.reckon.util.RentTools; + +public class CalculateUtil { + /** + * + * @param product_id 产品编号 + * @param clean_lease_money 融资额 + * @param income_number 期数 + * @return rent 每月租金 + * @throws Exception + */ + public static String getRentByProductId(String product_id,String clean_lease_money,String income_number) throws Exception{ + Map map = new HashMap(); + //年利率 + String retu_vale = ProductParamUtil.getProductParameterValue(product_id,"PRD0350","product_rate","ProductRate"); + //期数 + String rem_rent_list = income_number; + //融资额 + String rem_corpus = clean_lease_money; + //数字 1:期初;或 0:期末 + String period_type = ProductParamUtil.getProductParameterValue(product_id,"PRD0350","period_type","begin_end"); + if("period_type_1".equals(period_type)){ + period_type="1"; + }else{ + period_type="0"; + } + //还款间隔,汽车一般都是月付,所以先按12来,以后有需求再改 + String income_number_year = "12"; + //未来值,默认为"0" + String nominalprice ="0"; + + map.put("retu_vale", retu_vale); + map.put("rem_rent_list", rem_rent_list); + map.put("rem_corpus", rem_corpus); + map.put("period_type", period_type); + map.put("income_number_year", income_number_year); + map.put("nominalprice", nominalprice); + + String rent = RentTools.getRentByPmt(map); + //租金圆整 + String rentRound = ProductParamUtil.getProductParameterValue(product_id,"PRD0323","RentRound","RentRound"); + String rentRoundType = ProductParamUtil.getProductParameterValue(product_id,"PRD0323","RentRound","RentRoundType"); + if(rentRound.length()>0){ + rent=NumberUtils.rentRound(rent, rentRound,rentRoundType); + }else{ + rent = NumTools.formatNumberDoubleScale(rent, 2); + } + return rent; + } +}