public function init() { parent::init(); $this->user_sum = Totpredict::getUsersBalls(); $this->user_sum = Totuser::find()->orderBy('balance DESC')->all(); //Totpredict::getUsersStatus(); }
public function init() { parent::init(); $this->balance = Totpredict::find()->select('SUM(bet_balance)')->where(['user_id' => $this->user_id])->scalar(); $this->strict_predict = Totpredict::find()->select('COUNT(status)')->where(['user_id' => $this->user_id])->andWhere(['status' => 3])->scalar(); $this->result = Totpredict::find()->select('COUNT(status)')->where(['user_id' => $this->user_id])->andWhere(['status' => 2])->scalar(); $this->bad_predict = Totpredict::find()->select('COUNT(status)')->where(['user_id' => $this->user_id])->andWhere(['status' => 1])->scalar(); }
public function actionMakep() { if (!Totpredict::find()->where(['user_id' => 6, 'match_id' => Yii::$app->getRequest()->getQueryParam('match')])->one() && Yii::$app->getRequest()->getQueryParam('match') !== null) { $pred_comp = new Totpredict(); $pred_comp->match_id = Yii::$app->getRequest()->getQueryParam('match'); $pred_comp->user_id = 6; $pred_comp->host_g = mt_rand(0, 3); $pred_comp->guest_g = mt_rand(0, 3); $pred_comp->save(false); } if (Yii::$app->getRequest()->getQueryParam('host_g') !== null && Yii::$app->getRequest()->getQueryParam('guest_g') !== null) { $predict = new Totpredict(); $predict->guest_g = Yii::$app->getRequest()->getQueryParam('guest_g'); $predict->host_g = Yii::$app->getRequest()->getQueryParam('host_g'); $predict->user_id = Yii::$app->getRequest()->getQueryParam('user'); $predict->match_id = Yii::$app->getRequest()->getQueryParam('match'); if ($predict->save()) { return "<span style='color:green'>Прогноз сохранен</span>"; } else { return "<span style='color:red'>Ошибка сохранения</span>"; } } return "Ошибка"; }
public function actionPredicted($id) { $this->layout = '@app/themes/prognose/views/layouts/pagein'; //echo $id; exit; if ($this->userIfUserLegal($id)) { $predicted = Totpredict::find()->where(['user_id' => $this->current_user->id])->limit(20)->orderBy('id DESC')->all(); //var_dump($predicted); exit; //echo BetChempionWidget::widget(1); exit; return $this->render('stat', ['user' => $this->current_user, 'predicted' => $predicted]); } return $this->render('index'); }
/** * Проверка прогнозов * @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(); } } }