RsApi.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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 $card
  141. * @param $start
  142. * @param $end
  143. * @return array|mixed
  144. */
  145. public function YL00018($card,$start,$end){
  146. $check_res = $this->check();
  147. if(!$check_res) return ['code' => '403','message' => '测试环境'];
  148. $param = [
  149. 'aac147' => $card,
  150. 'aae030' => $start,
  151. 'aae031' => $end,
  152. 'sjhjLog' => $this->sjhjLog
  153. ];
  154. $res = $this->getInfo('YL00018',$param);
  155. return json_decode($res,true);
  156. }
  157. /**
  158. * 人社部协同平台-专业技术人员职业资格证书查询
  159. * @param $realname
  160. * @param $card
  161. * @return array|mixed
  162. */
  163. public function SBJ0007($realname,$card){
  164. $check_res = $this->check();
  165. if(!$check_res) return ['code' => '403','message' => '测试环境'];
  166. $param = [
  167. 'ksxm' => $realname,
  168. 'zjhm' => $card,
  169. 'sjhjLog' => $this->sjhjLog
  170. ];
  171. $res = $this->getInfo('SBJ0007',$param);
  172. return json_decode($res,true);
  173. }
  174. /**
  175. * 根据统一社会信用代码查询企业基本信息
  176. * @param $idCard
  177. */
  178. public function I040102($idCard){
  179. $check_res = $this->check();
  180. if(!$check_res) return ['code' => '403','message' => '测试环境'];
  181. $param = [
  182. 'USCC' => $idCard,
  183. 'sjhjLog' => $this->sjhjLog
  184. ];
  185. $res = $this->getInfo('I040102',$param);
  186. return json_decode($res,true);
  187. }
  188. /**
  189. * 根据统一社会信用代码查询事业单位基本信息
  190. * @param $idCard
  191. */
  192. public function I080101($idCard){
  193. $check_res = $this->check();
  194. if(!$check_res) return ['code' => '403','message' => '测试环境'];
  195. $param = [
  196. 'tyshxydm' => $idCard,
  197. 'sjhjLog' => $this->sjhjLog
  198. ];
  199. $res = $this->getInfo('I080101',$param);
  200. return json_decode($res,true);
  201. }
  202. /**
  203. * 根据民办非企业全称和统一社会信用代码查询民办非企业完整信息
  204. * @param $name
  205. * @param $idCard
  206. * @return array|mixed
  207. */
  208. public function I030501($name, $idCard){
  209. $check_res = $this->check();
  210. if(!$check_res) return ['code' => '403','message' => '测试环境'];
  211. $param = [
  212. 'aab004' => $name,
  213. 'aae136' => $idCard,
  214. 'sjhjLog' => $this->sjhjLog
  215. ];
  216. $res = $this->getInfo('I030501',$param);
  217. return json_decode($res,true);
  218. }
  219. }