Browse Source

优化脚本返回

master
wanghongjun 3 years ago
parent
commit
cfcf3329c1
  1. 8
      source/application/common.php
  2. 7
      source/application/task/controller/Pass.php
  3. 4
      source/application/task/controller/Passall.php
  4. 4
      source/application/task/controller/Passreal.php

8
source/application/common.php

@ -2,6 +2,7 @@
// 应用公共函数库文件 // 应用公共函数库文件
use think\Cache;
use think\Request; use think\Request;
use think\Log; use think\Log;
@ -451,17 +452,18 @@ function getTargetDate($granularity = 'all') {
*/ */
function getAccessToken(){ function getAccessToken(){
$token = \think\Session::get('apiAccessToken'); // 记录缓存, 时效2小时分钟
$token = Cache::get('api_access_token');
if (empty($token)) { if (empty($token)) {
$config = config('api_config'); $config = config('api_config');
// //
$url = $config['host_url']."/oauth/token?client_id=".$config['cid']."&client_secret=".$config['cskey']; $url = $config['host_url']."/oauth/token?client_id=".$config['cid']."&client_secret=".$config['cskey'];
// do post // do post
$ret = curl($url); $ret = curlPost($url);
$res = json_decode($ret,true); $res = json_decode($ret,true);
if ($res['access_token']) { if ($res['access_token']) {
\think\Session::set('apiAccessToken',$res['access_token']); Cache::set('api_access_token', $res['access_token'], 7200);
$token = $res['access_token']; $token = $res['access_token'];
} }
} }

7
source/application/task/controller/PassengerFlow.php → source/application/task/controller/Pass.php

@ -4,7 +4,7 @@ namespace app\task\controller;
use think\Db; use think\Db;
class PassengerFlow class Pass
{ {
/** /**
* 执行函数 * 执行函数
@ -21,11 +21,11 @@ class PassengerFlow
$arr = [ $arr = [
'hourly' => [ 'hourly' => [
'startTime' => $dateData['day']['c_start_time'], 'startTime' => $dateData['day']['c_start_time'],
'endTime' => $dateData['day']['c_end_time'], 'endTime' => date('c',time()),
], ],
'daily' => [ 'daily' => [
'startTime' => $dateData['month']['c_start_time'], 'startTime' => $dateData['month']['c_start_time'],
'endTime' => $dateData['month']['c_end_time'], 'endTime' => date('c',time()),
], ],
'monthly' => [ 'monthly' => [
'startTime' => $dateData['year']['c_start_time'], 'startTime' => $dateData['year']['c_start_time'],
@ -76,6 +76,7 @@ class PassengerFlow
} }
} catch (\Exception $e) { } catch (\Exception $e) {
exit( $e->getMessage() );
} }
return true; return true;

4
source/application/task/controller/PassengerFlowAll.php → source/application/task/controller/Passall.php

@ -4,7 +4,7 @@ namespace app\task\controller;
use think\Db; use think\Db;
class PassengerFlowAll class passall
{ {
/** /**
* 执行函数 * 执行函数
@ -81,7 +81,7 @@ class PassengerFlowAll
} }
} catch (\Exception $e) { } catch (\Exception $e) {
exit( $e->getMessage() );
} }
return true; return true;

4
source/application/task/controller/PassengerFlowReal.php → source/application/task/controller/Passreal.php

@ -4,7 +4,7 @@ namespace app\task\controller;
use think\Db; use think\Db;
class PassengerFlowReal class Passreal
{ {
/** /**
* 执行函数 * 执行函数
@ -51,7 +51,7 @@ class PassengerFlowReal
} }
} catch (\Exception $e) { } catch (\Exception $e) {
exit( $e->getMessage() );
} }
return true; return true;
Loading…
Cancel
Save