当前位置: 首页>>代码示例>>PHP>>正文


PHP Propel::getWriteConnection方法代码示例

本文整理汇总了PHP中Propel::getWriteConnection方法的典型用法代码示例。如果您正苦于以下问题:PHP Propel::getWriteConnection方法的具体用法?PHP Propel::getWriteConnection怎么用?PHP Propel::getWriteConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Propel的用法示例。


在下文中一共展示了Propel::getWriteConnection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addRepayment

 public function addRepayment(Loan $loan, \Datetime $date, Money $amount, BorrowerPayment $borrowerPayment = null)
 {
     // Divide the payment in the lenders and the web site fee
     // 1. Get the web site fee %
     // 2. Get who all lended and how much
     // 3. substract he website fee out of this installment
     // 4. remaining money should be divided in lenders according to their proportion and added
     // 5. If the loan gets completed with this payment set the loan status to complete
     $calculator = $this->getRepaymentCalculator($loan, $amount);
     if ($calculator->unpaidAmount()->isNegative()) {
         throw new \Exception('Unpaid amount is negative');
     }
     $con = Propel::getWriteConnection(TransactionTableMap::DATABASE_NAME);
     $con->beginTransaction();
     $refundThreshold = $this->currencyService->convertFromUSD(Money::create(1), $loan->getCurrency(), $date);
     $refundAmount = $calculator->refundAmount($refundThreshold);
     if ($refundAmount->isPositive()) {
         $this->addBorrowerRefund($con, $loan, $refundAmount);
         $amount = $amount->subtract($refundAmount);
         $calculator->setRepaymentAmount($amount);
     }
     $this->transactionService->addInstallmentTransaction($con, $amount, $loan, $date);
     $nativeFeeAmount = $calculator->installmentServiceFee();
     $feeAmount = $this->currencyService->convertToUSD($nativeFeeAmount, $date);
     $this->transactionService->addInstallmentFeeTransaction($con, $loan, $feeAmount, $date);
     $bids = BidQuery::create()->filterByLoan($loan)->filterByActive(true)->find();
     $loanRepayments = $calculator->loanRepayments($bids);
     /** @var $loanRepayment LoanRepayment */
     foreach ($loanRepayments as $loanRepayment) {
         $lender = $loanRepayment->getLender();
         $nativeLenderAmount = $loanRepayment->getAmount();
         $nativeLenderInviteCredit = $loanRepayment->getLenderInviteCredit();
         if ($nativeLenderAmount->isPositive()) {
             $lenderAmount = $this->currencyService->convertToUSD($nativeLenderAmount, $date);
             $this->transactionService->addRepaymentTransaction($con, $lenderAmount, $loan, $lender, $date);
         }
         if ($nativeLenderInviteCredit->isPositive()) {
             $lenderInviteCredit = $this->currencyService->convertToUSD($nativeLenderInviteCredit, $date);
             $this->transactionService->addLenderInviteCreditRepaymentTransaction($con, $lenderInviteCredit, $loan, $date);
         }
     }
     $updatedInstallments = $this->updateInstallmentSchedule($con, $loan, $amount, $date);
     // TODO
     // $database->setOntimeRepayCredit($rest4, $borrowerid, $amount);
     // TODO
     // $database->loanpaidback($borrowerid,$loanid);
     // TODO emails/sms
 }
开发者ID:Junyue,项目名称:zidisha2,代码行数:48,代码来源:RepaymentService.php


注:本文中的Propel::getWriteConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。