Example #1
0
 /**
  * 广告展示详情
  */
 public function showadpvinfoAction()
 {
     $data = reqstr('data');
     // if (!$data) {
     // 	return;
     // }
     $page = reqnum('page', 1);
     $pagesize = 10;
     $data = urldecode($data);
     $info = array();
     parse_str($data, $info);
     $date = (int) $info['date'] ? (int) $info['date'] : 7;
     //默认是查出7天的数据
     $sdate = trim($info['sdate']) ? trim($info['sdate']) : '';
     $edate = trim($info['edate']) ? trim($info['edate']) : '';
     $station = (int) $info['station'] ? (int) $info['station'] : 0;
     // 0 表示查询出所有车站
     $adtype = trim($info['adtype']) ? trim($info['adtype']) : 'ad';
     //默认是广告1
     if (!$sdate || !$edate) {
         $edate = date('Y-m-d');
         $sdate = date('Y-m-d', strtotime("-{$date} day"));
     }
     //如果时间区间大于30天则按照30天计算
     $date_area = abs(strtotime($edate) - strtotime($sdate)) / 86400;
     if ($date_area > 30) {
         $sdate = date('Y-m-d', strtotime("-30 day"));
     }
     $sdate = str_replace('-', '_', $sdate);
     $edate = str_replace('-', '_', $edate);
     $nt = new Psys_StationModel();
     $data = $nt->ShowAdPvInfo($sdate, $edate, $station, $adtype, $page, $pagesize);
     $graphdata = $nt->ShowAdPvInfo($sdate, $edate, $station, $adtype, $page, $pagesize, 1);
     $paging = $this->paging($data['allnum'], $page, $pagesize, count($data['allrow']));
     /*------------------------------数据格式---------------------------------------------*/
     foreach ($data['allrow'] as $k => &$v) {
         $adname = $nt->GetAdName($v['detail']);
         $v['adname'] = $adname['adname'];
     }
     $nts = new Psys_ResourceModel();
     foreach ($graphdata['allrow'] as $v1) {
         $adinfo = $nt->GetAdName($v1['detail']);
         $x_date = $x_cat[] = date('m/d', strtotime(str_replace('_', '-', $v1['date'])));
         $eventrecordinfo = $nts->EventRecordInfo($v1['date'], 5, $station);
         //返回特殊点的提示信息
         if (!empty($eventrecordinfo)) {
             $title = $eventrecordinfo['title'];
             $descript = $eventrecordinfo['descript'];
         } else {
             $title = '';
             $descript = '';
         }
         $datas[$adinfo['id']]['infos']['date' . $x_date]['title'] = $title;
         $datas[$adinfo['id']]['infos']['date' . $x_date]['descript'] = $descript;
         if (empty($eventrecordinfo)) {
             $datas[$adinfo['id']]['data'][] = (int) $v1['num'];
         } else {
             $datas[$adinfo['id']]['data'][] = array('y' => (int) $v1['num'], 'marker' => array('fillColor' => '#FF0000', 'lineColor' => '#FF0000', 'states' => array('hover' => array('fillColor' => '#FF0000', 'lineColor' => '#FF0000'))));
             //设置当前点鼠标经过的颜色
         }
         $datas[$adinfo['id']]['name'] = $adinfo['adname'];
     }
     /*------------------------------chart数据格式需要索引从0开始---------------------------------------------*/
     $j = 0;
     foreach (array_unique($x_cat) as $v_x) {
         $result['x_cat'][$j] = $v_x;
         $j++;
     }
     $i = 0;
     foreach ($datas as $val) {
         $datass[$i] = $val;
         if ($i > 0) {
             $datass[$i]['visible'] = false;
         }
         $i++;
     }
     $result['y_cat'] = $datass;
     $stations = $nt->station();
     if ($station) {
         $stationname = $this->getstationname($stations, $station);
     } else {
         $stationname = '所有车站';
     }
     return array('table' => $data['allrow'], 'graph' => $result, 'paging' => $paging, 'station' => $stationname);
 }
Example #2
0
 /**
  * 手机品牌、浏览器、系统排行数据
  */
 public function mobilerankdataAction()
 {
     $data = reqstr('data');
     if (!$data) {
         return;
     }
     $page = reqnum('page', 1);
     $pagesize = 10;
     $data = urldecode($data);
     $info = array();
     parse_str($data, $info);
     $date = (int) $info['date'] ? (int) $info['date'] : 7;
     //默认是查出7天的数据
     $sdate = trim($info['sdate']) ? trim($info['sdate']) : '';
     $edate = trim($info['edate']) ? trim($info['edate']) : '';
     $station = (int) $info['station'] ? (int) $info['station'] : 0;
     // 0 表示查询出所有车站
     $type = trim($info['type']) ? trim($info['type']) : 'mobile';
     //默认是手机
     if (!$sdate || !$edate) {
         $edate = date('Y-m-d');
         $sdate = date('Y-m-d', strtotime("-{$date} day"));
     }
     $sdate = str_replace('-', '_', $sdate);
     $edate = str_replace('-', '_', $edate);
     $nt = new Psys_ResourceModel();
     $data = $nt->MobileRankData($sdate, $edate, $station, $type, $page, $pagesize);
     $data_graph = $nt->MobileRankData($sdate, $edate, $station, $type, $page, $pagesize, 1);
     $paging = $this->paging($data['allnum'], $page, $pagesize, count($data['allrow']));
     $stations = $nt->station();
     $total = 0;
     foreach ($data['allrow'] as &$v) {
         if ($station) {
             $v['stationname'] = $this->getstationname($stations, $station);
         } else {
             $v['stationname'] = 'ALL';
         }
         $total += $v['num'];
     }
     $phonebrand = array('mobile' => '手机品牌', 'browser' => '浏览器', 'sys' => '手机系统');
     $datas[0]['type'] = 'pie';
     $datas[0]['name'] = $phonebrand[$type] . '使用占比';
     foreach ($data_graph['allrow'] as $v1) {
         $datas[0]['data'][] = array($v1['name'], (double) round($v1['num'] / $total * 100, 2));
     }
     $result['y_cat'] = $datas;
     return array('table' => $data['allrow'], 'paging' => $paging, 'graph' => $result);
 }