| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <?php
- namespace App\Servers\Wenlv;
- use \Exception;
- /**
- * 获取景点信息API接口
- * @author 唐远望
- * @version 1.0
- * @date 2026-01-06
- */
- class ScenicArea
- {
- private $app_key;
- private $app_id;
- private $app_secret;
- private $header;
- private $baseUrl = 'https://jt-open-platform.jt-health.cn/management/api';
- /**
- * 构造函数
- * @throws Exception 当API密钥未设置时抛出异常
- *
- */
- public function __construct()
- {
- $time_string = date('Y-m-d', time());
- $this->header = [
- 'time_string:' . $time_string,
- ];
- }
- /**
- * 发送http post请求
- * @param string $url 请求地址
- * @param array $headers 请求头
- * @param json $postdata 请求数据
- * @param array $options curl配置项
- */
- public static function curl_post($url = '', $headers = '', $postdata = '', $options = array())
- {
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- if (!empty($headers)) {
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- }
- if (!empty($options)) {
- curl_setopt_array($ch, $options);
- }
- $data = curl_exec($ch);
- return $data;
- }
- /**
- * 发送http get请求
- */
- public static function curl_get($url = '', $headers = '', $options = array())
- {
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 5);
- if (!empty($headers)) {
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- }
- if (!empty($options)) {
- curl_setopt_array($ch, $options);
- }
- $data = curl_exec($ch);
- return $data;
- }
- /**
- * 提交设备采样数据接口
- * @author 唐远望
- * @version 1.0
- * @date 2026-01-06
- */
- public function submitDeviceData($request_data)
- {
- $url = $this->baseUrl . '/report/submitReport';
- $response = self::curl_post($url, $this->header, json_encode($request_data));
- $response_data = json_decode($response, true);
- return $response_data;
- }
- /**
- * 获取报告接口
- * @author 唐远望
- * @version 1.0
- * @date 2026-01-06
- */
- public function getReport($request_data)
- {
- $url = $this->baseUrl . '/report/getReport';
- $response = self::curl_post($url, $this->header, json_encode($request_data));
- $response_data = json_decode($response, true);
- return $response_data;
- }
- /**
- * 获取报告18大风险对应的商品推荐
- * @author 唐远望
- * @version 1.0
- * @date 2026-01-06
- */
- public function getDeviceData($request_data)
- {
- $url = $this->baseUrl . '/report/getRiskCommodityList';
- $response = self::curl_post($url, $this->header, json_encode($request_data));
- $response_data = json_decode($response, true);
- return $response_data;
- }
- /**
- * 体质卡兑换
- * @author 唐远望
- * @version 1.0
- * @date 2026-01-06
- */
- public function exchangeHealthCard($request_data)
- {
- $url = $this->baseUrl . '/physiqueCard/exchangePhysiqueCard';
- $response = self::curl_post($url, $this->header, json_encode($request_data));
- $response_data = json_decode($response, true);
- return $response_data;
- }
- /**
- * 获取近两天报告
- * @author 唐远望
- * @version 1.0
- * @date 2026-01-06
- */
- public function getTwoDayReport($request_data)
- {
- $url = $this->baseUrl . '/report/getDaysReportsList';
- $response = self::curl_post($url, $this->header, json_encode($request_data));
- $response_data = json_decode($response, true);
- return $response_data;
- }
- /**
- * 获取近一周报告
- * @author 唐远望
- * @version 1.0
- * @date 2026-01-06
- */
- public function getOneWeekReport($request_data)
- {
- $url = $this->baseUrl . '/report/getWeeksReportsList';
- $response = self::curl_post($url, $this->header, json_encode($request_data));
- $response_data = json_decode($response, true);
- return $response_data;
- }
- /**
- * 两笔报告对比
- * @author 唐远望
- * @version 1.0
- * @date 2026-01-06
- */
- public function compareTwoReport($request_data)
- {
- $url = $this->baseUrl . '/report/getReportContrast';
- $response = self::curl_post($url, $this->header, json_encode($request_data));
- $response_data = json_decode($response, true);
- return $response_data;
- }
- /**
- * 激活设备
- * @author 唐远望
- * @version 1.0
- * @date 2026-01-08
- */
- public function activateDevice($request_data){
- $url = $this->baseUrl . '/report/activateCode';
- $response = self::curl_post($url, $this->header, json_encode($request_data));
- $response_data = json_decode($response, true);
- return $response_data;
- }
- /**
- * 获取设备信息
- * @author 唐远望
- * @version 1.0
- * @date 2026-01-08
- */
- public function getDeviceInfo($request_data){
- $url = $this->baseUrl . '/report/getDeviceInfo';
- $response = self::curl_post($url, $this->header, json_encode($request_data));
- $response_data = json_decode($response, true);
- return $response_data;
- }
- }
|