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

56 lines
1.8 KiB

<?php
namespace task\module\Pass;
use task\module\dm\Dm;
class Pass
{
/**
* 请求创建数据
* @param $requestData
* @param $url
* @param $host_path
* @return array|int[]
*/
public static function requestCreateData($requestData,$url,$host_path = '')
{
# 验证传输数据
if (empty($requestData) && is_array($requestData)) return ['status' => 0, 'msg' => 'requestData不能为空,且必须是数组'];
if (empty($url)) return ['status' => 0, 'msg' => 'url不能为空'];
# 获取请求路径
if (empty($host_path)) {
$config = config('api_config');
$host_path = $config['host_path'];
}
# 验证令牌
$token = '9c4cb25665cf08667c815420ab383cb5';
# 请求接口数据
$data = [
'data' => base64_encode(json_encode($requestData)),
'token' => md5($token . date('Ymd'))
];
$json_data = json_encode($data);
$createUrl = $host_path . $url;
# 发起请求
$result = post_token($createUrl,$json_data,false,[],$token);
$result = json_decode($result,true);
# 判断返回信息
if ($result['code'] != 1) return ['status' => 0, 'msg' => $result['msg']];
return ['status' => 1];
}
/**
* 获取统计组ID
* @param $dataType // 1 返回字符串 2 返回数组
* @return array|string
*/
public static function getGroupIds($dataType)
{
include '../module/dm/Dm.php';
$dm = new Dm();
$groupRes = $dm->select('bt_passenger_monitor_group',null,'"groupId"');
$groupIdArr = array_column($groupRes,'groupId') ?: [];
return $dataType == 2 ? $groupIdArr : implode(",",$groupIdArr);
}
}