public function __construct(CoinManagerContainer $coinManagerContainer, EntityManager $em, DepositRepository $depositRepo, RoundRepository $roundRepo) { $this->depositRepo = $depositRepo; $this->manager = $coinManagerContainer->get('main'); $this->round = $roundRepo->findCurrent(); $this->em = $em; }
public function __construct(WalletManager $walletManager, EntityManager $em, PayoutRepository $payoutRepo, RoundRepository $roundRep, DepositRepository $depositRepo) { $this->walletManager = $walletManager; $this->em = $em; $this->payoutRepo = $payoutRepo; $this->round = $roundRep->findCurrent(); $this->depositRepo = $depositRepo; }
public function startNextRound() { $currentRound = $this->roundRepo->findCurrent(); // check if settings for next round exist if (!($nextRound = $this->roundRepo->find($currentRound->getId() + 1))) { $nextRound = clone $currentRound; // __clone removes id $this->em->persist($nextRound); } $currentRound->setFinished(true); $nextRound->setStarted(true); $this->em->flush(); }
/** * @Route("/round/{round}", name="admin_round", defaults={"round" = null}) * @Template() */ public function roundAction(Request $request, Round $round = null) { $this->checkIp($request); // new round defining if (!$round) { $round = new Round(); if (!($currentRound = $this->roundRepo->findOneBy(['started' => true, 'finished' => false]))) { // first round auto start $roundId = 1; } else { $lastRound = $this->roundRepo->findOneBy([], ['id' => 'desc']); $roundId = $lastRound->getId() + 1; } } else { $roundId = $round->getId(); } $form = $this->createForm(new RoundType(), $round); if ($request->isMethod('post')) { $form->submit($request); if ($form->isValid()) { if ($roundId == 1) { $round->setStarted(true); } $this->em->persist($round); $this->em->flush(); $this->roundManager->defineWalletAccount($round); return $this->redirect($this->generateUrl('admin')); } } return $this->render('AppBundle:Admin:round.html.twig', ['round' => $round, 'roundId' => $roundId, 'form' => $form->createView()]); }
protected function execute(InputInterface $input, OutputInterface $output) { $this->init(); $this->output = $output; $this->input = $input; try { $lock = Lock::lock('scanner_' . $this->nameShort); } catch (UnableToLockException $e) { $this->writeln('Already running'); return; } $this->writeln('Started wallet scanner ' . date('Y-m-d H:i:s')); if (!($this->round = $this->roundRepo->findOneBy(['started' => true, 'finished' => false]))) { $this->writeln('No running round'); return; } $this->writeln('Creating new incoming transactions'); if ($newTransactions = $this->walletManager->getNewIncomingTransactions()) { $this->writeln('Found ' . count($newTransactions) . ' new transactions'); $this->depositManager->saveNewDeposits($newTransactions); } else { $this->writeln('No new transactions found'); } $this->writeln('Updating deposits'); $updated = $this->depositManager->updatePendingDeposits(); $this->writeln('Updated/checked ' . $updated . ' deposits'); $this->writeln('Realising payouts'); $payouts = $this->payoutManager->realisePayouts(); $this->writeln('Realised ' . count($payouts) . ' payouts'); $this->writeln('Checking round end'); $this->checkRoundEnd(); }
/** * @Route("/reset", name="reset") * @Template() */ public function resetAction() { $round = $this->roundRepo->findCurrent(); $this->getSession()->clear(); return $this->redirect($this->generateUrl('stats', ['round' => $round->getId()])); }