宝体数据调用接口
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.
 
 
 
 
 
 

68 lines
2.0 KiB

<?php
namespace app\common\model;
class Pass extends BaseModel
{
public static $unit = [1 => '>', 2 => '<', 3 => '=', 4 => '≥', 5 => '<=', 6 => '!='];
/**
* 馆舍客流情况-拥挤程度
* @param $proportion // 比例
* @return string
*/
public static function getPassType($proportion)
{
# 舒适:阈值<80%
if ($proportion < 0.8) {
return '舒适';
}
# 饱和:80%<阈值<100%
if (0.8 < $proportion || $proportion < 1) {
return '饱和';
}
# 拥挤:阈值=100%
if ($proportion == 1) {
return '拥挤';
}
# 拥挤:阈值=100%
if ($proportion >= 1.2) {
return '爆满';
}
return '';
}
/**
* 请求创建数据
* @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' => json_encode($requestData),
'token' => md5($token . date('Ymd'))
];
$json_data = json_encode($data);
$createUrl = $host_path . $url;
# 发起请求
$result = postToken($createUrl,$json_data,false,[],$token);
$result = json_decode($result,true);
# 判断返回信息
if ($result['code'] != 1) return ['status' => 0, 'msg' => $result['msg']];
return ['status' => 1];
}
}