php 银行贷款利息 等额本息 等额本金

2015-2-1 奇Yu WEB开发

//等额本金还款法
  private  static function debj($borrow_amount, $rate, $drepay_time,$showYue=false){     
   
       //累计还款总额
       $HuanKuanZonge=0;
       //月本金
       $yueBenJin = $borrow_amount / $drepay_time;
     
   
       $fh = array();
       $fh['yueBenJin'] = $yueBenJin;
   
        //余额
       $yue = $borrow_amount;
       $sz = array();
       for($i = 1; $i <= $drepay_time; $i++)
       {
           $yueHuanKuan = $borrow_amount/$drepay_time + ($borrow_amount-$borrow_amount*($i-1)/$drepay_time)*$rate;//第i月还款额
        
           if ($i == 1)
           {
               //首月还款
               $fh['shouYueHuanKuan'] = $yueHuanKuan;
           }
           if ($i == 2)
           {
               //每月递减
               $fh['meiYuDiJian'] = $fh['shouYueHuanKuan'] - $yueHuanKuan;
           }
           $HuanKuanZonge = $HuanKuanZonge + $yueHuanKuan;
           $yueLiXi = $yueHuanKuan - $yueBenJin;
           $yue = $yue - $yueBenJin;
   
           $xj = array();
           $xj['bh'] = $i;
           $xj['yueLiXi'] = $yueLiXi;   //月利息
           $xj['yueBenJin']=$yueBenJin; //月本金
           $xj['yueHuanKuan'] = $yueHuanKuan;   //月还款
           $xj['yue'] = $yue;     //余额
           $sz[$i-1] = $xj;
       }
       $fh['zongLiXi'] = $HuanKuanZonge - $borrow_amount;
       $fh['huanKuanZongHe'] = $HuanKuanZonge;

       if ($showYue)
       {
           $fh['xx'] = $sz;
       } 
       return $fh;

}


//等额本息

	
/**
*
* @param 总金额 $je
* @param 月利率 $ylv
* @param 借款时间 $qx
* @param bool 是否显示详细 $isshow
* @return multitype:number multitype:multitype:number Ambigous <string, number>
*/
private static function debx($je, $ylv, $qx,$isshow=false)
{
//每月还款
$yhk=$je * $ylv * (pow(1+$ylv, $qx)/(pow(1+$ylv, $qx) -1));;
//累计还款总额
$hkze=$yhk * $qx;
//累计支付利息
$zlx=$hkze - $je;
$fh = array();
$fh['zongLiXi'] = $zlx;
$fh['huanKuanZongHe'] = $hkze;
$fh['yueHuanKuan'] = $yhk;
if ($isshow)
{
$ye = $je; //贷款余额
$sz =array();
for ($i=1; $i<=$qx; $i++)
{
$ylx = $ye * $ylv;
$ybj = $yhk-$ylx;
$ye -= $ybj;
$xj = array();
$xj['bh'] = $i;
$xj['yueLiXi'] = $ylx; //月利息
$xj['yueBenJin'] = $ybj; //月本金
$xj['yueHuanKuan']=$ylx+$ybj;//月还款
$xj['yue'] = $ye; //余额
$sz[$i-1] = $xj;
}
$fh['xx'] = $sz;
}
return $fh;
}

标签: php

评论(1) 浏览(2132)

Powered by emlog 豫ICP备14014990号-1 sitemap