123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
- <?php
- namespace app\admin\api;
- use OneSm\Sm4;
- class DataApi{
- public $guid;
- public function __construct()
- {
- $this->getGuid();
- }
- protected function getGuid(){
- $options = [
- 'cache_wsdl' => WSDL_CACHE_NONE,
- 'trace' => 1,
- 'stream_context' => stream_context_create(
- [
- 'ssl' => [
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- ]
- ]
- )
- ];
- $redis = \app\common\Redis::instance(\think\facade\Config::get("cache.stores.redis.select"));
- $guid= $redis->get("jjdata_guid");
- if(!$guid || empty($guid)) {
- $client = new \SoapClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/Authentication?wsdl", $options);
- $param = [
- 'userid' => 'jjswzzb_sbxt',
- 'password' => 'sbxt@2022'
- ];
- $rst = $client->loginByAccount($param);
- $ret = json_decode($rst->return, true);
- if($ret['code'] == '01'){
- $this->guid = $ret['data'];
- $redis->set("jjdata_guid",$this->guid,1700);
- }else{
- $this->guid = '';
- }
- }else{
- $this->guid = $guid;
- }
- }
- public function getClient($url){
- $this->getGuid();
- $options = [
- 'cache_wsdl' => WSDL_CACHE_NONE,
- 'trace' => 1,
- 'stream_context' => stream_context_create(
- [
- 'ssl' => [
- 'verify_peer' => false,
- 'verify_peer_name' => false,
- 'allow_self_signed' => true
- ]
- ]
- )
- ];
- $client = new \SoapClient($url, $options);
- return $client;
- }
- public function queryUnemploymentInsuranceByIdAndTime($card,$start,$end){
- $client = $this->getClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/InsuranceRecordSearch?wsdl");
- $param = [
- 'guid' => $this->guid,
- 'requestid' => 'null_00001',
- 'id' => $card,
- 'startTime' => $start,
- 'endTime' => $end
- ];
- $rst = $client->queryUnemploymentInsuranceByIdAndTime($param);
- $ret = json_decode($rst->return, true);
- if($ret['code'] == '01'){
- return $ret;
- }else{
- return false;
- }
- }
- public function IDNumber($realname,$birthday){
- $client = $this->getClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/InsuranceRecordSearchs?wsdl");
- $param = [
- 'guid' => $this->guid,
- 'requestid' => 'null_00001',
- 'aac003' => $realname,
- 'bac504' => $birthday
- ];
- $rst = $client->IDNumber($param);
- $ret = json_decode($rst->return, true);
- if($ret['code'] == '01'){
- return $ret;
- }else{
- return false;
- }
- }
- public function queryOldAgeSecurityInsuranceByIdAndTime($card,$start,$end){
- $client = $this->getClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/InsuranceRecordSearch?wsdl");
- $param = [
- 'guid' => $this->guid,
- 'requestid' => 'null_00001',
- 'id' => $card,
- 'startTime' => $start,
- 'endTime' => $end
- ];
- $rst = $client->queryOldAgeSecurityInsuranceByIdAndTime($param);
- $ret = json_decode($rst->return, true);
- if($ret['code'] == '01'){
- return $ret;
- }else{
- return false;
- }
- }
- public function queryJfhbxxByYears($card,$name,$years){
- $client = $this->getClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/CityBrain?wsdl");
- $param = [
- 'guid' => $this->guid,
- 'requestid' => 'null_00001',
- 'reason' => "测试",
- 'optIDCard' => "350582199006028550",
- 'optName' => "郑明炜",
- 'optIp' => get_client_ip(),
- 'optMac' => "00-D8-61-73-14-EC",
- 'IDCard' => $card,
- 'name' => $name,
- 'years' => $years
- ];
- $rst = $client->queryJfhbxxByYears($param);
- $ret = json_decode($rst->return, true);
- $ret = json_decode($ret, true);
- if($ret['code'] == '01'){
- return $ret;
- }else{
- return false;
- }
- }
- public function untrustworthyPersonnel($card){
- $client = $this->getClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/CityBrain?wsdl");
- $param = [
- 'guid' => $this->guid,
- 'requestid' => 'null_00001',
- 'reason' => "测试",
- 'optIDCard' => "350582199006028550",
- 'optName' => "郑明炜",
- 'optIp' => get_client_ip(),
- 'optMac' => "00-D8-61-73-14-EC",
- 'IDCard' => $card
- ];
- $rst = $client->untrustworthyPersonnel($param);
- $ret = json_decode($rst->return, true);
- $ret = json_decode($ret, true);
- if($ret['code'] == '200'){
- return $ret;
- }else{
- return false;
- }
- }
- public function untrustworthyPersonnelByBaidu($realname,$card)
- {
- $ch = curl_init();
- // 设置URL
- curl_setopt($ch, CURLOPT_URL, "https://sp1.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?resource_id=6899&query=失信被执行人名单&cardNum={$card}&iname={$realname}&areaName=&from_mid=1&ie=utf-8&oe=utf-8&format=json&t=1727057358546&cb=jQuery110205689284447545091_1727054639403&_=1727054639430");
- // 设置返回结果不直接输出
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- // 执行请求
- $response = curl_exec($ch);
- // 检查是否有错误发生
- if (curl_errno($ch)) {
- $error = curl_error($ch);
- dump($error);
- curl_close($ch);
- return false;
- }
- // 关闭cURL资源
- curl_close($ch);
- // 提取JSONP格式数据中的JSON部分
- $jsonStart = strpos($response, '(') + 1;
- $jsonEnd = strrpos($response, ')');
- $jsonLength = $jsonEnd - $jsonStart;
- $jsonData = substr($response, $jsonStart, $jsonLength);
- // 解析JSON数据
- $result = json_decode($jsonData, true);
- return $result;
- }
- }
|