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

88 lines
2.9 KiB

<?php
namespace task\tasks;
include 'Base.php';
class Pass extends Base
{
public function run()
{
$config = $this->config('api_config');
$dateData = $this->get_target_date();
$token = $this->get_access_token();
$arr = [
'hourly' => [
'startTime' => $dateData['day']['c_start_time'],
'endTime' => date('c',time()),
],
'daily' => [
'startTime' => $dateData['month']['c_start_time'],
'endTime' => date('c',time()),
],
'monthly' => [
'startTime' => $dateData['year']['c_start_time'],
'endTime' => date('c'),
]
];
$url = $config['host_url'] . "/api/cfas/v2/passengerFlow/groups";
$requestData = [];
try {
$ids = $this->get_real_group_ids($config,$token,1);
foreach ($arr as $granularity => $value) {
$dataArr = [
'granularity' => $granularity,
'startTime' => $value['startTime'],
'endTime' => $value['endTime'],
'ids' => $ids
];
$json_data = json_encode($dataArr);
$result = $this->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'] ?: 0,
'flowOutNum' => $val['flowOutNum'] ?: 0,
'noRepeatInNum' => $val['noRepeatInNum'] ?: 0,
'noRepeatOutNum' => $val['noRepeatOutNum'] ?: 0,
'holdValue' => $val['holdValue'] ?: 0,
'createTime' => $val['createTime'],
'updateTime' => $val['updateTime'],
'netValue' => $val['netValue'] ?: 0,
'statTime' => $val['statTime'],
'granularity' => $granularity,
];
$requestData[] = $insert_arr;
}
}
} catch (\Exception $e) {
return $e->getMessage();
}
$requestRes = $this->request_create_data($requestData,'/api/pass.create/createPassengerFlow', $config['host_path']);
if (!$requestRes['status']) {
return $requestRes['msg'];
}
return true;
}
}
$pass = new Pass();
echo $pass->run();
$pass = new Pass();
echo $pass->run();