新增物流回调

This commit is contained in:
2023-03-23 10:34:25 +08:00
parent 0f4a6629da
commit ac382e288c
3 changed files with 137 additions and 11 deletions
+50 -7
View File
@@ -265,18 +265,59 @@ class Ca
*/
public function getSignedFile(string $user_id, string $file_id): mixed
{
$option = [
$arg = [
'form_params' => [
'userId' => $user_id,// 用户标识信息(为云证书entityId)
'fileId' => $file_id,// 签章接口返回的文件标识
]
];
try {
$option = [
"headers" => [
"app_id" => config("ca.app_id"),
"signature" => $this->getRequestSign($arg),
],
];
$option = array_merge($arg, $option);
$response = $this->client->post(config("ca.api_url") . '/signature-server/api/open/signature/fetchSignedFile', $option);
if ($response->getStatusCode() != '200') {
// 请求失败
throw new BusinessException($response->getBody()->getContents());
}
// 将 Stream 对象转换为字符串
return (string)$response->getBody()->getContents();
} catch (GuzzleException $e) {
throw new BusinessException($e->getMessage());
}
}
/**
* PDF签章文件验证
* @param array $data
* @return mixed
*/
public function verifyPdf(array $data): mixed
{
$option = [
'multipart' => [
[
'name' => 'pdfFile',
'contents' => $data['pdf_file'],// 待签章PDF文件(字节流)
],
]
];
try {
$response = $this->httpRequest(
config("ca.api_url") . '/signature-server/api/open/signature/fetchSignedFile',
config("ca.api_url") . '/signature-server/api/open/signature/verifyPdf',
$option
);
if (empty($response)) {
// 返回值为空
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
@@ -287,7 +328,6 @@ class Ca
}
}
/**
* 获取请求签名
* @param array $data
@@ -311,11 +351,14 @@ class Ca
}
}
ksort($sign_data);
$data = implode('&', $sign_data);
if (!empty($sign_data)){
ksort($sign_data);
$data = implode('&', $sign_data);
}else{
$data = "";
}
$data = hash_hmac("sha1", $data, config("ca.secret"));
return $data;
return hash_hmac("sha1", $data, config("ca.secret"));
}
/**