Пример #1
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Statistic the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Statistic::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #2
0
 public function actionStatistics()
 {
     $criteria = new CDbCriteria();
     $criteria->limit = 4;
     $criteria->order = 'date DESC';
     $criteria->condition = 'id_user='******'statistics', array('model' => $model));
 }
 public function getMongoCommand()
 {
     $commands = array();
     $map = new MongoCode("\n            function() {\n                var date = ISODate(this.dateCreate);\n                var key = {departureCityId: this.departureCityId, arrivalCityId: this.arrivalCityId };\n                emit(key, {count: 1});\n            };\n        ");
     $reduce = new MongoCode("function(key, values) {\n                var sum = 0;\n                values.forEach(function(value) {\n                    sum += value['count'];\n                });\n                return {count: sum};\n            };\n        ");
     $finalize = new MongoCode("function (key, value) {\n            return value['count']\n        }");
     $commands['mapreduce1'] = array("mapreduce" => Statistic::model()->getCollectionName(), "map" => $map, "reduce" => $reduce, "finalize" => $finalize, "query" => array("modelName" => "FlightSearch"), "out" => $this->result->getCollectionName());
     return $commands;
 }
Пример #4
0
 public function getMongoCommand()
 {
     $commands = array();
     $map = new MongoCode("\r\n            function() {\r\n                var date = ISODate(this.dateCreate);\r\n                var key = {date: date, searchId: this.searchId};\r\n                emit(key, {count: 1});\r\n            };\r\n        ");
     $reduce = new MongoCode("function(key, values) {\r\n                var sum = 0;\r\n                values.forEach(function(value) {\r\n                    sum += value['count'];\r\n                });\r\n                return {count: sum};\r\n            };\r\n        ");
     $commands['mapreduce1'] = array("mapreduce" => Statistic::model()->getCollectionName(), "map" => $map, "reduce" => $reduce, "query" => array("modelName" => "FlightSearch"), "out" => $this->result->getCollectionName());
     $map = new MongoCode("\r\n            function() {\r\n                var key = {year: this._id['date'].getFullYear(), month: this._id['date'].getMonth()+1, day: this._id['date'].getDate()};\r\n                emit(key, {count: 1});\r\n            };\r\n        ");
     $commands['mapreduce2'] = array("mapreduce" => $this->result->getCollectionName(), "map" => $map, "reduce" => $reduce, "out" => $this->result->getCollectionName());
     return $commands;
 }
Пример #5
0
 public function getStatus()
 {
     switch ($this->is_active) {
         case Referals::$NOT_ACTIVE:
             $txt = "Не активирован";
             break;
         case Referals::$ACTIVE:
             $statistic = Statistic::model()->findByAttributes(array('id_player' => $this->id_referal));
             $txt = "Активирован" . ", внес в систему: " . $statistic->invest_summ . ' руб.';
             break;
     }
     return $txt;
 }
Пример #6
0
 public function actionDownload($slug, $type)
 {
     $allUrls = new Url();
     $allUrls->resetClick();
     $file = File::model()->findByAttributes(array('slug' => $slug));
     if ($file) {
         $statistic = Statistic::model()->findBySql("SELECT * FROM " . Statistic::model()->tableName() . " WHERE file_id=" . $file->id . " ORDER BY id DESC LIMIT 1");
         $statistic->{$type} += 1;
         $statistic->save();
         if (count($file['url']) > 0) {
             foreach ($file['url'] as $url) {
                 if ($url->type == $type) {
                     $url->day_click += 1;
                     $url->month_click += 1;
                     $url->total += 1;
                     $url->save();
                     $this->redirect($url->url);
                 }
             }
         }
     } else {
         throw new CHttpException(404, 'The file requested  page does not exist.');
     }
 }
Пример #7
0
 public function actionResult()
 {
     $rc = Yii::app()->robokassa;
     // Коллбэк для события "оплата произведена"
     $rc->onSuccess = function ($event) {
         // Запишем в модель оплаты что оплата прошла
         $payForm = Yii::app()->robokassa->params['order'];
         $payForm->status = 'succes';
         $payForm->save();
         // получим пользователя из модели оплаты
         $player = Player::model()->findByPk($payForm->id_player);
         // Прибавим в статистике пользователя параметр инвестиции
         $statistic = Statistic::model()->findByAttributes(array('id_player' => $player->id));
         $statistic->invest_summ += $payForm->summ;
         $statistic->save();
         // Добавим пользователю сумму на счет оплаты !!!*1000!!!
         $player->setSummBuyPlus($payForm->summ);
         // Увеличим лемит вывода
         $current_summ_limit = $payForm->summ * 0.4;
         $player->setSummLimitPlus($current_summ_limit);
         // Получить реферала, если есть(?)
         $referal = Referals::model()->findByAttributes(array('id_referal' => $player->id));
         if ($referal != null) {
             // Получить пригласившего
             $parent_referal = Player::model()->findByAttributes(array('id' => $referal->id_player));
             // Получить статистику пригласившего и записать в базу
             $statistic_referal = Statistic::model()->findByAttributes(array('id_player' => $parent_referal->id));
             // Если еще не оплачивал, отметить что оплатил, добавить реферала в сумму рефералов прегласившего
             if ($referal->is_active == 0) {
                 $referal->is_active = 1;
                 $statistic_referal->referals += 1;
             }
             $summ_pay = $payForm->summ;
             $parent_referal->setReferalBonuses($summ_pay, $statistic_referal);
         }
     };
     // Коллбэк для события "отказ от оплаты"
     $rc->onFail = function ($event) {
         $InvId = Yii::app()->request->getParam('InvId');
         $payForm = Pays::model()->findByAttributes(array('id' => $InvId));
         if ($payForm != null) {
             $payForm->status = 'fail';
             $payForm->save();
         }
     };
     // Обработка ответа робокассы
     $rc->result();
 }
Пример #8
0
 public function addOut($player)
 {
     if ($player->activate_phone == Player::$ACTIVE_PHONE) {
         if ($this->validate()) {
             if ($player->getSummExit() >= $this->summ) {
                 if ($player->getSummLimit() >= $this->summ) {
                     $this->status = PaysOut::$STATUS_ADDING;
                     $this->sendAdminEmail($player);
                     $this->save();
                     $player->setSummExitPlus(-$this->summ);
                     $player->setSummLimitPlus(-$this->summ);
                     $statistic = Statistic::model()->findByAttributes(array('id_player' => $player->id));
                     $statistic->qut_summ += $this->summ;
                     $statistic->update();
                     return true;
                 } else {
                     $this->addError('info', "У вас не хватает средств на доступном балансе! Чтобы пополнить доступный баланс, читайте информацию ниже!");
                 }
             } else {
                 $this->addError('info', "У вас не хватает средств для вывода!");
             }
         }
     } else {
         $this->addError('info', "Вы должны подтвердить телефон, чтобы выводить деньги");
     }
     return false;
 }
Пример #9
0
 public function actionMyship()
 {
     $player = Player::model()->findByAttributes(array('email' => Yii::app()->user->id));
     $ship = Ship::model()->findByAttributes(array('id' => $player->id));
     $statistic = Statistic::model()->findByAttributes(array('id_player' => $player->id));
     $this->render('myship', array('player' => $player, 'ship' => $ship, 'statistic' => $statistic));
 }