Exemplo n.º 1
0
 public function outRecord($form)
 {
     $arr['CreditRecord'] = $form->toArray();
     $this->load($arr);
     $creditAccount = new CreditAccount();
     $creditAccount = $creditAccount->find()->where(['account_id' => $this['out_account_id']])->one();
     //因为在该方法中要对同一张表多次添加记录,使用AR有BUG,所以不使用load方法,而手工加载数据
     $record_id = $this['record_id'];
     $fee_record_id = $this['fee_record_id'];
     $bank = $creditAccount['finance_id'];
     $card = $this['out_account_id'];
     $month = $form['start_month'] != '' ? $form['start_month'] : 0;
     $formDate = $form['create_time'] != '' ? $form['create_time'] : date('y-m-d H:i:s', time());
     echo $formDate;
     $date = DateUtil::addMonth($formDate, $month);
     $form['stage_number'] = $form['stage_number'] != '' ? $form['stage_number'] : 1;
     $money = $form['money'] / $form['stage_number'];
     //添加银行代付记录
     $this->addRecord($bank, $this['money'], $this['in_account_id'], $record_id, $formDate, 0);
     for ($i = 0; $i < $form['stage_number']; $i++) {
         //添加信用卡本金欠账记录(可分期)
         $this->addRecord($card, $money, $bank, $record_id, DateUtil::addMonth($date, $i), 0);
         if (isset($form['fee_per_stage']) && $form['fee_per_stage'] > 0) {
             //添加手续费
             $this->addRecord($card, $form['fee_per_stage'], $bank, $record_id, DateUtil::addMonth($date, $i), $fee_record_id);
         }
     }
     return $this->errors;
 }
Exemplo n.º 2
0
 public function findMonthCreditInfo($form = null)
 {
     $nextMonth = DateUtil::getCurrentMonth();
     $month = DateUtil::addMonth($nextMonth, -1, 'Y-m');
     $account = 11;
     if (isset($form)) {
         $nextMonth = $form->getYm('-');
         $month = DateUtil::addMonth($nextMonth, -1, 'Y-m');
         $account = $form['account_id'];
     }
     $passDay = DateUtil::getPass(DateUtil::getCurrentMonth());
     $query = new Query();
     $subquery = new Query();
     $subquery->select(['mi' => $this->getMonSumCMoneyQuery($month, 'in_account_id', [$account]), 'mo' => $this->getMonSumCMoneyQuery($month, 'out_account_id', [$account]), 'nmo' => $this->getMonSumCMoneyQuery($nextMonth, 'out_account_id', [$account]), 'i' => $this->getSumCMoneyQuery('in_account_id', [$account]), 'o' => $this->getSumCMoneyQuery('out_account_id', [$account]), 'tmo' => $this->getMonSumTCMoneyQuery($month, 'out_account_id'), 'ti' => $this->getSumCMoneyQuery('in_account_id'), 'to' => $this->getSumCMoneyQuery('out_account_id'), 'so' => $this->getMonCreditmoney($account, $month, 'record_id', $this->getStageRecordIdQuery([$account])), 'fo' => $this->getMonCreditmoney($account, $month, 'fee_record_id', $this->getFeeRecordIdQuery([$account]))]);
     //总交易数
     return $query->select(['m' => '(a.o-a.i)', 'mpert' => '((a.o-a.i)/(a.to-a.ti))', 'nrm' => 'a.nmo', 'crm' => 'a.mo', 'rmed' => 'a.mi', 'rming' => '(a.mo-a.mi)', 'st' => 'a.so', 'stpercrm' => '(a.so/a.mo)', 'fee' => 'a.fo', 'feepertcrm' => '(a.fo/a.mo)'])->from(['a' => $subquery])->one();
 }
Exemplo n.º 3
0
 public function actionMonthConsume()
 {
     $form = new MonthSearchForm();
     $years = DateUtil::getYears();
     $monthes = DateUtil::getMonthes();
     $query = new Account();
     $accounts = $query->findFormListArray(['type_id' => 5], -1, '总消费');
     if (Yii::$app->request->isPost) {
         $form->load(Yii::$app->request->post());
         $rel['consume'] = $query->findMonthConsumeInfo($form);
         $ym = $form['ym'];
     } else {
         $rel['consume'] = $query->findMonthConsumeInfo();
         $ym = DateUtil::getCurrentMonth('ch');
     }
     return $this->render('month/consumeDetail', ['model' => $form, 'years' => $years, 'monthes' => $monthes, 'accounts' => $accounts, 'rel' => $rel, 'ym' => $ym]);
 }
Exemplo n.º 4
0
 public function getMonCreditmoney($credit_id, $month = '2015-1', $column = 'in_account_id', $value = 1)
 {
     $day = $this->getReturnDay($credit_id)['return_day'];
     $query = $this->getAccountIOmoneyQuery($column, $value);
     return $query->from(['a' => 'fund_credit_record'])->andWhere(['between', 'create_time', DateUtil::getCreditMonthBegin($month, $day), DateUtil::getCreditMonthEnd($month, $day)]);
 }
Exemplo n.º 5
0
 public function findMonthConsumeInfo($form = null)
 {
     $month = DateUtil::getCurrentMonth();
     $account = 24;
     if (isset($form)) {
         $month = $form->getYm('-');
         $account = $form['account_id'];
     }
     $passDay = DateUtil::getPass(DateUtil::getCurrentMonth());
     $query = new Query();
     $subquery = new Query();
     $subquery->select(['m' => $this->getMonSumCurrencyQuery($month, 'in_account_id', [$account]), 'c' => $this->getMonSumCurrencyQuery($month, 'in_account_id', [$account])->select('COUNT(id)'), 't' => $this->getMonSumMoneyQuery($month, [2, 5])]);
     //消费总额
     return $query->select(['m' => 'a.m', 'c' => 'a.c', 'mperd' => "(a.m/{$passDay})", 'mperc' => '(a.m/a.c)', 'pct' => '(a.m/a.t)'])->from(['a' => $subquery])->one();
 }