DataApi.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 InsuranceRecordSearch($card,$start,$end){
  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("http://110.88.153.177:802/ConvergenceServiceBoot/webservice/InsuranceRecordSearch?wsdl", $options);
  60. $param = [
  61. 'guid' => $this->guid,
  62. 'requestid' => 'null_00001',
  63. 'id' => $card,
  64. 'startTime' => $start,
  65. 'endTime' => $end
  66. ];
  67. $rst = $client->queryUnemploymentInsuranceByIdAndTime($param);
  68. $ret = json_decode($rst->return, true);
  69. if($ret['code'] == '01'){
  70. dd($ret);
  71. }else{
  72. $this->guid = '';
  73. }
  74. }
  75. }