/** * @param array|TransactionListResult[] $transactions * @return Deposit[] */ public function saveNewDeposits(array $transactions) { $deposits = []; foreach ($transactions as $transaction) { $this->round->getStats()->setLastCheckedTx($transaction->getTxId()); if ($account = $this->accountRepo->findOneBy(['depositAddress' => $transaction->getAddress(), 'round' => $this->round])) { /* @var $account Account */ if ($transaction->getAmount() < $this->round->getMinDeposit()) { $this->round->getStats()->addTotalDonation($transaction->getAmount()); continue; } $amount = min($this->round->getMaxDeposit(), $transaction->getAmount()); $donation = $transaction->getAmount() - $amount; if ($donation) { $this->round->getStats()->addTotalDonation($donation); } $deposit = $deposits[] = new Deposit(); $deposit->setAmount($amount); $deposit->setConfirmations($transaction->getConfirmations()); $deposit->setReceivedTime($transaction->getTime()); if ($deposit->getConfirmations() >= $this->round->getMinConfirmations()) { $deposit->setConfirmed(true); } $deposit->setTxIn($transaction->getTxId()); $deposit->setAccount($account); $this->payoutManager->createPayout($deposit); $this->em->persist($deposit); $this->em->flush(); } } $this->em->flush(); return $deposits; }
/** * @param array $params * @return array */ private function common($params) { $round = $params['round']; if (!$round) { throw $this->createNotFoundException('No round started.'); } /* @var $round Round */ $params['stats'] = $round->getStats(); if ($account = $this->getSession()->get('account')) { if ($account = $this->accountRepo->find($account)) { $params['account'] = $account; } } return $params; }