时间处理

本文介绍了一个用于计算贷款收益的PHP函数,该函数通过循环计算不同日期的收益并生成表格形式的数据。涉及日期处理、条件判断及数学运算。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

public static function liebiao($model) {


        $table = '';
        $str = '<tr>%s</tr>';
        $td = "<td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td>";
        //借款成本

        $numClients = $model->billcount - 1;

        for ($i = 0; $i < $numClients; $i++) {

            list($y, $m, $d) = explode('-', $model->firstDate);

            if ($d <= 15) {
                $_mk = mktime(0, 0, 0, ((int) $m) + $i, 15, (int) $y);

                //$_newDate = date("Y-m-d", $_mk);
            } else {
                $mk = mktime(0, 0, 0, ((int) $m) + $i, $d, (int) $y);

                $newDate = date("Y-m-d", $mk);
                list($_y, $_m, $_d) = explode('-', $newDate);

                if ($_m == "02" || $_m == "2") {
                    $_mk = mktime(0, 0, 0, ((int) $_m), 28, (int) $_y);
                } else if ($_m == "03" && $_d == "02") {
                    $_mk = mktime(0, 0, 0, ((int) 02), 28, (int) $_y);
                } else {
                    $_mk = mktime(0, 0, 0, ((int) $_m), $_d, (int) $_y);
                }
            }

            $Date_1 = $Date_1 = date("Y-m-d", $_mk);
            $Date_2 = $model->generatedRightDate;
            $d1 = strtotime($Date_1);
            $d2 = strtotime($Date_2);

            $Days = round(($d1 - $d2) / 3600 / 24);
//            isset($results[0]['totalPaymentAmt']) ?  '是■否□' : '是□否■';

            if (mb_substr(Combox::getComboxName("回收方式", $model->recycleType), 0, 3) == "月月盈") {
                $_shouyi = $model->investAmt;
            } else {
                $shouyi = $model->investAmt + ($model->investAmt * ($model->recycleType / 100) / 360 * $Days);
                $_shouyi = sprintf("%01.2f", $shouyi);
            }





            $borrAmt = ContractPrint::againSummuryBorrowsPayAmt($model, date("Y-m-d", $_mk));
//
//            $yueAmt = $borrAmt - ContractPrint::tmonthAmt($model);



            if (mb_substr(Combox::getComboxName("回收方式", $model->recycleType), 0, 3) == "月月盈" && $i == 0) {

                list($by, $bm, $bd) = explode('-', $model->firstDate);
                list($ty, $tm, $_td) = explode('-', $model->generatedRightDate);
                //---------------------
                $_mk = mktime(0, 0, 0, ((int) $bm), $bd, (int) $by);

                $Date_1 = date("Y-m-d", $_mk);

                $_d1 = strtotime($Date_1);
                $_d2 = strtotime($model->generatedRightDate);
                $_Days = round(($_d1 - $_d2) / 3600 / 24);

                $_monthAmt = $model->investAmt * ($model->recycleType / 100) / 360 * $_Days;



                $tds = sprintf($td, date("Y-m-d", $_mk), $borrAmt, $borrAmt, 0, '0%', 0, $borrAmt - $_monthAmt, $_monthAmt, $_shouyi);
            } else if (mb_substr(Combox::getComboxName("回收方式", $model->recycleType), 0, 3) == "月月盈") {
                $tds = sprintf($td, date("Y-m-d", $_mk), $borrAmt, $borrAmt, 0, '0%', 0, $borrAmt - ContractPrint::tmonthAmt($model), ContractPrint::tmonthAmt($model), $_shouyi);
            } else {
                $tds = sprintf($td, date("Y-m-d", $_mk), $borrAmt, $borrAmt, 0, '0%', 0, $borrAmt, 0, $_shouyi);
            }
//            $_monthShouyi=ContractPrint::againPayAmt($model)-ContractPrint::monthAmt($model);
//                 $_AMT=$borrAmt-$_monthShouyi;   
//            $tds = sprintf($td, date("Y-m-d", $_mk), $borrAmt, $borrAmt, 0, '0%', $_AMT, $_monthShouyi, 0, $_shouyi);

            $table .= sprintf($str, $tds);
        }
        return $table;


//        $_sql = "select min(rightMonthNo) as months from rah_rightmatch where lendInvestID='$model->lendInvestID'";
//        $_command = Yii::app()->db->createCommand($_sql);
//        $_results = $_command->queryAll();
//        $_numClients = (int) $_results[0]["months"];
//
//        list($y, $m, $d) = explode('-', $_numClients);
//
//
//
//        for ($i = 0; $i < $numClients; $i++) {
//            $tds = '';
//
//            $shouyiri = date("Y-m-d", mktime(0, 0, 0, ((int) $m) + i, $d, (int) $y));
//
//
//            $table = '';
//            $str = '<tr>%s</tr>';
//            $td = "<td>%d</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td> <td>%s</td>";
//
//            $tds.= sprintf($td, $i,$shouyiri, 0, 0, 0, 0, 0, $numClients-$i, 0);
//
//
//            $table .= sprintf($str, $tds);
//        }
//        return $table;
    }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值