Esempio n. 1
0
 /**
  * This command export heatmap result data.
  * @param string $filename the file to be imported to DB.
  */
 public function actionHeatmap($filename = 'heatmap.csv')
 {
     $file = Yii::$app->getRuntimePath() . DIRECTORY_SEPARATOR . 'exported_data' . DIRECTORY_SEPARATOR . $filename;
     $heatmap_records = \app\models\HeatMap::find()->where(['status' => \app\models\HeatMap::HEATMAP_VALID])->all();
     $all_mobiles = array();
     $fh = fopen($file, "w");
     fprintf($fh, "用户微信昵称,用户手机号,是否员工,提交时间\n");
     foreach ($heatmap_records as $heatmap) {
         $user = $heatmap->user;
         $staff = $user->staff;
         if (!empty($staff) && $staff->cat == \app\models\MStaff::SCENE_CAT_IN) {
         } else {
             $staff = $user->mobileStaff;
         }
         $mobiles = array();
         $bind_mobiles = $user->openidBindMobiles;
         if (!empty($bind_mobiles)) {
             foreach ($bind_mobiles as $bind_mobile) {
                 $mobiles[] = $bind_mobile->mobile;
             }
         }
         if (!empty(array_diff($mobiles, $all_mobiles))) {
             $all_mobiles = array_merge($all_mobiles, $mobiles);
             fprintf($fh, "%s,%s,%s,%s\n", $user->nickname, "[" . $user->getBindMobileNumbersStr() . "]", !empty($staff) ? "员工:{$staff->name}" : "否", $heatmap->create_time);
         }
     }
     fclose($fh);
     //        var_dump($all_mobiles);
 }
Esempio n. 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = HeatMap::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['heat_map_id' => $this->heat_map_id, 'lon' => $this->lon, 'lat' => $this->lat, 'speed_up' => $this->speed_up, 'speed_down' => $this->speed_down, 'speed_delay' => $this->speed_delay, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'gh_id', $this->gh_id])->andFilterWhere(['like', 'openid', $this->openid])->andFilterWhere(['like', 'pic_url', $this->pic_url]);
     return $dataProvider;
 }
Esempio n. 3
0
 public function getMySpeedDownRank()
 {
     return HeatMap::find()->where('gh_id=:gh_id AND speed_down>=:speed_down AND status=:status', [':gh_id' => $this->gh_id, ':speed_down' => $this->speed_down, ':status' => 0])->count();
 }
Esempio n. 4
0
 public function action4gspeedpic()
 {
     //$this->layout = 'wap';
     $this->layout = false;
     $gh_id = U::getSessionParam('gh_id');
     $openid = U::getSessionParam('openid');
     $model = MUser::findOne(['gh_id' => $gh_id, 'openid' => $openid]);
     Yii::$app->wx->setGhId($gh_id);
     $gh = Yii::$app->wx->getGh();
     $jssdk = new JSSDK($gh['appid'], $gh['appsecret']);
     $myPoints = HeatMap::find()->where(['gh_id' => $gh_id, 'openid' => $openid, 'status' => 0])->orderBy(['heat_map_id' => SORT_DESC])->all();
     if (!empty($myPoints)) {
         $myPoint = $myPoints[0];
     } else {
         $myPoint = null;
     }
     return $this->render('4gspeedpic', ['gh_id' => $gh_id, 'openid' => $openid, 'user' => $model, 'jssdk' => $jssdk, 'myPoint' => $myPoint]);
 }