去除问诊价格调整次数限制
This commit is contained in:
+79
-51
@@ -24,7 +24,8 @@ class Ca
|
||||
#[Inject]
|
||||
protected Client $client;
|
||||
|
||||
public function __construct(){
|
||||
public function __construct()
|
||||
{
|
||||
$this->container = ApplicationContext::getContainer();
|
||||
$this->client = $this->container->get(Client::class);
|
||||
}
|
||||
@@ -47,7 +48,7 @@ class Ca
|
||||
|
||||
try {
|
||||
$response = $this->httpRequest(config("ca.api_url") . '/cloud-certificate-service' . '/api/cloudCert/open/v2/cert/offlineAuthCertEnroll', $option);
|
||||
if (empty($response)){
|
||||
if (empty($response)) {
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
@@ -64,12 +65,12 @@ class Ca
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCertSign(string $user_id,string $pin,array $data): mixed
|
||||
public function getCertSign(string $user_id, string $pin, array $data): mixed
|
||||
{
|
||||
$option = [
|
||||
'form_params' => [
|
||||
'entityId' => $user_id, // 用户唯一标识,由业务系统定义
|
||||
'toSign' => hash_hmac("sha1",json_encode($data,JSON_UNESCAPED_UNICODE),config("ca.secret")), // 签名原文
|
||||
'toSign' => hash_hmac("sha1", json_encode($data, JSON_UNESCAPED_UNICODE), config("ca.secret")), // 签名原文
|
||||
'pin' => $pin, // 证书PIN码
|
||||
]
|
||||
];
|
||||
@@ -79,7 +80,7 @@ class Ca
|
||||
config("ca.api_url") . '/cloud-certificate-service' . '/api/cloudCert/open/cert/sign',
|
||||
$option
|
||||
);
|
||||
if (empty($response)){
|
||||
if (empty($response)) {
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
@@ -91,7 +92,8 @@ class Ca
|
||||
|
||||
// PKCS7签名验证接口
|
||||
// 对客户端签名信息进行验证,返回证书信息,同时可以配置回调服务,在验证成功后回调业务系统
|
||||
public function verifyPkcs7(string $sign_p7,array $data){
|
||||
public function verifyPkcs7(string $sign_p7, array $data)
|
||||
{
|
||||
$generator = $this->container->get(IdGeneratorInterface::class);
|
||||
|
||||
$option = [
|
||||
@@ -99,7 +101,7 @@ class Ca
|
||||
'opType' => "签名验证",
|
||||
'requestId' => $generator->generate(),// 业务流水号,唯一
|
||||
'signedData' => $sign_p7, // 签名值:签名接口返回的signP7
|
||||
'toSign' => hash_hmac("sha1",json_encode($data,JSON_UNESCAPED_UNICODE),config("ca.secret")), // 签名原文
|
||||
'toSign' => hash_hmac("sha1", json_encode($data, JSON_UNESCAPED_UNICODE), config("ca.secret")), // 签名原文
|
||||
]
|
||||
];
|
||||
|
||||
@@ -108,7 +110,7 @@ class Ca
|
||||
config("ca.api_url") . '/signgw-service/api/signature/verifyPkcs7',
|
||||
$option
|
||||
);
|
||||
if (empty($response)){
|
||||
if (empty($response)) {
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
@@ -125,7 +127,7 @@ class Ca
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function addUserSignConfig(string $user_id,string $card_num,array $data): mixed
|
||||
public function addUserSignConfig(string $user_id, string $card_num, array $data): mixed
|
||||
{
|
||||
$option = [
|
||||
'form_params' => [
|
||||
@@ -196,7 +198,7 @@ class Ca
|
||||
config("ca.api_url") . '/signature-server/api/open/signature/fetchUserSeal',
|
||||
$option
|
||||
);
|
||||
if (empty($response)){
|
||||
if (empty($response)) {
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
@@ -208,35 +210,32 @@ class Ca
|
||||
|
||||
/**
|
||||
* PDF添加电子签章
|
||||
* @param string $user_id
|
||||
* @param array $data
|
||||
* @return mixed
|
||||
*/
|
||||
public function addSignPdf(string $user_id,array $data){
|
||||
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码,云证书签章时使用
|
||||
// ],
|
||||
'multipart' => [
|
||||
[
|
||||
'name' => 'pdfFile',
|
||||
'contents' => $data['pdf_file'],
|
||||
'name' => 'pdfFile',
|
||||
'contents' => $data['pdf_file'],// 待签章PDF文件(字节流)
|
||||
],
|
||||
[
|
||||
'name' => 'userId',
|
||||
'name' => 'userId',
|
||||
'contents' => $user_id, // 用户标识信息
|
||||
],
|
||||
[
|
||||
'name' => 'configKey',
|
||||
'name' => 'configKey',
|
||||
'contents' => $user_id, // 签章配置唯一标识
|
||||
],
|
||||
[
|
||||
'name' => 'signParams',
|
||||
'name' => 'signParams',
|
||||
'contents' => $data['sign_param'],// 签章参数,JSON格式数据,如果不指定,那么以签章配置接口配置为准
|
||||
],
|
||||
[
|
||||
'name' => 'cloudCertPass',
|
||||
'name' => 'cloudCertPass',
|
||||
'contents' => $user_id,// 云证书PIN码,云证书签章时使用
|
||||
],
|
||||
]
|
||||
@@ -248,7 +247,37 @@ class Ca
|
||||
$option
|
||||
);
|
||||
|
||||
if (empty($response)){
|
||||
if (empty($response)) {
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
return $response;
|
||||
} catch (GuzzleException $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载签章的pdf文件
|
||||
* @param string $user_id
|
||||
* @param string $file_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSignedFile(string $user_id, string $file_id): mixed
|
||||
{
|
||||
$option = [
|
||||
'form_params' => [
|
||||
'userId' => $user_id,// 用户标识信息(为云证书entityId)
|
||||
'fileId' => $file_id,// 签章接口返回的文件标识
|
||||
]
|
||||
];
|
||||
|
||||
try {
|
||||
$response = $this->httpRequest(
|
||||
config("ca.api_url") . '/signature-server/api/open/signature/fetchSignedFile',
|
||||
$option
|
||||
);
|
||||
if (empty($response)) {
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
@@ -259,7 +288,6 @@ class Ca
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取请求签名
|
||||
* @param array $data
|
||||
@@ -267,22 +295,26 @@ class Ca
|
||||
*/
|
||||
protected function getRequestSign(array $data): string
|
||||
{
|
||||
// pdf进行签章时,此参数为文件流,不参与签名
|
||||
unset($data['form_params']['pdfFile']);
|
||||
$sign_data = array();
|
||||
if (isset($data['form_params'])) {
|
||||
$sign_data = $data['form_params'];
|
||||
}
|
||||
|
||||
// signParams参数计算时不进行urlencode处理
|
||||
// if (isset($data['form_params']['signParams'])){
|
||||
// $sign_param = json_decode($data['form_params']['signParams'],true);
|
||||
// $sign_param[0]['sealImg'] = urldecode($sign_param[0]['sealImg']);
|
||||
//
|
||||
// $data['form_params']['signParams'] = json_encode($sign_param);
|
||||
// }
|
||||
if (isset($data['multipart'])) {
|
||||
foreach ($data['multipart'] as $item) {
|
||||
// pdf进行签章时,此参数为文件流,不参与签名
|
||||
if ($item['name'] == "pdfFile") {
|
||||
continue;
|
||||
}
|
||||
|
||||
$sign_data[$item['name']] = $item['contents'];
|
||||
}
|
||||
}
|
||||
|
||||
ksort($data['form_params']);
|
||||
$data = implode('&',$data['form_params']);
|
||||
dump($data);
|
||||
$data = hash_hmac("sha1",$data,config("ca.secret"));
|
||||
ksort($sign_data);
|
||||
$data = implode('&', $sign_data);
|
||||
|
||||
$data = hash_hmac("sha1", $data, config("ca.secret"));
|
||||
return $data;
|
||||
}
|
||||
|
||||
@@ -293,7 +325,7 @@ class Ca
|
||||
* @return mixed
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
protected function httpRequest(string $path,array $arg = []): mixed
|
||||
protected function httpRequest(string $path, array $arg = []): mixed
|
||||
{
|
||||
$option = [
|
||||
"headers" => [
|
||||
@@ -302,28 +334,24 @@ class Ca
|
||||
],
|
||||
];
|
||||
|
||||
$arg = array_merge($arg,$option);
|
||||
$arg = array_merge($arg, $option);
|
||||
|
||||
try {
|
||||
$response = $this->client->post($path, $arg);
|
||||
}catch(\Exception $e){
|
||||
dump($e->getMessage());
|
||||
}
|
||||
$response = $this->client->post($path, $arg);
|
||||
|
||||
if ($response->getStatusCode() != '200'){
|
||||
if ($response->getStatusCode() != '200') {
|
||||
// 请求失败
|
||||
throw new BusinessException($response->getBody()->getContents());
|
||||
}
|
||||
$body = json_decode($response->getBody(),true);
|
||||
$body = json_decode($response->getBody(), true);
|
||||
dump($body);
|
||||
if (empty($body)){
|
||||
if (empty($body)) {
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
|
||||
if ($body['result_code'] != 0){
|
||||
if ($body['result_code'] != 0) {
|
||||
// 请求失败
|
||||
if (!empty($body['result_msg'])){
|
||||
if (!empty($body['result_msg'])) {
|
||||
throw new BusinessException($body['result_msg']);
|
||||
}
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
|
||||
Reference in New Issue
Block a user