panghu před 1 rokem
rodič
revize
d68d1286ec

+ 7 - 1
app/Console/Commands/TestCommand.php

@@ -65,10 +65,16 @@ class TestCommand extends Command
      */
     public function handle()
     {
+//        $file_id = '0a1feb9ddf3f4da198ec0bb7d0c3225a';
+//        $file_status = ESignContractServer::creatServer()->getFileStatus($file_id);
+//        dd($file_status);
 
         $psnId= 'd1bca85014164a88b896159c799223f9';
         //获取企业内部使用签章列表
-        ESignServer::creatServer()->internalAuthInfo(1,$psnId);
+//        ESignServer::creatServer()->internalAuthInfo(1,$psnId);
+//        ESignServer::creatServer()->psnsealListInfo(1,$psnId);
+        ESignServer::creatServer()->createOrgsealsbyTemplate(1,$psnId);
+        dd(11111);
         //查询是否有合同章
         $sealItem=MemberSeal::where('m_id',1)->first();
         if(empty($sealItem)){

+ 3 - 0
app/Http/Controllers/AdminApi/SignContractController.php

@@ -144,6 +144,9 @@ class SignContractController extends AdminController
         $local_file = WordServer::creatServer()->replaceWordText($file_path,$file_name,$text_json);
         //上传文件到e签宝并获得文件id
         $file_id = ESignContractServer::creatServer()->fileUploadUrl($local_file);
+        //获取文件状态
+        $file_status = ESignContractServer::creatServer()->getFileStatus($file_id);
+        dd(111);
 
         $data = compact('contract_id','contract_no','file_id','text_json','sign_json','local_file');
         //存入数据库

+ 36 - 13
app/Servers/ESign/ESignContractServer.php

@@ -81,20 +81,42 @@ class ESignContractServer
 
         $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
         //获取文件上传地址
-        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+//        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
         $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
-        EsignLogHelper::printMsg($response->getStatus());
-        EsignLogHelper::printMsg($response->getBody());
+//        EsignLogHelper::printMsg($response->getStatus());
+//        EsignLogHelper::printMsg($response->getBody());
         $fileUploadUrl=json_decode($response->getBody())->data->fileUploadUrl;
         $fileId=json_decode($response->getBody())->data->fileId;
         //文件流put上传
         $response=EsignHttpHelper::upLoadFileHttp($fileUploadUrl,$filePath,"application/pdf");
-        EsignLogHelper::printMsg($response->getStatus());
-        EsignLogHelper::printMsg($response->getBody());
+//        EsignLogHelper::printMsg($response->getStatus());
+//        EsignLogHelper::printMsg($response->getBody());
 
         return $fileId;
     }
 
+    /**
+     * 获取文件状态
+     * @param $fileId
+     * @return int|mixed
+     */
+    function getFileStatus($fileId)
+    {
+        $config=$this->config;
+        $apiaddr="/v3/files/{$fileId}";
+        $requestType = HttpEmun::GET;
+        //生成签名验签+json体的header
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], "", $requestType, $apiaddr);
+        //发起接口请求
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, "");
+        $ret=json_decode($response->getBody(),true);
+        if(isset($ret['code']) && $ret['code']==0){
+            return $ret['data']['fileStatus'];
+        }else{
+            return 0;
+        }
+    }
+
     /**
      * 获取签署文件对应关键字坐标
      * @param $fileId
@@ -114,10 +136,10 @@ class ESignContractServer
 
         $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
         //获取文件上传地址
-        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+//        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
         $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
-        EsignLogHelper::printMsg($response->getStatus());
-        EsignLogHelper::printMsg($response->getBody());
+//        EsignLogHelper::printMsg($response->getStatus());
+//        EsignLogHelper::printMsg($response->getBody());
         $ret=json_decode($response->getBody(),true);
         if(isset($ret['code']) && $ret['code']==0){
             return ['code'=>'1','msg'=>'ok','data'=>$ret['data']['keywordPositions']];
@@ -136,9 +158,11 @@ class ESignContractServer
         foreach ($signData as $k=>$v){
             $keywords[]=$v['keyword'];
         }
-        //获取对应关键字定位
 
+        //获取对应关键字定位
+//dd(111);
         $positionRet=ESignContractServer::creatServer()->getKeywordPositions($fileId,$keywords);
+        dd($positionRet);
         if(empty($positionRet['code'])){
             return ['code'=>0,'msg'=>'签署区域定位失败'];
         }else{
@@ -243,7 +267,6 @@ class ESignContractServer
         if(empty($signers)){
             return ['code'=>0,'msg'=>'暂无可执行电签印章'];
         }
-
         $flowId=  $this->createByFile($fileId,$file_name.'.pdf',$file_name,$signers);
 
         if($flowId){
@@ -288,10 +311,10 @@ class ESignContractServer
 
         $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], $paramStr, $requestType, $apiaddr);
 
-        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+//        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
         $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, $paramStr);
-        EsignLogHelper::printMsg($response->getStatus());
-        EsignLogHelper::printMsg($response->getBody());
+//        EsignLogHelper::printMsg($response->getStatus());
+//        EsignLogHelper::printMsg($response->getBody());
 
         $signFlowId = false;
         if($response->getStatus() == 200){

+ 25 - 3
app/Servers/ESign/ESignServer.php

@@ -20,8 +20,8 @@ class ESignServer
     public  $config = [
         'eSignAppId'=>'', //app id
         'eSignAppSecret'=>'', // app key
-//        'eSignHost'=>'https://smlopenapi.esign.cn', //模拟环境
-             'eSignHost'=>'https://openapi.esign.cn' //正式环境
+        'eSignHost'=>'https://smlopenapi.esign.cn', //模拟环境
+//             'eSignHost'=>'https://openapi.esign.cn' //正式环境
     ];
 
     function __construct()
@@ -190,13 +190,15 @@ class ESignServer
 
         $config=$this->config;
         $apiaddr="/v3/seals/psn-seal-list?psnId=".$psnId."&pageNum={$pageNum}&pageSize=20";
+//        var_dump($apiaddr);
         $requestType = HttpEmun::GET;
         //生成签名验签+json体的header
         $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], "", $requestType, $apiaddr);
+//        dd($signAndBuildSignAndJsonHeader);
         //发起接口请求
         $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, "");
         $ret=json_decode($response->getBody(),true);
-//        dd($ret);
+        dd($ret);
         if(isset($ret['code']) && $ret['code']==0){
             //存入签章信息
             $this->setMemberSealList($mId,$ret['data']['seals'],1);
@@ -206,6 +208,26 @@ class ESignServer
         }
     }
 
+    function psnsealListInfo($psnId){
+        $config=$this->config;
+        $apiaddr="/v3/seals/psn-seal-list?psnId=".$psnId."&pageNum=1&pageSize=20";
+        $requestType = HttpEmun::GET;
+//生成签名验签+json体的header
+        $signAndBuildSignAndJsonHeader = EsignHttpHelper::signAndBuildSignAndJsonHeader($config['eSignAppId'], $config['eSignAppSecret'], "", $requestType, $apiaddr);
+//发起接口请求
+        //发起接口请求
+        EsignLogHelper::printMsg($signAndBuildSignAndJsonHeader);
+        $response = EsignHttpHelper::doCommHttp($config['eSignHost'], $apiaddr, $requestType, $signAndBuildSignAndJsonHeader, "");
+        EsignLogHelper::printMsg($response->getStatus());
+        $code=json_decode($response->getBody())->code;
+        if($code ===0){
+            EsignLogHelper::printMsg("查询个人印章列表接口调用成功");
+            EsignLogHelper::printMsg($response->getBody());
+        }else{
+            EsignLogHelper::printMsg($response->getBody());
+        }
+    }
+
 
     /**
      * 设置企业签章信息