123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- namespace app\admin\api;
- use OneSm\Sm4;
- class RsApi {
- private $key;
- private $iv;
- private $clientId;
- private $sjhjLog;
- private $sm4;
- public function __construct()
- {
- $this->key = 'b123d075924b4224';
- $this->iv = '8a003e84b5be7b6e';
- $this->clientId = 'jjrzzb';
- $this->sjhjLog = [
- 'requestIpAddr' => '10.41.18.18',
- 'requestMacAddr' => '28:6e:d4:88:cb:98',
- 'requestReason' => '申报系统审核',
- 'operaterName' => '系统',
- 'operaterIdcard' => '系统'
- ];
- $this->sm4 = new Sm4($this->key);
- }
- protected function check(){
- $deny_list = ["jjrcw.test", "jjrcw.test:8080","report.com","report.jinjianghc.com"]; //拒绝短信名单
- if (in_array($_SERVER["HTTP_HOST"], $deny_list))
- return false; //测试不请求数据
- else
- return true;
- }
- protected function getInfo($url,$data){
- $encrypt_str = date("YmdHis",time()) . json_encode($data,JSON_UNESCAPED_UNICODE);
- $encrypt_data = $this->sm4->enDataCbc($encrypt_str, $this->iv);
- $res = $this->RsCurl('http://172.29.133.70:58080/service-proxy/proxy/'.$url,base64_encode($encrypt_data));
- $decrypt_data = $this->sm4->deDataCbc(base64_decode($res), $this->iv);
- $decrypt_data = mb_substr($decrypt_data, 14, strlen($decrypt_data), 'UTF-8');
- return $decrypt_data;
- }
- private function RsCurl($url, $postFields){
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json; charset=utf-8', //json版本需要填写 Content-Type: application/json;
- 'clientId: jjrzzb',
- 'sysClientCache: false',
- 'serviceProxyCache: false',
- 'resultCache: false'
- )
- );
- curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); //若果报错 name lookup timed out 报错时添加这一行代码
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
- curl_setopt($ch, CURLOPT_TIMEOUT, 60);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- $ret = curl_exec($ch);
- if (false == $ret) {
- $result = curl_error($ch);
- } else {
- $rsp = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- if (200 != $rsp) {
- $result = "请求状态 " . $rsp . " " . curl_error($ch);
- } else {
- $result = $ret;
- }
- }
- curl_close($ch);
- return $result;
- }
- /**
- * 根据身份证号码查询身份证信息
- * @param $card
- */
- public function I010902($card){
- $check_res = $this->check();
- if(!$check_res) return ['code' => '403','message' => '测试环境'];
- $param = [
- 'userIDCard' => '聚才网',
- 'queryCause' => '聚才网人员信息核查',
- 'reqIp' => '10.41.18.18',
- 'QQF_MAC' => '28:6e:d4:88:cb:98',
- 'userName' => '聚才网',
- 'approvePhone' => '18060002035',
- 'BHCR_SFZH' => $card,
- 'sjhjLog' => $this->sjhjLog
- ];
- $res = $this->getInfo('I010902',$param);
- return json_decode($res,true);
- }
- }
|