开发ca,修正手机号获取验证码log表
This commit is contained in:
+39
-2
@@ -4,6 +4,7 @@ namespace Extend\Ca;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Utils\Log;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
@@ -182,6 +183,36 @@ class Ca
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PDF添加电子签章
|
||||
*/
|
||||
public function addSignPdf(string $user_id,array $data){
|
||||
$option = [
|
||||
'form_params' => [
|
||||
'userId' => $user_id,// 用户标识信息
|
||||
'configKey' => $user_id,// 签章配置唯一标识
|
||||
'signParams' => $data['sign_param'],// 签章参数,JSON格式数据,如果不指定,那么以签章配置接口配置为准
|
||||
'pdfFile' => $data['pdf_file'],// 待签章PDF文件(字节流)
|
||||
'cloudCertPass' => $user_id,// 云证书PIN码,云证书签章时使用
|
||||
]
|
||||
];
|
||||
|
||||
try {
|
||||
$response = $this->httpRequest(
|
||||
config("ca.api_url") . '/signature-server/api/open/signature/signPdf',
|
||||
$option
|
||||
);
|
||||
|
||||
if (empty($response)){
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
return $response;
|
||||
} catch (GuzzleException $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求签名
|
||||
* @param array $data
|
||||
@@ -190,6 +221,12 @@ class Ca
|
||||
protected function getRequestSign(array $data): string
|
||||
{
|
||||
ksort($data['form_params']);
|
||||
foreach ($data['form_params'] as $key => $item){
|
||||
if ($key == "pdfFile"){
|
||||
// pdf进行签章时,此参数为文件流,不参与签名
|
||||
unset($data['form_params'][$key]);
|
||||
}
|
||||
}
|
||||
|
||||
$data = implode('&',$data['form_params']);
|
||||
return hash_hmac("sha1",$data,config("ca.secret"));
|
||||
@@ -204,7 +241,6 @@ class Ca
|
||||
*/
|
||||
protected function httpRequest(string $path,array $arg = []): mixed
|
||||
{
|
||||
|
||||
$option = [
|
||||
"headers" => [
|
||||
"app_id" => config("ca.app_id"),
|
||||
@@ -214,9 +250,10 @@ class Ca
|
||||
|
||||
$arg = array_merge($arg,$option);
|
||||
|
||||
// dump(json_encode($arg,JSON_UNESCAPED_UNICODE));
|
||||
// dump(json_encode($arg,JSON_UNESCAPED_UNICODE));
|
||||
|
||||
$response = $this->client->post($path, $arg);
|
||||
|
||||
if ($response->getStatusCode() != '200'){
|
||||
// 请求失败
|
||||
throw new BusinessException($response->getBody()->getContents());
|
||||
|
||||
Reference in New Issue
Block a user