Exemplo n.º 1
0
 /**
  * Прогноз
  * @param $id
  * @return string
  */
 public function actionPrognose($id)
 {
     $this->layout = '@app/themes/prognose/views/layouts/pagein';
     if ($this->userIfUserLegal($id)) {
         $now_id = 1;
         $users_predicted_matches = implode(',', ArrayHelper::map(Totpredict::find()->where(['user_id' => $this->current_user->id])->all(), 'id', 'match_id'));
         $all = Totmatch::find()->all();
         foreach ($all as $one) {
             /*echo date('Y-m-d H:i:s', Totmatch::formatMatchDateToTime(explode(' ', $one->date)[0]))." "
                   .Totmatch::formatMatchDateToTime(explode(' ', $one->date)[0])." ".time()."<br>";
               var_dump(Totmatch::formatMatchDateToTime(explode(' ', $one->date)[0]) >= time());
               */
             if (Totmatch::formatMatchDateToTime(explode(' ', $one->date)[0]) + 36000 <= time()) {
                 $now_id = $one->id;
             }
         }
         if ($users_predicted_matches) {
             $match_list = Totmatch::find()->where("id NOT IN (" . $users_predicted_matches . ") AND id > " . $now_id)->all();
         } else {
             $match_list = Totmatch::find()->where("id > " . $now_id)->all();
         }
         return $this->render('group', ['user' => $this->current_user, 'match_list' => $match_list]);
     }
     return $this->render('index');
 }
Exemplo n.º 2
0
 /**
  * Прогноз
  * @return string
  */
 public function actionPrognose()
 {
     if (Yii::$app->getRequest()->getQueryParam('login') && Yii::$app->getRequest()->getQueryParam('pseudo')) {
         $name = Yii::$app->getRequest()->getQueryParam('login');
         $pseudo = Yii::$app->getRequest()->getQueryParam('pseudo');
         $user = Totuser::find()->where("name like('%" . $name . "') and pseudo like('" . $pseudo . "')")->one();
         if ($user) {
             //$now_id = 1;
             $users_predicted_matches = implode(',', ArrayHelper::map(Totpredict::find()->where(['user_id' => $user->id])->all(), 'id', 'match_id'));
             /*$all = Totmatch::find()->all();
                             foreach ($all as $one) {
             
                                 if (Totmatch::formatMatchDateToTime(explode(' ', $one->date)[0]) + 36000 <= time()) {
                                     $now_id = Totmatch::formatMatchDateToTime(explode(' ', $one->date)[0]);
             
                                 }
                             }
                             */
             $tomorrow = date('d.m.Y', time() + 24 * 3600);
             $day_after_tomorrow = date('d.m.Y', time() + 2 * 24 * 3600);
             if ($users_predicted_matches) {
                 $match_list = Totmatch::find()->where("id NOT IN (" . $users_predicted_matches . ") AND (date like '" . $tomorrow . "%' OR date like '" . $day_after_tomorrow . "%')")->all();
             } else {
                 $match_list = Totmatch::find()->where("date like '" . $tomorrow . "%' OR date like '" . $day_after_tomorrow . "%' ")->all();
             }
             //var_dump($match_list); exit;
             return $this->render('group', ['user' => $user, 'match_list' => $match_list]);
         }
         echo 'no';
     }
 }
Exemplo n.º 3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getMatch()
 {
     return $this->hasOne(Totmatch::className(), ['id' => 'match_id']);
 }
