thinkphp快速对接e签宝平台

<?php
namespace app\home\controller; 
use app\common\logic\UserAddressLogic;
use app\common\logic\GoodsActivityLogic;
use app\common\logic\CouponLogic;
use app\common\logic\IntegralLogic;
use app\common\logic\CartLogic;
use app\common\logic\OrderLogic;
use app\common\logic\PickupLogic;
use app\common\model\SpecGoodsPrice;
use app\common\model\Goods;
use think\Db;

header("Content-type:text/html;charset=utf-8");

//e签宝
class Eqb extends Base {
    
    private $redirectUrl =''; //签属结束后跳转页
    private $notifyUrl =''; //签属回调页
    private $eSignAppId =''; //app id
    private $eSignAppSecret=''; // app key
    private $eSignHost ='https://smlopenapi.esign.cn'; //模拟环境
    private $eSignUpload ='https://esignoss.esign.cn'; //文件流
    // private $eSignUpload ='https://oss.esign.cn'; //模拟环境
    // private $eSignHost ='https://openapi.esign.cn'; //正式环境
    /**
     * 初始化函数
     */
    public function _initialize()
    {
        
    }

    
    //消息回调通知
    public function notifyurl(){
        $data = file_get_contents('php://input');
        file_put_contents('eqb.txt',$data,FILE_APPEND);//追加写入消息日志
        $json = json_decode($data,true);
        if($json['action']=='SIGN_MISSON_COMPLETE' && $json['signResult']==2){
            //签署完成
            $mobile = $json['operator']['psnAccount']['accountMobile'];
            $user = M('users')->where(['mobile'=>$mobile])->save(['eqb_status'=>1]);
        }
        // $json = [
        //   "action" => "SIGN_MISSON_COMPLETE",
        //   "timestamp" => 1718267179875,
        //   "signFlowId" => "46b0609529ad458e8a3eec361e3f87f7",
        //   "customBizNum" => "1718267148",
        //   "signOrder" => 1,
        //   "operateTime" => 1718267179000,
        //   "signResult" => 2,
        //   "resultDescription" => "签署完成",
        //   "operator" => [
        //     "psnId" => "030abcd9221f478e8446600054ed1772",
        //     "psnAccount" => [
        //       "accountMobile" => "15241508811"
        //     ]
        //   ]
        // ];

        // echo 12;die;
    }
    //印章回调通知
    public function notifyyinzhang(){
        $data = file_get_contents('php://input');
        file_put_contents('eqbyinzhang.txt',$data,FILE_APPEND);//追加写入消息日志
        // echo 12;die;
    }
    //展示页面测试
    public function show(){
        return $this->fetch('index/eqb');
    }

    //上传本地文件
    public function upload($filePath='',$fileName=''){
        $url = '/v3/files/file-upload-url';
        $host = $this->eSignHost.'/v3/files/file-upload-url';
        // $filePath = "./esign/平台用户合作协议(青抖云).pdf";
        // 文件Content-MD5值 4wobwYcP/xHBzdaIx4hiuQ==
        $fileContentMD5 = $this->getFileContentMD5($filePath);
        // echo $fileContentMD5;die;
        $content_type = "application/pdf";
        $data = [
            'contentMd5'=>$fileContentMD5,
            'contentType'=>$content_type,
            'convertToPDF'=>false,
            'fileName'=>$fileName,
            'fileSize'=>filesize($filePath)
        ];
        $json = json_encode($data,JSON_UNESCAPED_UNICODE);
        $headers = $this->buildSignedHeaders($this->eSignAppId,$this->eSignAppSecret,'POST', $json, 'application/json; charset
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值