Пример #1
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();
 }
Пример #2
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();
 }