Exemplo n.º 4
0
 /**
  * Проверка прогнозов
  * @throws \Exception
  */
 public function actionMarkPredictedMatches()
 {
     $day = date('d.m.Y', time() - 24 * 3600);
     $day_before = date('d.m.Y', time() - 24 * 3600 * 2);
     $predicted = Totmatch::find()->where(['foo_match_id' => 1])->andWhere("date like ('" . $day . "%') or date like ('" . $day_before . "%')")->all();
     // var_dump($predicted); exit;
     foreach ($predicted as $match) {
         $date = explode(" ", $match->date);
         try {
             $d = $date[0];
         } catch (\ErrorException $e) {
             $d = '';
         }
         //echo $d; exit;
         $m = Matches::find()->where("host like('_" . $match->host . "') and guest like('" . $match->guest . "_') and date like('" . $d . "')")->one();
         //var_dump($match->guest); exit;
         if ($m) {
             echo $m->id . PHP_EOL;
             //exit;
             $match->foo_match_id = $m->id;
             $match->update();
         } else {
             continue;
         }
         $tested = Totpredict::find()->where(['match_id' => $match->id])->all();
         foreach ($tested as $play) {
             //var_dump($play->host_g);
             //var_dump($m->gett);
             //var_dump($play->guest_g);
             //var_dump($m->lett);
             if ($play->host_g == $m->gett && $play->guest_g == $m->lett && ($m->prim !== ' После серии пенальти' && $m->prim !== ' После дополнительного времени')) {
                 $play->status = Totpredict::STATUS_RIGHT_SCORE;
                 $play->bet_balance = $this->getMatchBet($m->gett, $m->lett, $m->bet_h, $m->bet_n, $m->bet_g);
                 $play->update();
             } elseif ($play->host_g == $play->guest_g && ($m->lett == $play->host_g || $m->gett == $play->guest_g) && ($m->prim == ' После серии пенальти' || $m->prim == ' После дополнительного времени')) {
                 var_dump($play);
                 $play->status = Totpredict::STATUS_RIGHT_SCORE;
                 $play->bet_balance = $this->getMatchBet(1, 1, $m->bet_h, $m->bet_n, $m->bet_g);
                 $play->update();
             } elseif ($play->host_g == $play->guest_g && ($m->prim == ' После серии пенальти' || $m->prim == ' После дополнительного времени')) {
                 var_dump($play);
                 $play->status = Totpredict::STATUS_RIGHT_RESULT;
                 $play->bet_balance = $this->getMatchBet(1, 1, $m->bet_h, $m->bet_n, $m->bet_g);
                 $play->update();
             } elseif ($play->host_g != $play->guest_g && ($m->prim == ' После серии пенальти' || $m->prim == ' После дополнительного времени')) {
                 var_dump($play);
                 $play->status = Totpredict::STATUS_BAD_PROGNOSE;
                 $play->bet_balance = -1;
                 $play->update();
             } elseif ($play->host_g > $play->guest_g && $m->gett > $m->lett || $play->host_g == $play->guest_g && $m->gett == $m->lett || $play->host_g < $play->guest_g && $m->gett < $m->lett) {
                 $play->status = Totpredict::STATUS_RIGHT_RESULT;
                 $play->bet_balance = $this->getMatchBet($m->gett, $m->lett, $m->bet_h, $m->bet_n, $m->bet_g);
                 $play->update();
             } else {
                 $play->status = Totpredict::STATUS_BAD_PROGNOSE;
                 $play->bet_balance = -1;
                 $play->update();
             }
         }
         try {
             Totpredict::getUsersStatus();
         } catch (\ErrorException $e) {
             echo $e->getMessage();
         }
     }
 }
Exemplo n.º 5
0
 /**
  * Генерируем матчи для прогнозов
  */
 public function actionPrognosematch()
 {
     $content = file_get_contents('/home/romanych/my/Моё/матчи2.txt');
     //$cont = explode('[block]', $content);
     $con = explode(PHP_EOL, $content);
     //var_dump($con); exit;
     $i = 0;
     $this->tournament = '';
     $chempionship = '';
     foreach ($con as $match) {
         $match_arr = explode(' ', $this->clearMatchString($match));
         //var_dump($match_arr);
         $play = new Totmatch();
         if ($i == 0) {
             $chempionship = $match;
         }
         if (isset($match_arr[0]) && $match_arr[0] == "Тур") {
             $this->tournament = $chempionship . " " . $match;
         } else {
             try {
                 $play->date = $match_arr[0] . "2017 " . $match_arr[1];
                 $play->host = $this->backTeamString($match_arr[2]);
                 $play->guest = $this->backTeamString($match_arr[3]);
                 $play->tournament = $this->tournament;
                 $play->foo_match_id = 1;
                 //var_dump($play);
                 $play->save();
             } catch (\ErrorException $e) {
                 $i++;
                 continue;
             }
         }
         $i++;
         //echo $this->tournament;
     }
 }