You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
147 lines
5.2 KiB
147 lines
5.2 KiB
<?php
|
|
namespace app\controller;
|
|
|
|
use app\BaseController;
|
|
|
|
class Index extends BaseController
|
|
{
|
|
public function index()
|
|
{
|
|
return phpinfo();
|
|
//return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:) </h1><p> ThinkPHP V' . \think\facade\App::version() . '<br/><span style="font-size:30px;">14载初心不改 - 你值得信赖的PHP框架</span></p><span style="font-size:25px;">[ V6.0 版本由 <a href="https://www.yisu.com/" target="yisu">亿速云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="https://tajs.qq.com/stats?sId=64890268" charset="UTF-8"></script><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="ee9b1aa918103c4fc"></think>';
|
|
}
|
|
|
|
public function hello($name = 'ThinkPHP6')
|
|
{
|
|
return 'hello,' . $name;
|
|
}
|
|
|
|
public function getAccessToken(){
|
|
$config = config('app');
|
|
//
|
|
$url = $config['host_url']."/oauth/token?client_id=".$config['cid']."&client_secret=".$config['cskey'];
|
|
// do post
|
|
$ret = post($url);
|
|
|
|
return $ret;
|
|
}
|
|
|
|
/**
|
|
* 总览总数据接口
|
|
* @return array
|
|
*/
|
|
public function allGroupNum() {
|
|
|
|
$config = config('app');
|
|
|
|
$dayStatTime = date('c',strtotime(date("Y-m-d 00:00:00")));
|
|
$monday = date('Y-m-d 00:00:00', strtotime("last Monday", strtotime(date('Y-m-d'))));
|
|
$weekStatTime = date('c',strtotime($monday));
|
|
$monthStatTime = date('c',strtotime(date("Y-m-01 00:00:00")));
|
|
$dateArr = ['day' => $dayStatTime, 'week' => $weekStatTime, 'month' => $monthStatTime];
|
|
|
|
$returnData = [];
|
|
foreach ($dateArr as $date => $statTime) {
|
|
|
|
$url = $config['host_url'] . "/api/cfas/v2/passengerFlow/allGroup";
|
|
|
|
$granularity = $date == 'month' ? 'monthly' : 'daily';
|
|
|
|
$data = [
|
|
'granularity' => $granularity,
|
|
'statTime' => $statTime
|
|
];
|
|
|
|
$json_data = json_encode($data);
|
|
$result = postToken($url,$json_data,false,[],'60NDtZnTUiPtXEFC2MAszjZ9fbedfBTQ');
|
|
$res_data = json_decode($result,true);
|
|
|
|
if ($res_data['code'] != 0) {
|
|
return ['code' => 404, 'msg' => $res_data['msg']];
|
|
}
|
|
|
|
$list = $res_data['data']['list'];
|
|
|
|
$returnData[$date]['flowInNum'] = 0;
|
|
foreach ($list as $value) {
|
|
$returnData[$date]['flowInNum'] += $value['flowInNum'];
|
|
}
|
|
}
|
|
|
|
|
|
return ['code' => 0, 'data' => $returnData];
|
|
}
|
|
|
|
/**
|
|
* 进馆人数趋势
|
|
* @return array|void
|
|
*/
|
|
public function groups() {
|
|
|
|
$config = config('app');
|
|
|
|
$dateData = getTargetDate();
|
|
|
|
$dateArr = [
|
|
'day' => [
|
|
'startTime' => $dateData['day']['c_start_time'],// 当天开始时间
|
|
'endTime' => $dateData['day']['c_end_time'],// 当天结束时间
|
|
'granularity' => 'daily'
|
|
],
|
|
'week' => [
|
|
'startTime' => $dateData['week']['c_start_time'],
|
|
'endTime' => $dateData['week']['c_end_time'],
|
|
'granularity' => 'daily'
|
|
],
|
|
'month' =>[
|
|
'startTime' => $dateData['month']['c_start_time'],
|
|
'endTime' => $dateData['month']['c_end_time'],
|
|
'granularity' => 'monthly'
|
|
],
|
|
'year' =>[
|
|
'startTime' => $dateData['year']['c_start_time'],
|
|
'endTime' => $dateData['year']['c_end_time'],
|
|
'granularity' => 'yearly'
|
|
],
|
|
|
|
];
|
|
|
|
$returnData = [];
|
|
foreach ($dateArr as $date => $dateRow) {
|
|
|
|
$url = $config['host_url'] . "/api/cfas/v2/passengerFlow/groups";
|
|
|
|
$granularity = $dateRow['granularity'];
|
|
|
|
$data = [
|
|
'granularity' => $granularity,
|
|
'startTime' => $dateRow['startTime'],
|
|
'endTime' => $dateRow['endTime'],
|
|
'ids' => '01'
|
|
];
|
|
|
|
$json_data = json_encode($data);
|
|
$result = postToken($url,$json_data,false,[],'rqhzG171BROnwBhhcZJJDudZ4vdvC3nm');
|
|
|
|
$res_data = json_decode($result,true);
|
|
if ($res_data['code'] != 0) {
|
|
return ['code' => 404, 'msg' => $res_data['msg']];
|
|
}
|
|
|
|
$list = $res_data['data']['list'];
|
|
|
|
$returnData[$date]['flowInNum'] = 0;
|
|
foreach ($list as $value) {
|
|
// $createTime = date("H",$value['createTime'] /1000 + (3600*8));
|
|
$returnData[$date]['flowInNum'] += $value['flowInNum'];
|
|
}
|
|
}
|
|
|
|
foreach ($returnData as &$val) {
|
|
$val['flowInNum'] = formatNumber($val['flowInNum']);
|
|
}
|
|
|
|
return json_encode($returnData);
|
|
}
|
|
|
|
}
|
|
|