RsApi.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?php
  2. namespace app\admin\api;
  3. use OneSm\Sm4;
  4. class RsApi {
  5. private $key;
  6. private $iv;
  7. private $clientId;
  8. private $sjhjLog;
  9. private $sm4;
  10. public function __construct()
  11. {
  12. $this->key = 'b123d075924b4224';
  13. $this->iv = '8a003e84b5be7b6e';
  14. $this->clientId = 'jjrzzb';
  15. $this->sjhjLog = [
  16. 'requestIpAddr' => '10.41.18.18',
  17. 'requestMacAddr' => '28:6e:d4:88:cb:98',
  18. 'requestReason' => '申报系统审核',
  19. 'operaterName' => '系统',
  20. 'operaterIdcard' => '123456789'
  21. ];
  22. $this->sm4 = new Sm4($this->key);
  23. }
  24. protected function check(){
  25. $deny_list = ["jjrcw.test", "jjrcw.test:8080","report.com","report.jinjianghc.com"]; //拒绝短信名单
  26. if (in_array($_SERVER["HTTP_HOST"], $deny_list))
  27. return false; //测试不请求数据
  28. else
  29. return true;
  30. }
  31. protected function getInfo($url,$data){
  32. $encrypt_str = date("YmdHis",time()) . json_encode($data,JSON_UNESCAPED_UNICODE);
  33. $encrypt_data = $this->sm4->enDataCbc($encrypt_str, $this->iv);
  34. $res = $this->RsCurl('http://172.29.133.70:58080/service-proxy/proxy/'.$url,base64_encode($encrypt_data));
  35. $decrypt_data = $this->sm4->deDataCbc(base64_decode($res), $this->iv);
  36. $decrypt_data = mb_substr($decrypt_data, 14, strlen($decrypt_data), 'UTF-8');
  37. return $decrypt_data;
  38. }
  39. private function RsCurl($url, $postFields){
  40. $ch = curl_init();
  41. curl_setopt($ch, CURLOPT_URL, $url);
  42. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  43. 'Content-Type: application/json; charset=utf-8', //json版本需要填写 Content-Type: application/json;
  44. 'clientId: jjrzzb',
  45. 'sysClientCache: false',
  46. 'serviceProxyCache: false',
  47. 'resultCache: false'
  48. )
  49. );
  50. curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //若果报错 name lookup timed out 报错时添加这一行代码
  51. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  52. curl_setopt($ch, CURLOPT_POST, 1);
  53. curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
  54. curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  55. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  56. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  57. $ret = curl_exec($ch);
  58. if (false == $ret) {
  59. $result = curl_error($ch);
  60. } else {
  61. $rsp = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  62. if (200 != $rsp) {
  63. $result = "请求状态 " . $rsp . " " . curl_error($ch);
  64. } else {
  65. $result = $ret;
  66. }
  67. }
  68. curl_close($ch);
  69. return $result;
  70. }
  71. /**
  72. * 根据身份证号码查询身份证信息
  73. * @param $card
  74. */
  75. public function I010902($card){
  76. $check_res = $this->check();
  77. if(!$check_res) return ['code' => '403','message' => '测试环境'];
  78. $param = [
  79. 'userIDCard' => '聚才网',
  80. 'queryCause' => '聚才网人员信息核查',
  81. 'reqIp' => '10.41.18.18',
  82. 'QQF_MAC' => '28:6e:d4:88:cb:98',
  83. 'userName' => '聚才网',
  84. 'approvePhone' => '18060002035',
  85. 'BHCR_SFZH' => $card,
  86. 'sjhjLog' => $this->sjhjLog
  87. ];
  88. $res = $this->getInfo('I010902',$param);
  89. return json_decode($res,true);
  90. }
  91. /**
  92. * 根据身份证号码查询个人婚姻信息
  93. * @param $card
  94. * @return array|mixed
  95. */
  96. public function I030101($card){
  97. $check_res = $this->check();
  98. if(!$check_res) return ['code' => '403','message' => '测试环境'];
  99. $param = [
  100. 'aac002' => $card,
  101. 'sjhjLog' => $this->sjhjLog
  102. ];
  103. $res = $this->getInfo('I030101',$param);
  104. return json_decode($res,true);
  105. }
  106. /**
  107. * 根据证件号码、社保缴交年月查询个人社保缴费信息
  108. * @param $card
  109. * @param $time
  110. * @return array|mixed
  111. */
  112. public function I110202($card,$time){
  113. $check_res = $this->check();
  114. if(!$check_res) return ['code' => '403','message' => '测试环境'];
  115. $param = [
  116. 'zjhm' => $card,
  117. 'ny' => $time,
  118. 'sjhjLog' => $this->sjhjLog
  119. ];
  120. $res = $this->getInfo('I110202',$param);
  121. return json_decode($res,true);
  122. }
  123. /**
  124. * 根据证件号码查询失信被执行人 编码S0503
  125. * @param $card
  126. * @return array|mixed
  127. */
  128. public function S0503($card){
  129. $check_res = $this->check();
  130. if(!$check_res) return ['code' => '403','message' => '测试环境'];
  131. $param = [
  132. 'aac002' => $card,
  133. 'sjhjLog' => $this->sjhjLog
  134. ];
  135. $res = $this->getInfo('S0503',$param);
  136. return json_decode($res,true);
  137. }
  138. /**
  139. * 根据统一社会信用代码查询企业基本信息
  140. * @param $idCard
  141. */
  142. public function I040102($idCard){
  143. $check_res = $this->check();
  144. if(!$check_res) return ['code' => '403','message' => '测试环境'];
  145. $param = [
  146. 'USCC' => $idCard,
  147. 'sjhjLog' => $this->sjhjLog
  148. ];
  149. $res = $this->getInfo('I040102',$param);
  150. return json_decode($res,true);
  151. }
  152. /**
  153. * 根据统一社会信用代码查询事业单位基本信息
  154. * @param $idCard
  155. */
  156. public function I080101($idCard){
  157. $check_res = $this->check();
  158. if(!$check_res) return ['code' => '403','message' => '测试环境'];
  159. $param = [
  160. 'tyshxydm' => $idCard,
  161. 'sjhjLog' => $this->sjhjLog
  162. ];
  163. $res = $this->getInfo('I080101',$param);
  164. return json_decode($res,true);
  165. }
  166. /**
  167. * 根据民办非企业全称和统一社会信用代码查询民办非企业完整信息
  168. * @param $name
  169. * @param $idCard
  170. * @return array|mixed
  171. */
  172. public function I030501($name, $idCard){
  173. $check_res = $this->check();
  174. if(!$check_res) return ['code' => '403','message' => '测试环境'];
  175. $param = [
  176. 'aab004' => $name,
  177. 'aae136' => $idCard,
  178. 'sjhjLog' => $this->sjhjLog
  179. ];
  180. $res = $this->getInfo('I030501',$param);
  181. return json_decode($res,true);
  182. }
  183. }