You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1357 lines
50 KiB
1357 lines
50 KiB
<?php
|
|
namespace fdd;
|
|
|
|
use fdd\FddEncryption;
|
|
use fdd\FddConfig;
|
|
use fdd\FddException;
|
|
require_once "FddException.php";
|
|
require_once "FddConfig.php";
|
|
require_once "FddData.php";
|
|
require_once "FddEncryption.php";
|
|
|
|
/**
|
|
*
|
|
* 接口访问类,包含所有法大大API列表的封装,类中方法为static方法,
|
|
* 每个接口有默认超时时间
|
|
*/
|
|
date_default_timezone_set('PRC');//其中PRC为“中华人民共和国”
|
|
class FddApi
|
|
{/**
|
|
* 合规化接口 注册账号
|
|
* @param Account $param
|
|
* @param int $timeOut
|
|
* @return array|mixed
|
|
*/
|
|
public static function registerAccount(FddAccount $param, $timeOut = 6)
|
|
{
|
|
//注册接口
|
|
$url = FddConfig::FddServer.'/account_register.api';
|
|
try{
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
if (!$param->IsOpenIDSet())
|
|
throw new FddException("缺少必填参数-open_id");
|
|
if (!$param->IsAccountTypeSet())
|
|
throw new FddException("缺少必填参数-account_type");
|
|
$encArr = $param->GetValues();
|
|
$encKey = array_keys($encArr);
|
|
array_multisort($encKey);
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=>$encKey
|
|
];
|
|
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
$input = $param->GetValues();
|
|
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 合同模板传输接口
|
|
* app_id、timestamp、msg_digest、v 、template_id 必填参数
|
|
* file、doc_url 选填参数
|
|
* @param FddTemplate $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function UploadTemplate(FddTemplate $param, $timeOut = 6)
|
|
{
|
|
//合同模板传输接口 地址
|
|
$url = FddConfig::FddServer.'/uploadtemplate.api';
|
|
try{
|
|
//参数处理
|
|
if (!$param->IsTemplate_idSet())
|
|
throw new FddException("缺少必填参数-template_id");
|
|
if (!$param->IsFileSet() && !$param->IsDoc_urlSet())
|
|
throw new FddException("缺少必填参数-file、doc_url 二选一");
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
//设置加密串
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=> ['template_id']
|
|
];
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
$input = $param->GetValues();
|
|
|
|
$res = self::https_request($url,$input);
|
|
|
|
return $res;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 合同文档传输接口
|
|
* app_id、timestamp、msg_digest、v 、contract_id、doc_type 、doc_title必填参数
|
|
* file、doc_url 选填参数
|
|
* @param FddTemplate $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function Uploaddocs(FddTemplate $param, $timeOut = 6)
|
|
{
|
|
//合同文档传输接口 地址
|
|
$url = FddConfig::FddServer.'/uploaddocs.api';
|
|
try{
|
|
//参数处理
|
|
if (!$param->IsContract_idSet())
|
|
throw new FddException("缺少必填参数-contract_id");
|
|
if (!$param->IsDoc_titleSet())
|
|
throw new FddException("缺少必填参数-doc_title");
|
|
if (!$param->IsDoc_typeSet())
|
|
throw new FddException("缺少必填参数-doc_type");
|
|
if (!$param->IsFileSet() && !$param->IsDoc_urlSet())
|
|
throw new FddException("缺少必填参数-file、doc_url 二选一");
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
//设置加密串
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1' => ['contract_id']
|
|
];
|
|
// $param->SetMsg_digest($des::ContractDigest($param));
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
$input = $param->GetValues();
|
|
// file文件是为header 跳转
|
|
// header('location:'.$url.$des->ArrayParamToStr($input));
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 合同生成接口
|
|
* app_id、timestamp、msg_digest、v 、template_id 必填参数
|
|
* @param FddTemplate $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function GenerateContract(FddTemplate $param, $timeOut = 6)
|
|
{
|
|
//合同生成接口 地址
|
|
$url = FddConfig::FddServer.'/generate_contract.api';
|
|
|
|
try{
|
|
//参数处理
|
|
if (!$param->IsDoc_titleSet())
|
|
throw new FddException("缺少必填参数-doc_title");
|
|
if (!$param->IsTemplate_idSet())
|
|
throw new FddException("缺少必填参数-template_id");
|
|
if (!$param->IsContract_idSet())
|
|
throw new FddException("缺少必填参数-contract_id");
|
|
if (!$param->IsParameter_mapSet())
|
|
throw new FddException("缺少必填参数-parameter_map");
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
if($param->GetInsertWay()!=''){
|
|
if($param->GetInsertWay() == 0){
|
|
if (!$param->IsPageBeginSet())
|
|
throw new FddException("缺少必填参数-pageBegin");
|
|
}
|
|
if($param->GetInsertWay() == 1){
|
|
if (!$param->IsKeywordSet())
|
|
throw new FddException("缺少必填参数-keyword");
|
|
}
|
|
$data = [];
|
|
if($param->GetInsertWay() != null){
|
|
$data['insertWay'] = $param->GetInsertWay();
|
|
}
|
|
if($param->GetKeyword() != null){
|
|
$data['keyword'] = $param->GetKeyword();
|
|
}
|
|
if($param->GetPageBegin() != null){
|
|
$data['pageBegin'] = $param->GetPageBegin();
|
|
}
|
|
if($param->GetBorderFlag() != null){
|
|
$data['borderFlag'] = $param->GetBorderFlag();
|
|
}
|
|
if($param->GetCellHeight() != null){
|
|
$data['cellHeight'] = $param->GetCellHeight();
|
|
}
|
|
if($param->GetCellHorizontalAlignment() != null){
|
|
$data['cellHorizontalAlignment'] = $param->GetCellHorizontalAlignment();
|
|
}
|
|
if($param->GetCellVerticalAlignment() != null){
|
|
$data['cellVerticalAlignment'] = $param->GetCellVerticalAlignment();
|
|
}
|
|
if($param->GetTheFirstHeader() != null){
|
|
$data['theFirstHeader'] = $param->GetTheFirstHeader();
|
|
}
|
|
if($param->GetHeaders() != null){
|
|
$data['headers'] = $param->GetHeaders();
|
|
}
|
|
if($param->GetHeadersAlignment() != null){
|
|
$data['headersAlignment'] = $param->GetHeadersAlignment();
|
|
}
|
|
if($param->GetDatas() != null){
|
|
$data['datas'] = $param->GetDatas();
|
|
}
|
|
if($param->GetColWidthPercent() != null){
|
|
$data['colWidthPercent'] = $param->GetColWidthPercent();
|
|
}
|
|
if($param->GetTableHorizontalAlignment() != null){
|
|
$data['tableHorizontalAlignment'] = $param->GetTableHorizontalAlignment();
|
|
}
|
|
if($param->GetTableWidthPercentage() != null){
|
|
$data['tableWidthPercentage'] = $param->GetTableWidthPercentage();
|
|
}
|
|
if($param->GetTableHorizontalOffset() != null){
|
|
$data['tableHorizontalOffset'] = $param->GetTableHorizontalOffset();
|
|
}
|
|
$param->SetHeaders(json_encode($param->GetHeaders()));
|
|
$param->SetDatas(json_encode($param->GetDatas()));
|
|
$param->SetColWidthPercent(json_encode($param->GetColWidthPercent()));
|
|
$arr = array($data);
|
|
$param->SetDynamic_tables(json_encode($arr));
|
|
|
|
if (!$param->IsHeadersSet())
|
|
throw new FddException("缺少必填参数-headers");
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
$param->SetMsg_digest($des::ContractDigest($param));
|
|
$input = $param->GetValues();
|
|
|
|
$res = self::https_request($url,$input);
|
|
|
|
return $res;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 文档签署接口(手动签)
|
|
* app_id、timestamp、msg_digest、contract_id 、transaction_id、customer_id、必填参数
|
|
* notify_url 选填参数
|
|
* @param FddSignContract $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function Extsign(FddSignContract $param, $timeOut = 6)
|
|
{
|
|
// 文档签署接口(手动签) 地址
|
|
$url = FddConfig::FddServer.'/extsign.api';
|
|
try{
|
|
//参数处理
|
|
if (!$param->IsTransaction_idSet())
|
|
throw new FddException("缺少必填参数-transaction_id");
|
|
if (!$param->IsContract_idSet())
|
|
throw new FddException("缺少必填参数-contract_id");
|
|
if (!$param->IsCustomer_idSet())
|
|
throw new FddException("缺少必填参数-customer_id");
|
|
if (!$param->IsDoc_titleSet())
|
|
throw new FddException("缺少必填参数-doc_title");
|
|
if (!$param->IsReturn_urlSet())
|
|
throw new FddException("缺少必填参数-return_url");
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
$param->SetDoc_title(urlencode($param->GetDoc_title()));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
$param->SetMsg_digest($des::ExtsignDigest($param));
|
|
$input = $param->GetValues();
|
|
$jump=$url.$des->ArrayParamToStr($input);
|
|
return ['result'=>'success','code'=>1,'msg'=>'成功','data'=>$jump];
|
|
header('location:'.$url.$des->ArrayParamToStr($input));
|
|
// $res = self::https_request($url,$input);
|
|
// return $res;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 文档签署接口(自动签)
|
|
* app_id、timestamp、msg_digest、contract_id 、transaction_id、customer_id、必填参数
|
|
* notify_url 选填参数
|
|
* @param FddSignContract $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function ExtsignAuto(FddSignContract $param, $timeOut = 6)
|
|
{
|
|
// 文档签署接口(自动签) 地址
|
|
$url = FddConfig::FddServer.'/extsign_auto.api';
|
|
try{
|
|
//参数处理
|
|
if (!$param->IsTransaction_idSet())
|
|
throw new FddException("缺少必填参数-transaction_id");
|
|
if (!$param->IsContract_idSet())
|
|
throw new FddException("缺少必填参数-contract_id");
|
|
if (!$param->IsCustomer_idSet())
|
|
throw new FddException("缺少必填参数-customer_id");
|
|
if (!$param->IsDoc_titleSet())
|
|
throw new FddException("缺少必填参数-doc_title");
|
|
if (!$param->IsClient_roleSet())
|
|
throw new FddException("缺少必填参数-client_role");
|
|
if ($param->IsPosition_typeSet()){
|
|
if($param->GetPosition_type() == 1){
|
|
if(!$param->IsYSet() && !$param->IsXSet() && !$param->IsPagenumSet())
|
|
throw new FddException("缺少必填参数- x 、y 、pagenum");
|
|
}
|
|
if($param->GetPosition_type() == 0){
|
|
if(!$param->IsSign_keywordSet())
|
|
throw new FddException("缺少必填参数- Sign_keyword");
|
|
}
|
|
}
|
|
if($param->IsPagenumSet()){
|
|
$pagenum = $param->GetPagenum();
|
|
$x = $param->GetX();
|
|
$y = $param->GetY();
|
|
$SearchLocation = array(
|
|
array(
|
|
'pagenum' => $pagenum,
|
|
'x' => $x,
|
|
'y' => $y
|
|
)
|
|
);
|
|
$param->SetSignature_positions(json_encode($SearchLocation));
|
|
}
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
$param->SetDoc_title(urlencode($param->GetDoc_title()));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
$param->SetMsg_digest($des::ExtsignDigest($param));
|
|
$input = $param->GetValues();
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 文档签署接口(含有效期和次数限制)
|
|
* app_id、timestamp、msg_digest、contract_id 、transaction_id 、customer_id、doc_title、return_url、validity、quantity必填参数
|
|
* notify_url 、sign_keyword 、keyword_strategy 选填参数
|
|
* @param FddSignContract $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function ExtsignValidation(FddSignContract $param, $timeOut = 6)
|
|
{
|
|
// 文档签署接口(含有效期和次数限制) 地址
|
|
$url = FddConfig::FddServer.'/extsign_validation.api';
|
|
try{
|
|
//参数处理
|
|
if (!$param->IsTransaction_idSet())
|
|
throw new FddException("缺少必填参数-transaction_id");
|
|
if (!$param->IsContract_idSet())
|
|
throw new FddException("缺少必填参数-contract_id");
|
|
if (!$param->IsCustomer_idSet())
|
|
throw new FddException("缺少必填参数-customer_id");
|
|
if (!$param->IsDoc_titleSet())
|
|
throw new FddException("缺少必填参数-doc_title");
|
|
if (!$param->IsReturn_urlSet())
|
|
throw new FddException("缺少必填参数-return_url");
|
|
if (!$param->IsValiditySet())
|
|
throw new FddException("缺少必填参数-validity");
|
|
if (!$param->IsQuantitySet())
|
|
throw new FddException("缺少必填参数-quantity");
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
$param->SetDoc_title(urlencode($param->GetDoc_title()));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
$param->SetMsg_digest($des::ExtsignValiityDigest($param));
|
|
$input = $param->GetValues();
|
|
header('location:'.$url.$des->ArrayParamToStr($input));
|
|
// $res = self::https_request($url,$input);
|
|
// return $res;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 客户签署结果查询接口
|
|
* @param FddQuerySignResult $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function QuerySignResult(FddQuerySignResult $param, $timeOut = 6)
|
|
{
|
|
//客户签署结果查询接口 地址
|
|
$url = FddConfig::FddServer.'/query_sign_result.api';
|
|
try{
|
|
//参数处理
|
|
if (!$param->IsContract_idSet())
|
|
throw new FddException("缺少必填参数-contract_id");
|
|
if (!$param->IsCustomer_idSet())
|
|
throw new FddException("缺少必填参数-customer_id");
|
|
if (!$param->IsTransaction_idSet())
|
|
throw new FddException("缺少必填参数-transaction_id");
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
//设置加密串
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=> ['contract_id','customer_id','transaction_id']
|
|
];
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
$input = $param->GetValues();
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 文档查看接口
|
|
* @param FddContractManageMent $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function ViewContract(FddContractManageMent $param, $timeOut = 6)
|
|
{
|
|
//文档查看接口
|
|
$url = FddConfig::FddServer.'/viewContract.api';
|
|
try{
|
|
if (!$param->IsContract_idSet())
|
|
throw new FddException("缺少必填参数-contract_id");
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
//设置加密串
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=> ['contract_id']
|
|
];
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
$input = $param->GetValues();
|
|
header('location:'.$url.$des->ArrayParamToStr($input));
|
|
// $res = self::https_request($url,$input);
|
|
// return $res;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 文档临时查看/下载地址接口(含有效期和次数)
|
|
* @param FddContractManageMent $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常 Geturl
|
|
*/
|
|
public static function GetUrl(FddContractManageMent $param, $timeOut = 6)
|
|
{
|
|
//文档临时查看/下载地址接口(含有效期和次数)
|
|
$url = FddConfig::FddServer.'/geturl.api';
|
|
try{
|
|
if (!$param->IsContract_idSet())
|
|
throw new FddException("缺少必填参数-contract_id");
|
|
if (!$param->IsValiditySet())
|
|
throw new FddException("缺少必填参数-validity");
|
|
if (!$param->IsQuantitySet())
|
|
throw new FddException("缺少必填参数-quantity");
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
//设置加密串
|
|
$enc = [
|
|
'md5' => ['validity','quantity'],
|
|
'sha1'=> ['contract_id']
|
|
];
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
$input = $param->GetValues();
|
|
// header('location:'.$url.$des->ArrayParamToStr($input));
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 文档下载接口
|
|
* @param FddContractManageMent $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function DownLoadContract(FddContractManageMent $param, $timeOut = 6)
|
|
{
|
|
//文档下载接口 地址
|
|
$url = FddConfig::FddServer.'/downLoadContract.api';
|
|
try{
|
|
if (!$param->IsContract_idSet())
|
|
throw new FddException("缺少必填参数-contract_id");
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
//设置加密串
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=> ['contract_id']
|
|
];
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
$input = $param->GetValues();
|
|
header('location:'.$url.$des->ArrayParamToStr($input));
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 查询合同hash值接口
|
|
* contract_id 必填参数
|
|
* @param FddContractManageMent $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function GetContractHash(FddContractManageMent $param, $timeOut = 6)
|
|
{
|
|
//查询合同hash值接口
|
|
$url = FddConfig::FddServer.'/getContractHash.api';
|
|
try{
|
|
if (!$param->IsContract_idSet())
|
|
throw new FddException("缺少必填参数-contract_id");
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
//设置加密串
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=> ['contract_id']
|
|
];
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
$input = $param->GetValues();
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 客户信息修改接口
|
|
* @param FddUserManage $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function InfoChange(FddUserManage $param, $timeOut = 6)
|
|
{
|
|
//客户信息修改接口 地址
|
|
$url = FddConfig::FddServer.'/infochange.api';
|
|
try{
|
|
if (!$param->IsCustomer_idSet())
|
|
throw new FddException("缺少必填参数-customer_id");
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
//设置加密串
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=> []
|
|
];
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
$input = $param->GetValues();
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 合同归档接口
|
|
* @param FddContractManageMent $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function ContractFiling(FddContractManageMent $param, $timeOut = 6)
|
|
{
|
|
//合同归档接口
|
|
$url = FddConfig::FddServer.'/contractFiling.api';
|
|
try{
|
|
if (!$param->IsContract_idSet())
|
|
throw new FddException("缺少必填参数-contract_id");
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
//设置加密串
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=> ['contract_id']
|
|
];
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
$input = $param->GetValues();
|
|
// header('location:'.$url.$des->ArrayParamToStr($input));
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
*
|
|
* 文档验签接口
|
|
* app_id、timestamp、msg_digest、doc_url、file必填参数
|
|
* @param FddSignContract $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function ContractVerify(FddSignContract $param, $timeOut = 6)
|
|
{
|
|
// 文档验签接口 地址
|
|
$url = FddConfig::FddServer.'/contract_verify.api';
|
|
try{
|
|
//参数处理
|
|
if (!$param->IsFileSet() && !$param->IsDoc_urlSet())
|
|
throw new FddException("缺少必填参数-file、doc_url 二选一");
|
|
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
//设置加密串
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=> ['doc_url']
|
|
];
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
$input = $param->GetValues();
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 实名信息哈希存证
|
|
* @param FddCertification $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function HashDeposit(FddDeposit $param, $timeOut = 6)
|
|
{
|
|
//查询个人实名认证信息
|
|
$url = FddConfig::FddServer.'/hash_deposit.api';
|
|
try{
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
$encArr = $param->GetValues();
|
|
$encKey = array_keys($encArr);
|
|
array_multisort($encKey);
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=>$encKey
|
|
];
|
|
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
|
|
$input = $param->GetValues();
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 个人实名信息存证
|
|
* @param FddDeposit $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function personDeposit(FddDeposit $param, $timeOut = 6)
|
|
{
|
|
//个人实名信息存证
|
|
$url =FddConfig::FddServer.'/person_deposit.api';
|
|
try{
|
|
|
|
if (!$param->IsDocumentTypeSet()){
|
|
$param->SetDocumentType('0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
if("1" === $param->GetVerifiedType()){
|
|
$PublicSecurityEssentialFactor = [
|
|
'applyNum'=>$param->GetapplyNum(),
|
|
'queryTime'=>$param->GetqueryTime(),
|
|
'systemFlag'=>$param->GetsystemFlag(),
|
|
'idcardCompare'=>$param->GetidcardCompare(),
|
|
'nameCompare'=>$param->GetnameCompare(),
|
|
'vrifiedProvider'=>$param->GetverifiedProvider(),
|
|
];
|
|
$param->SetPublicSecurityEssentialFactor(json_encode($PublicSecurityEssentialFactor));
|
|
if (!$param->IsPublicSecurityEssentialFactorSet())
|
|
throw new FddException("缺少必填参数-PublicSecurityEssentialFactor");
|
|
}
|
|
if("2" === $param->GetVerifiedType()){
|
|
$MobileEssentialFactor = [
|
|
'transactionId'=>$param->GettransactionId(),
|
|
'mobileVerificationCode'=>'',//$param->GetmobileVerificationCode(),
|
|
'verifiedProvider'=>'',//$param->GetverifiedProvider(),
|
|
'result'=>'',//$param->Getresult(),
|
|
];
|
|
$param->SetMobileEssentialFactor(json_encode($MobileEssentialFactor));
|
|
if (!$param->IsMobileEssentialFactorSet())
|
|
throw new FddException("缺少必填参数-MobileEssentialFactor");
|
|
|
|
}
|
|
if("3" === $param->GetVerifiedType()){
|
|
$BankEssentialFactor = [
|
|
'bank'=>$param->Getbank(),
|
|
'bankAccount'=>$param->GetbankAccount(),
|
|
'transactionId'=>$param->GettransactionId(),
|
|
'verifiedProvider'=>$param->GetverifiedProvider(),
|
|
'result'=>$param->Getresult(),
|
|
];
|
|
$param->SetBankEssentialFactor(json_encode($BankEssentialFactor));
|
|
if (!$param->IsBankEssentialFactorSet())
|
|
throw new FddException("缺少必填参数-BankEssentialFactor");
|
|
}
|
|
if("4" === $param->GetVerifiedType()){
|
|
$MobileAndBankEssentialFactor = [
|
|
'bank'=>$param->Getbank(),
|
|
'bankAccount'=>$param->GetbankAccount(),
|
|
'transactionId'=>$param->GettransactionId(),
|
|
'mobileVerificationCode'=>$param->GetmobileVerificationCode(),
|
|
'verifiedProvider'=>$param->GetverifiedProvider(),
|
|
'result'=>$param->Getresult(),
|
|
];
|
|
$param->SetMobileAndBankEssentialFactor(json_encode($MobileAndBankEssentialFactor));
|
|
if (!$param->IsMobileAndBankEssentialFactorSet())
|
|
throw new FddException("缺少必填参数-MobileAndBankEssentialFactor");
|
|
}
|
|
/*
|
|
$LiveDetection = [
|
|
'transactionId'=>$param->GettransactionId(),
|
|
'result'=>$param->Getresult(),
|
|
];
|
|
if($param->Getresult()){
|
|
$param->SetLiveDetection(json_encode($LiveDetection));
|
|
}
|
|
*/
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=>['bank_essential_factor','customer_id','document_type',
|
|
'idcard','live_detection','mobile','mobile_and_bank_essential_factor',
|
|
'mobile_essential_factor','name','preservation_data_provider',
|
|
'preservation_desc','preservation_name','public_security_essential_factor',
|
|
'verified_time','verified_type']
|
|
];
|
|
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
|
|
$input = $param->GetValues();
|
|
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 企业信息实名存证
|
|
* @param FddDeposit $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function companyDeposit(FddDeposit $param,FddDeposit $inputPerson, $timeOut = 6)
|
|
{
|
|
//企业信息实名存证
|
|
$url = FddConfig::FddServer.'/company_deposit.api';
|
|
try{
|
|
|
|
if (!$param->IsDocumentTypeSet()){
|
|
$param->SetDocumentType('0');
|
|
}
|
|
|
|
$LiveDetection = [
|
|
'transactionId'=>$inputPerson->GettransactionId(),
|
|
'result'=>$inputPerson->Getresult(),
|
|
];
|
|
$companyPrincipalVerifiedMsg = [
|
|
'customer_id'=>$inputPerson->GetCustomerID(),
|
|
'preservation_name'=>$inputPerson->GetPreservationName(),
|
|
'preservation_desc'=>$inputPerson->GetPreservationDesc(),
|
|
'preservation_data_provider'=>$inputPerson->GetPreservationDataProvider(),
|
|
'name'=>$inputPerson->GetName(),
|
|
'document_type'=>$inputPerson->GetDocumentType(),
|
|
'idcard'=>$inputPerson->GetIdCard(),
|
|
'mobile'=>$inputPerson->GetMobile(),
|
|
//'verified_time'=>$inputPerson->GetVerifiedTime(),
|
|
'verified_type'=>$inputPerson->GetVerifiedType(),
|
|
//'live_detection'=>json_encode($LiveDetection),
|
|
];
|
|
|
|
if("1" === $inputPerson->GetVerifiedType()){
|
|
$PublicSecurityEssentialFactor = [
|
|
'applyNum'=>$inputPerson->GetapplyNum(),
|
|
'queryTime'=>$inputPerson->GetqueryTime(),
|
|
'systemFlag'=>$inputPerson->GetsystemFlag(),
|
|
'idcardCompare'=>$inputPerson->GetidcardCompare(),
|
|
'nameCompare'=>$inputPerson->GetnameCompare(),
|
|
'vrifiedProvider'=>$inputPerson->GetverifiedProvider(),
|
|
];
|
|
|
|
$companyPrincipalVerifiedMsg['public_security_essential_factor']=$PublicSecurityEssentialFactor;
|
|
$inputPerson->SetPublicSecurityEssentialFactor(json_encode($PublicSecurityEssentialFactor));
|
|
if (!$inputPerson->IsPublicSecurityEssentialFactorSet())
|
|
throw new FddException("缺少必填参数-PublicSecurityEssentialFactor");
|
|
}
|
|
if("2" === $inputPerson->GetVerifiedType()){
|
|
$MobileEssentialFactor = [
|
|
'transactionId'=>$inputPerson->GettransactionId(),
|
|
'verifiedProvider'=>$inputPerson->GetverifiedProvider(),
|
|
'result'=>$inputPerson->Getresult(),
|
|
];
|
|
$companyPrincipalVerifiedMsg['mobile_essential_factor']=$MobileEssentialFactor;
|
|
$inputPerson->SetMobileEssentialFactor(json_encode($MobileEssentialFactor));
|
|
if (!$inputPerson->IsMobileEssentialFactorSet())
|
|
throw new FddException("缺少必填参数-MobileEssentialFactor");
|
|
}
|
|
if("3" === $inputPerson->GetVerifiedType()){
|
|
|
|
$BankEssentialFactor = [
|
|
'bank'=>$inputPerson->Getbank(),
|
|
'bankAccount'=>$inputPerson->GetbankAccount(),
|
|
'transactionId'=>$inputPerson->GettransactionId(),
|
|
'verifiedProvider'=>$inputPerson->GetverifiedProvider(),
|
|
'result'=>$inputPerson->Getresult(),
|
|
];
|
|
|
|
$companyPrincipalVerifiedMsg['bank_essential_factor']=$BankEssentialFactor;
|
|
$inputPerson->SetBankEssentialFactor(json_encode($BankEssentialFactor));
|
|
if (!$inputPerson->IsBankEssentialFactorSet())
|
|
throw new FddException("缺少必填参数-BankEssentialFactor");
|
|
}
|
|
if("4" === $inputPerson->GetVerifiedType()){
|
|
$MobileAndBankEssentialFactor = [
|
|
'bank'=>$inputPerson->Getbank(),
|
|
'bankAccount'=>$inputPerson->GetbankAccount(),
|
|
'transactionId'=>$inputPerson->GettransactionId(),
|
|
'mobileVerificationCode'=>$inputPerson->GetmobileVerificationCode(),
|
|
'verifiedProvider'=>$inputPerson->GetverifiedProvider(),
|
|
'result'=>$inputPerson->Getresult(),
|
|
];
|
|
|
|
$companyPrincipalVerifiedMsg['mobile_and_bank_essential_factor']=$MobileAndBankEssentialFactor;
|
|
$inputPerson->SetMobileAndBankEssentialFactor(json_encode($MobileAndBankEssentialFactor));
|
|
if (!$inputPerson->IsMobileAndBankEssentialFactorSet())
|
|
throw new FddException("缺少必填参数-MobileAndBankEssentialFactor");
|
|
}
|
|
|
|
|
|
$inputPerson->SetLiveDetection(json_encode($LiveDetection));
|
|
|
|
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
$param->SetCompanyPrincipalVerifiedMsg(json_encode($companyPrincipalVerifiedMsg));
|
|
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=>['amount_or_random_code','company_name','company_principal_type','company_principal_verified_msg',
|
|
'credit_code','customer_bank','customer_bank_account','customer_branch_bank',
|
|
'customer_id','document_type','legal_idcard','legal_name','licence','organization',
|
|
'pay_type','preservation_data_provider','preservation_desc','preservation_name','
|
|
public_bank_account','public_branch_bank','transaction_id','user_back_fill_amount_or_random_code',
|
|
'verified_mode','verified_time']
|
|
];
|
|
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
$param->SetV('2.0');
|
|
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
|
|
$input = $param->GetValues();
|
|
dump($input);
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 个人实名信息存证
|
|
* @param FddDeposit $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function personVerify(FddVerify $param){
|
|
|
|
$des = new FddEncryption();
|
|
//个人实名信息存证
|
|
$url =FddConfig::FddServer.'/get_person_verify_url.api';
|
|
try{
|
|
$keys=['customer_id','verified_way','page_modify',
|
|
'return_url','notify_url','customer_name','customer_ident_type',
|
|
'customer_ident_no','mobile','ident_front_path',
|
|
'id_photo_optional','result_type','cert_flag',
|
|
'option','cert_type'];
|
|
asort($keys);
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=>$keys
|
|
];
|
|
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
$input = $param->GetValues();
|
|
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 企业信息实名存证
|
|
* @param FddDeposit $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function companyVerify(FddVerify $param)
|
|
{
|
|
|
|
$des = new FddEncryption();
|
|
//企业信息实名存证
|
|
$url = FddConfig::FddServer.'/get_company_verify_url.api';
|
|
try{
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=>['cert_flag','company_info','company_principal_type','customer_id','id_photo_optional',
|
|
'legal_allow_company_verify_way','legal_authorized_mobile','legal_info','legal_name','mobile',
|
|
'notify_url','option','organization_type','page_modify','return_url','verified_way']
|
|
];
|
|
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
$param->SetV('2.0');
|
|
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
|
|
$input = $param->GetValues();
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
/**
|
|
* 存证方案--编号证书
|
|
* @param FddCertification $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function applyClientNumCert(FddDeposit $param, $timeOut = 6)
|
|
{
|
|
//编号证书申请接口
|
|
$url = FddConfig::FddServer.'/apply_client_numcert.api';
|
|
try{
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=>['customer_id','evidence_no']
|
|
];
|
|
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
|
|
$input = $param->GetValues();
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
/**
|
|
* 实名证书申请
|
|
* @param FddCertification $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function applyCert(FddDeposit $param, $timeOut = 6)
|
|
{
|
|
//编号证书申请接口
|
|
$url = FddConfig::FddServer.'/apply_cert.api';
|
|
try{
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=>['customer_id','verified_serialno']
|
|
];
|
|
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
|
|
$input = $param->GetValues();
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
/**
|
|
* 实名证书申请
|
|
* @param FddCertification $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function findCert($surl='',$no='')
|
|
{
|
|
//编号证书申请接口
|
|
$url = FddConfig::FddServer.$surl;
|
|
try{
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
$enc = [
|
|
'md5' => [],
|
|
'sha1'=>['verified_serialno']
|
|
];
|
|
$param=new FddDeposit();
|
|
$param->SetVerifiedSerialno($no);
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
$param->SetMsg_digest($des::GeneralDigest($param,$enc));
|
|
|
|
$input = $param->GetValues();
|
|
$res = self::https_request($url,$input);
|
|
return $res;
|
|
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
/**
|
|
*
|
|
* 文档签署接口(手动签)--合规化存证方案
|
|
* app_id、timestamp、msg_digest、contract_id 、transaction_id、customer_id、必填参数
|
|
* notify_url 选填参数
|
|
* @param FddSignContract $param
|
|
* @param int $timeOut
|
|
* @throws FddException
|
|
* @return 成功时返回,其他抛异常
|
|
*/
|
|
public static function ExtsignForDeposit(FddSignContract $param, $timeOut = 6)
|
|
{
|
|
// 文档签署接口(手动签) 地址
|
|
$url = FddConfig::FddServer.'/extsign.api';
|
|
try{
|
|
//参数处理
|
|
if (!$param->IsTransaction_idSet())
|
|
throw new FddException("缺少必填参数-transaction_id");
|
|
if (!$param->IsContract_idSet())
|
|
throw new FddException("缺少必填参数-contract_id");
|
|
if (!$param->IsCustomer_idSet())
|
|
throw new FddException("缺少必填参数-customer_id");
|
|
if (!$param->IsDoc_titleSet())
|
|
throw new FddException("缺少必填参数-doc_title");
|
|
if (!$param->IsReturn_urlSet())
|
|
throw new FddException("缺少必填参数-return_url");
|
|
if(!$param->IsCustomerNameSet() || !$param->IsCustomerIdentNoSet()){
|
|
throw new FddException("customer_name和customer_ident_no必须同时传入");
|
|
}
|
|
$param->SetApp_id(FddConfig::AppId);
|
|
$param->SetTimestamp(date('YmdHis'));
|
|
$param->SetDoc_title(urlencode($param->GetDoc_title()));
|
|
if (!$param->IsVSet()){
|
|
$param->SetV('2.0');
|
|
}
|
|
//实例化3DES类
|
|
$des = new FddEncryption();
|
|
$param->SetMsg_digest($des::ExtsignDigest($param));
|
|
$input = $param->GetValues();
|
|
header('location:'.$url.$des->ArrayParamToStr($input));
|
|
// $res = self::https_request($url,$input);
|
|
// return $res;
|
|
$end = $url.$des->ArrayParamToStr($input);
|
|
return $end;
|
|
}catch (FddException $e){
|
|
|
|
return ['result'=>'error','code'=>2001,'msg'=>$e->errorMessage()];
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 通用http函数
|
|
* @param $url
|
|
* @param string $data
|
|
* @param string $type
|
|
* @param string $res
|
|
* @return mixed
|
|
*/
|
|
public static function https_request($url,$data = "",$type="post",$res="json"){
|
|
|
|
/* $apiUrl=FddConfig::FddServer;
|
|
$client=new HttpClient($apiUrl);
|
|
if($type=="post"){
|
|
$ret=$client->quickPost($url, $data);
|
|
}else{
|
|
$ret=$client->quickGet($url);
|
|
}
|
|
if (is_array($ret)&&$res == "json") {
|
|
return json_decode($ret,true);
|
|
}
|
|
return $ret; */
|
|
echo $url;
|
|
dump($data);
|
|
|
|
//1.初始化curl
|
|
$curl = curl_init();
|
|
//2.设置curl的参数
|
|
curl_setopt($curl, CURLOPT_URL, $url);
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,2);
|
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
if ($type == "post"){
|
|
curl_setopt($curl, CURLOPT_POST, 1);
|
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
|
// curl_setopt($curl,CURLOPT_BINARYTRANSFER, true);
|
|
}
|
|
//3.采集
|
|
$output = curl_exec($curl);
|
|
dump($output);
|
|
if (curl_errno($curl)) {
|
|
echo 'Curl error: ' . curl_error($curl);exit;
|
|
}
|
|
//4.关闭
|
|
curl_close($curl);
|
|
if (is_array($output)&&$res == "json") {
|
|
return json_decode($output,true);
|
|
}
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* 文件输出http函数
|
|
* @param $url
|
|
* @param string $data
|
|
* @param string $type
|
|
* @return mixed
|
|
*/
|
|
public static function https_request_file($url,$data = "",$type="post"){
|
|
//1.初始化curl
|
|
$curl = curl_init();
|
|
//2.设置curl的参数
|
|
curl_setopt($curl, CURLOPT_URL, $url);
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
|
|
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,2);
|
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
|
if ($type == "post"){
|
|
curl_setopt($curl, CURLOPT_POST, 1);
|
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
|
}
|
|
//3.采集
|
|
$output = curl_exec($curl);
|
|
header("Content-type: application/octet-stream");
|
|
|
|
header("Content-Disposition: attachment; filename=原文出证".time().".pdf");
|
|
|
|
echo $output;
|
|
|
|
//4.关闭
|
|
curl_close($curl);
|
|
}
|
|
|
|
/**
|
|
* 图片转base64文件
|
|
* @param $image_file
|
|
* @return string
|
|
*/
|
|
public function base64EncodeImage ($image_file)
|
|
{
|
|
$base64_image = "";
|
|
$image_info = getimagesize($image_file);
|
|
$image_data = fread(fopen($image_file, "r"), filesize($image_file));
|
|
$base64_image = "data:" . $image_info["mime"] . ";base64," . chunk_split(base64_encode($image_data));
|
|
return $base64_image;
|
|
}
|
|
|
|
} ?>
|