/** * @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(); }