体育管项目脚本
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.

99 lines
3.3 KiB

<?php
namespace task\tasks;
use task\module\Pass\Pass;
$Passall = new Passall();
echo $Passall->run();
class Passall
{
public function run()
{
include_once '../common.php';
include_once '../module/Pass/Pass.php';
$config = config('api_config');
$dateData = get_target_date();
$token = get_access_token();
$dateArr = [
'day' => [
'startTime' => $dateData['day']['c_start_time'],// 当天开始时间
'endTime' => date("c"),// 当天结束时间
'granularity' => 'daily'
],
'week' => [
'startTime' => $dateData['week']['c_start_time'],
'endTime' => date("c"),
'granularity' => 'daily'
],
'month' =>[
'startTime' => $dateData['month']['c_start_time'],
'endTime' => date("c"),
'granularity' => 'monthly'
],
'year' =>[
'startTime' => date("c",strtotime("-10 year")),
'endTime' => date("c",time()),
'granularity' => 'yearly'
]
];
$requestData = [];
try {
$ids = Pass::getRealGroupIds($config,$token,1);
foreach ($dateArr as $date => $value) {
$url = $config['host_url'] . "/api/cfas/v2/passengerFlow/groups";
$granularity = $value['granularity'];
$dataArr = [
'granularity' => $granularity,
'startTime' => $value['startTime'],
'endTime' => $value['endTime'],
'ids' => $ids
];
$json_data = json_encode($dataArr);
$result = post_token($url,$json_data,false,[],$token);
$res_data = json_decode($result,true);
if ($res_data['code'] != 0) throw new \Exception('请求失败');
$list = (array)$res_data['data']['list'];
foreach ($list as $val) {
$insert_arr = [
'groupId' => $val['groupId'],
'groupName' => $val['groupName'],
'flowInNum' => $val['flowInNum'],
'flowOutNum' => $val['flowOutNum'],
'noRepeatInNum' => $val['noRepeatInNum'],
'noRepeatOutNum' => $val['noRepeatOutNum'],
'holdValue' => $val['holdValue'],
'createTime' => $val['createTime'],
'updateTime' => $val['updateTime'],
'netValue' => $val['netValue'],
'statTime' => $val['statTime'],
'granularity' => $granularity,
'date' => $date,
];
$requestData[] = $insert_arr;
}
}
} catch (\Exception $e) {
return $e->getMessage();
}
$requestRes = Pass::requestCreateData($requestData,'/api/pass.create/createPassengerFlowAll', $config['host_path']);
if (!$requestRes['status']) {
return $requestRes['msg'];
}
return true;
}
}