/** * @return bool */ public static function updateDotaDraftPrizes() { // 1. получить список активных фантазий (активность из event) $events = DotaEvent::getActualEventsList(); $event_ids = ArrayHelper::map($events, 'id', 'id'); $fantasies = DotaFantasy::getActiveFantasies($event_ids); echo '<pre>'; print_r($fantasies); echo '</pre>'; //die; $DotaDraft = new DotaDraft(); foreach ($fantasies as $fantasy) { $fantasyModel = DotaFantasy::findOne($fantasy['id']); $stat_heroes_on_event = DotaEventHeroStat::isPresentHeroesStatInEvent($fantasyModel->event_id); $stat_players_on_event = DotaEventPlayerStat::isPresentPlayersStatInEvent($fantasyModel->event_id); //echo'<pre>';print_r($fantasyModel->name);echo'</pre>';//die; //echo'<pre>';var_dump($stat_heroes_on_event);echo'</pre>';//die; //echo'<pre>';var_dump($stat_players_on_event);echo'</pre>';//die; //если статистики по матчам еще нет - дальше не обрабатываем if (DotaEventHeroStat::isPresentHeroesStatInEvent($fantasyModel->event_id) === false && DotaEventPlayerStat::isPresentPlayersStatInEvent($fantasyModel->event_id) === false) { continue; } //echo'<pre>';print_r($fantasy_id);echo'</pre>';die; $DotaFantasy = new DotaFantasy(); $places = $DotaFantasy->calculatePlacesInFantasy($fantasyModel); //echo'<pre>';print_r($places);echo'</pre>';//die; //проверка корректности расчета процентов по выйгрышу //if(PrizeMatrix::calculationIsCorrect($places) === false) return 1; $prizes = $DotaFantasy->calculatePrizesInFantasy($fantasyModel, $places); echo '<pre>'; print_r($prizes); echo '</pre>'; //die; //проверка корректности расчета сумм по выйгрышу //if(PrizeMatrix::calculationIsCorrect($places, $fantasyModel->prize_pool) === false) return 2; $DotaDraft->updatePrizeValues($prizes, $fantasy['id']); /* foreach($prizes as $user_id=>$value) { $values = [ 'prize' => $value, ]; $where = [ 'fantasy_id = ' . $fantasy['id'], 'user_id = ' . $user_id, ]; $DotaDraft->updateRow($values, $where); } */ } //die; return true; }