DataApi.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <?php
  2. namespace app\admin\api;
  3. use OneSm\Sm4;
  4. class DataApi{
  5. public $guid;
  6. public function __construct()
  7. {
  8. //$this->getGuid();
  9. }
  10. protected function getGuid(){
  11. $options = [
  12. 'cache_wsdl' => WSDL_CACHE_NONE,
  13. 'trace' => 1,
  14. 'stream_context' => stream_context_create(
  15. [
  16. 'ssl' => [
  17. 'verify_peer' => false,
  18. 'verify_peer_name' => false,
  19. 'allow_self_signed' => true
  20. ]
  21. ]
  22. )
  23. ];
  24. $redis = \app\common\Redis::instance(\think\facade\Config::get("cache.stores.redis.select"));
  25. $guid= $redis->get("jjdata_guid");
  26. if(!$guid || empty($guid)) {
  27. $client = new \SoapClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/Authentication?wsdl", $options);
  28. $param = [
  29. 'userid' => 'jjswzzb_sbxt',
  30. 'password' => 'sbxt@2022'
  31. ];
  32. $rst = $client->loginByAccount($param);
  33. $ret = json_decode($rst->return, true);
  34. if($ret['code'] == '01'){
  35. $this->guid = $ret['data'];
  36. $redis->set("jjdata_guid",$this->guid,1700);
  37. }else{
  38. $this->guid = '';
  39. }
  40. }else{
  41. $this->guid = $guid;
  42. }
  43. }
  44. public function getClient($url){
  45. $this->getGuid();
  46. $options = [
  47. 'cache_wsdl' => WSDL_CACHE_NONE,
  48. 'trace' => 1,
  49. 'stream_context' => stream_context_create(
  50. [
  51. 'ssl' => [
  52. 'verify_peer' => false,
  53. 'verify_peer_name' => false,
  54. 'allow_self_signed' => true
  55. ]
  56. ]
  57. )
  58. ];
  59. $client = new \SoapClient($url, $options);
  60. return $client;
  61. }
  62. public function queryUnemploymentInsuranceByIdAndTime($card,$start,$end){
  63. $client = $this->getClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/InsuranceRecordSearch?wsdl");
  64. $param = [
  65. 'guid' => $this->guid,
  66. 'requestid' => 'null_00001',
  67. 'id' => $card,
  68. 'startTime' => $start,
  69. 'endTime' => $end
  70. ];
  71. $rst = $client->queryUnemploymentInsuranceByIdAndTime($param);
  72. $ret = json_decode($rst->return, true);
  73. if($ret['code'] == '01'){
  74. return $ret;
  75. }else{
  76. return false;
  77. }
  78. }
  79. public function IDNumber($realname,$birthday){
  80. $client = $this->getClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/InsuranceRecordSearchs?wsdl");
  81. $param = [
  82. 'guid' => $this->guid,
  83. 'requestid' => 'null_00001',
  84. 'aac003' => $realname,
  85. 'bac504' => $birthday
  86. ];
  87. $rst = $client->IDNumber($param);
  88. $ret = json_decode($rst->return, true);
  89. if($ret['code'] == '01'){
  90. return $ret;
  91. }else{
  92. return false;
  93. }
  94. }
  95. public function queryOldAgeSecurityInsuranceByIdAndTime($card,$start,$end){
  96. $client = $this->getClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/InsuranceRecordSearch?wsdl");
  97. $param = [
  98. 'guid' => $this->guid,
  99. 'requestid' => 'null_00001',
  100. 'id' => $card,
  101. 'startTime' => $start,
  102. 'endTime' => $end
  103. ];
  104. $rst = $client->queryOldAgeSecurityInsuranceByIdAndTime($param);
  105. $ret = json_decode($rst->return, true);
  106. if($ret['code'] == '01'){
  107. return $ret;
  108. }else{
  109. return false;
  110. }
  111. }
  112. public function queryJfhbxxByYears($card,$name,$years){
  113. $client = $this->getClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/CityBrain?wsdl");
  114. $param = [
  115. 'guid' => $this->guid,
  116. 'requestid' => 'null_00001',
  117. 'reason' => "测试",
  118. 'optIDCard' => "350582199006028550",
  119. 'optName' => "郑明炜",
  120. 'optIp' => get_client_ip(),
  121. 'optMac' => "00-D8-61-73-14-EC",
  122. 'IDCard' => $card,
  123. 'name' => $name,
  124. 'years' => $years
  125. ];
  126. $rst = $client->queryJfhbxxByYears($param);
  127. $ret = json_decode($rst->return, true);
  128. $ret = json_decode($ret, true);
  129. if($ret['code'] == '01'){
  130. return $ret;
  131. }else{
  132. return false;
  133. }
  134. }
  135. public function untrustworthyPersonnel($card){
  136. $client = $this->getClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/CityBrain?wsdl");
  137. $param = [
  138. 'guid' => $this->guid,
  139. 'requestid' => 'null_00001',
  140. 'reason' => "测试",
  141. 'optIDCard' => "350582199006028550",
  142. 'optName' => "郑明炜",
  143. 'optIp' => get_client_ip(),
  144. 'optMac' => "00-D8-61-73-14-EC",
  145. 'IDCard' => $card
  146. ];
  147. $rst = $client->untrustworthyPersonnel($param);
  148. $ret = json_decode($rst->return, true);
  149. $ret = json_decode($ret, true);
  150. if($ret['code'] == '200'){
  151. return $ret;
  152. }else{
  153. return false;
  154. }
  155. }
  156. public function untrustworthyPersonnelByBaidu($realname,$card)
  157. {
  158. $ch = curl_init();
  159. // 设置URL
  160. 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=1734339892359&cb=jQuery110206573687618467712_1734317532315&_=1727054639430");
  161. // 设置返回结果不直接输出
  162. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  163. // 执行请求
  164. $response = curl_exec($ch);
  165. // 检查是否有错误发生
  166. if (curl_errno($ch)) {
  167. $error = curl_error($ch);
  168. dump($error);
  169. curl_close($ch);
  170. return false;
  171. }
  172. // 关闭cURL资源
  173. curl_close($ch);
  174. // 提取JSONP格式数据中的JSON部分
  175. $jsonStart = strpos($response, '(') + 1;
  176. $jsonEnd = strrpos($response, ')');
  177. $jsonLength = $jsonEnd - $jsonStart;
  178. $jsonData = substr($response, $jsonStart, $jsonLength);
  179. // 解析JSON数据
  180. $result = json_decode($jsonData, true);
  181. return $result;
  182. }
  183. }