DataApi.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 queryOldAgeSecurityInsuranceByIdAndTime($card,$start,$end){
  80. $client = $this->getClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/InsuranceRecordSearch?wsdl");
  81. $param = [
  82. 'guid' => $this->guid,
  83. 'requestid' => 'null_00001',
  84. 'id' => $card,
  85. 'startTime' => $start,
  86. 'endTime' => $end
  87. ];
  88. $rst = $client->queryOldAgeSecurityInsuranceByIdAndTime($param);
  89. $ret = json_decode($rst->return, true);
  90. if($ret['code'] == '01'){
  91. return $ret;
  92. }else{
  93. return false;
  94. }
  95. }
  96. public function queryJfhbxxByYears($card,$name,$years){
  97. $client = $this->getClient("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/CityBrain?wsdl");
  98. $param = [
  99. 'guid' => $this->guid,
  100. 'requestid' => 'null_00001',
  101. 'reason' => "测试",
  102. 'optIDCard' => "350582199006028550",
  103. 'optName' => "郑明炜",
  104. 'optIp' => get_client_ip(),
  105. 'optMac' => "00-D8-61-73-14-EC",
  106. 'IDCard' => $card,
  107. 'name' => $name,
  108. 'years' => $years
  109. ];
  110. $rst = $client->queryJfhbxxByYears($param);
  111. $ret = json_decode($rst->return, true);
  112. $ret = json_decode($ret, true);
  113. if($ret['code'] == '01'){
  114. return $ret;
  115. }else{
  116. return false;
  117. }
  118. }
  119. }