Ejemplo n.º 1
0
 /**
  * @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;
 }
Ejemplo n.º 2
0
 /**
  * @Route("/{round}/register", name="register", requirements={"round": "\d+"})
  * @Template()
  */
 public function registerAction(Request $request, $round = null)
 {
     $round = $round ? $this->roundRepo->find($round) : $this->roundRepo->findCurrent();
     $address = $request->get('address', null);
     if (!$address) {
         $this->getSession()->getFlashBag()->set('error', 'Address is required');
     } else {
         $validation = $this->manager->validateAddress($address);
         if (!$validation->isValid()) {
             $this->getSession()->getFlashBag()->set('error', 'Invalid address');
         } else {
             if (!($account = $this->accountRepo->findOneBy(['withdrawAddress' => $address]))) {
                 $depositAddress = $this->manager->getNewAddress($round->getWalletAccount());
                 $account = new Account();
                 $account->setWithdrawAddress($address);
                 $account->setDepositAddress($depositAddress);
                 if (($ref = $this->getSession()->get('ref')) || ($ref = $request->cookies->get('ref'))) {
                     if ($refAccount = $this->accountRepo->find($ref)) {
                         $account->setReferrer($refAccount);
                         $refAccount->addReferralRegistersCount();
                     }
                 }
                 $this->getDoctrine()->getManager()->persist($account);
                 $this->getDoctrine()->getManager()->flush();
             }
             $this->getSession()->set('account', $account->getId());
         }
     }
     return $this->redirect($this->generateUrl('stats', ['round' => $round->getId()]));
 }