/**
  * Prepares the data provider that should return the requested collection of the models.
  * @return ActiveDataProvider
  */
 protected function prepareDataProvider($starttime, $endtime, $channel, $platform, $server)
 {
     if ($this->prepareDataProvider !== null) {
         return call_user_func($this->prepareDataProvider, $this);
     }
     /* @var $modelClass \yii\db\BaseActiveRecord */
     $modelClass = $this->modelClass;
     $query = $modelClass::find();
     $query->select = ['ymd', 'SUM(dau) as dau', 'SUM(dau_adp) as dau_adp', 'SUM(dau_payp) as dau_payp', 'SUM(dau_npayp) as dau_npayp'];
     $query->andWhere(['>=', 'ymd', $starttime]);
     $query->andWhere(['<=', 'ymd', $endtime]);
     $query->andFilterWhere(['channel' => $channel]);
     $query->andFilterWhere(['platform' => $platform]);
     $query->andFilterWhere(['server' => $server]);
     $query->groupBy('ymd');
     $query->orderBy(['ymd' => SORT_ASC]);
     $response = ['max' => 0, 'categories' => [], 'series' => []];
     $data = $query->asArray()->all();
     $response['categories'] = array_column($data, 'ymd');
     $dau = Tools::fixedArrayToInterger(array_column($data, 'dau'));
     $response['series'][0] = ['name' => 'DAU', 'data' => $dau];
     $response['series'][1] = ['name' => '新增玩家', 'data' => Tools::fixedArrayToInterger(array_column($data, 'dau_adp'))];
     $response['series'][2] = ['name' => '付费玩家', 'data' => Tools::fixedArrayToInterger(array_column($data, 'dau_payp'))];
     $response['series'][3] = ['name' => '非付费玩家', 'data' => Tools::fixedArrayToInterger(array_column($data, 'dau_npayp'))];
     $response['max'] = empty($dau) ? 0 : max($dau);
     return $response;
 }
 /**
  * Prepares the data provider that should return the requested collection of the models.
  * @return ActiveDataProvider
  */
 protected function prepareDataProvider($starttime, $endtime, $channel, $platform, $server)
 {
     if ($this->prepareDataProvider !== null) {
         return call_user_func($this->prepareDataProvider, $this);
     }
     /* @var $modelClass \yii\db\BaseActiveRecord */
     $modelClass = $this->modelClass;
     $query = $modelClass::find();
     $query->select = ['FROM_UNIXTIME(logTime,"%Y-%m-%d %H:%i") as time', 'COUNT(1) as loginTimes'];
     $query->andFilterWhere(['FROM_UNIXTIME(logTime,"%Y%m%d")' => $endtime]);
     $query->andFilterWhere(['channel' => $channel]);
     $query->andFilterWhere(['platform' => $platform]);
     $query->andFilterWhere(['serverId' => $server]);
     $query->groupBy('time');
     $query->orderBy(['time' => SORT_ASC]);
     $resultData = $query->asArray()->all();
     $rawData = ArrayHelper::map($resultData, 'time', 'loginTimes');
     $data = Tools::fixStepMinute(Tools::fixedArrayToInterger($rawData));
     return array_values($data);
 }
 /**
  * Prepares the data provider that should return the requested collection of the models.
  * @return ActiveDataProvider
  */
 protected function prepareDataProvider($starttime, $endtime, $channel, $platform, $server)
 {
     if ($this->prepareDataProvider !== null) {
         return call_user_func($this->prepareDataProvider, $this);
     }
     /* @var $modelClass \yii\db\BaseActiveRecord */
     $modelClass = $this->modelClass;
     $query = $modelClass::find();
     $query->select = ['FROM_UNIXTIME(logTime,"%k") as hour', 'AVG(onlineNum) as onlineNum'];
     $query->andFilterWhere(['FROM_UNIXTIME(logTime,"%Y%m%d")' => $endtime]);
     $query->andFilterWhere(['channel' => $channel]);
     $query->andFilterWhere(['platform' => $platform]);
     $query->andFilterWhere(['serverId' => $server]);
     $query->groupBy('hour');
     $query->orderBy(['hour' => SORT_ASC]);
     $resultData = $query->asArray()->all();
     $rawData = ArrayHelper::map($resultData, 'hour', 'onlineNum');
     $data = Tools::fixStepHour($rawData);
     return array_values($data);
 }
 /**
  * Prepares the data provider that should return the requested collection of the models.
  * @return ActiveDataProvider
  */
 protected function prepareDataProvider($starttime, $endtime, $channel, $platform, $server)
 {
     if ($this->prepareDataProvider !== null) {
         return call_user_func($this->prepareDataProvider, $this);
     }
     /* @var $modelClass \yii\db\BaseActiveRecord */
     $modelClass = $this->modelClass;
     $query = $modelClass::find();
     $query->select = ['FROM_UNIXTIME(logTime,"%Y%m%d") as ymd', 'AVG(onlineNum) as acu', 'MAX(onlineNum) as pcu'];
     $query->andWhere(['>=', 'FROM_UNIXTIME("%Y-%m-%d",logTime)', $starttime]);
     $query->andWhere(['<=', 'FROM_UNIXTIME("%Y-%m-%d",logTime)', $endtime]);
     $query->andFilterWhere(['FROM_UNIXTIME(logTime,"%Y%m%d")' => $endtime]);
     $query->andFilterWhere(['channel' => $channel]);
     $query->andFilterWhere(['platform' => $platform]);
     $query->andFilterWhere(['serverId' => $server]);
     $query->groupBy('ymd');
     $query->orderBy(['ymd' => SORT_ASC]);
     $resultData = $query->asArray()->all();
     $acu = ArrayHelper::map($resultData, 'ymd', 'acu');
     $pcu = ArrayHelper::map($resultData, 'ymd', 'pcu');
     $data = ['acu' => array_values(Tools::fixStepDay($acu, $starttime, $endtime)), 'pcu' => array_values(Tools::fixStepDay($pcu, $starttime, $endtime))];
     return $data;
 }