diff --git a/app/api/controller/JunziqianController.php b/app/api/controller/JunziqianController.php index c4d51ec8c..1838e5d4c 100644 --- a/app/api/controller/JunziqianController.php +++ b/app/api/controller/JunziqianController.php @@ -3,11 +3,11 @@ namespace app\api\controller; use app\Request; -use com\junziqian\sdk\bean\req\sign\ApplySignReq; -use com\junziqian\sdk\bean\req\user\OrganizationCreateReq; -use com\junziqian\sdk\util\exception\ResultInfoException; -use com\junziqian\sdk\util\RequestUtils; -use com\junziqian\sdk\util\ShaUtils; +use junziqian\sdk\bean\req\sign\ApplySignReq; +use junziqian\sdk\bean\req\user\OrganizationCreateReq; +use junziqian\sdk\util\exception\ResultInfoException; +use junziqian\sdk\util\RequestUtils; +use junziqian\sdk\util\ShaUtils; use CURLFile; use think\facade\Db; diff --git a/extend/.gitignore b/extend/.gitignore deleted file mode 100755 index c96a04f00..000000000 --- a/extend/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/extend/junziqian/sdk/bean/Req2MapInterface.php b/extend/junziqian/sdk/bean/Req2MapInterface.php new file mode 100644 index 000000000..bfc9dde3f --- /dev/null +++ b/extend/junziqian/sdk/bean/Req2MapInterface.php @@ -0,0 +1,52 @@ + $value) { + if(is_null($value)){ + continue; + }else if($ignoreParams!=null&&in_array($key, $ignoreParams)){ + continue; + }else if(is_a($value,'CURLFile')){ + $array[$key] = $value;//文件直接处理 + }else if(is_array($value)){ + $array[$key] = CommonUtil::json_encode($value);//文件直接处理 + }else if(is_a($value,"com\junziqian\sdk\bean\Req2MapInterface")){ + $array[$key] = CommonUtil::json_encode($value);// + }else if(is_object($value)){ + //is_object 对数字、数组等都是返回false + $array[$key] = CommonUtil::json_encode($value);// + }else{ + if(is_string($value)&&""==$value){ + continue; + } + $array[$key] = $value;//文件直接处理 + } + } + return $array; + } +} \ No newline at end of file diff --git a/extend/junziqian/sdk/bean/req/sign/ApplySignReq.php b/extend/junziqian/sdk/bean/req/sign/ApplySignReq.php new file mode 100644 index 000000000..8d56aa5ba --- /dev/null +++ b/extend/junziqian/sdk/bean/req/sign/ApplySignReq.php @@ -0,0 +1,110 @@ +attachFiles!=null&&sizeof($this->attachFiles)>0){ + $i=0; + foreach($this->attachFiles as $value){ + $arr["attachFiles[".$i."]"]=$value; + $i = $i+1; + } + } + return $arr; + } + +} \ No newline at end of file diff --git a/extend/junziqian/sdk/bean/req/sign/ext/SequenceInfo.php b/extend/junziqian/sdk/bean/req/sign/ext/SequenceInfo.php new file mode 100644 index 000000000..bd567bff7 --- /dev/null +++ b/extend/junziqian/sdk/bean/req/sign/ext/SequenceInfo.php @@ -0,0 +1,31 @@ +businessNo = $businessNo; + $this->sequenceOrder = $sequenceOrder; + $this->totalNum = $totalNum; + } + +} \ No newline at end of file diff --git a/extend/junziqian/sdk/bean/req/sign/ext/SignatoryReq.php b/extend/junziqian/sdk/bean/req/sign/ext/SignatoryReq.php new file mode 100644 index 000000000..677dbc258 --- /dev/null +++ b/extend/junziqian/sdk/bean/req/sign/ext/SignatoryReq.php @@ -0,0 +1,88 @@ +serviceUrl = $serviceUrl; + $this->appkey = $appkey; + $this->appSecret = $appSecret; + $this->encryMethod = $encryMethod; + $this->tsType = $tsType; + if(!is_null($this->encryMethod)){ + $this->encryMethod=strtolower($this->encryMethod); + } + } + + /** + * @param $path + * @return object + */ + public function doPost($path,$req=null){ + Assert::notBlank($path,"path不能为空"); + $url=$this->serviceUrl.$path; + if($req==null){ + $req=Array(); + }else if(is_array($req)){ + // + }else if(is_a($req,"com\junziqian\sdk\bean\Req2MapInterface")){ + $req=$req->build(); + }else{ + throw new ResultInfoException("不支持的请求req"); + } + $req=$this->fillSign($req); + //请求服务端sass + //print_r(CommonUtil::json_encode($req)); + $response= HttpClientUtils::getPost($url,$req); + $res=json_decode($response); + Assert::notNull($res,"不能转换为JSON:".$response); + return $res; + } + + /** + * 填充签名数据 + * @param $req array + */ + public function fillSign($req){ + /**默认加密方式:不输入使用sha256,其它可选择项md5,sha1,sha3-256*/ + $ts=time(); + if($this->tsType==1){ + $ts=$ts*1000; + } + $sign=null; + $nonce= md5($ts.""); + $signSrc="nonce".$nonce."ts".$ts."app_key".$this->appkey."app_secret".$this->appSecret; + if($this->encryMethod==null||$this->encryMethod=="sha256"){ + $sign=ShaUtils::getSha256($signSrc); + }else if($this->encryMethod=="sha1"){ + $sign=ShaUtils::getSha1($signSrc); + }else if($this->encryMethod=="md5"){ + $sign=md5($signSrc); + }else{ + throw new ResultInfoException($this->encryMethod.",必须为md5,sha1,sha256之一","PARAM_ERROR"); + } + $req['ts']=$ts; + $req['app_key']=$this->appkey; + $req['sign']=$sign; + $req['nonce']=$nonce;//这只是为了生成一个随机值 + if($this->encryMethod!=null){ + $req['encry_method']=$this->encryMethod;//为''也不能传 + } + return $req; + } +} \ No newline at end of file diff --git a/extend/junziqian/sdk/util/ShaUtils.php b/extend/junziqian/sdk/util/ShaUtils.php new file mode 100644 index 000000000..1234f081f --- /dev/null +++ b/extend/junziqian/sdk/util/ShaUtils.php @@ -0,0 +1,56 @@ +resultCode; + } +} \ No newline at end of file diff --git a/extend/junziqian/sdk/util/http/HttpClientUtils.php b/extend/junziqian/sdk/util/http/HttpClientUtils.php new file mode 100644 index 000000000..ffd02095e --- /dev/null +++ b/extend/junziqian/sdk/util/http/HttpClientUtils.php @@ -0,0 +1,89 @@ + $v ) { + $headerArr[] = $n .':' . $v; + } + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headerArr); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); + $temp = curl_exec($ch); + if(@file_put_contents($file, $temp) && !curl_error($ch)) { + return $file; + } else { + throw new ResultInfoException(curl_error($ch),"POST_ERROR"); + } + } else { + $params = array( + "http"=>array( + "method"=>"GET", + "header"=>"User-Agent:windows", + "timeout"=>$timeout) + ); + $context = stream_context_create($params); + if(@copy($url, $file, $context)) { + //$http_response_header + return $file; + } else { + return false; + } + } + } +} \ No newline at end of file diff --git a/vendor/ebaoquan/junziqian_sdk b/vendor/ebaoquan/junziqian_sdk deleted file mode 160000 index 9acc82cd2..000000000 --- a/vendor/ebaoquan/junziqian_sdk +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 9acc82cd23d807280ddd29df2117e7890094d049