去除问诊价格调整次数限制

This commit is contained in:
wucongxing 2023-03-22 17:53:56 +08:00
parent 9074bfd30c
commit 019ac8fcc5
5 changed files with 118 additions and 93 deletions

View File

@ -19,8 +19,8 @@ class TestController extends AbstractController
// $this->test_8(); // $this->test_8();
// $this->test_3(); // $this->test_3();
// $this->test_4(); // $this->test_4();
$this->test_6(); // $this->test_6();
$this->test_9();
} }
@ -308,22 +308,12 @@ class TestController extends AbstractController
$pdf->AddPage(); $pdf->AddPage();
$pdf->Image('@' . $result, 10, 10, 0, 0, '', '', '', false, 300, '', false, false, 0, false, false, false); $pdf->Image('@' . $result, 10, 10, 0, 0, '', '', '', false, 300, '', false, false, 0, false, false, false);
return $pdf->Output("","S"); $pdf->Output(dirname(__DIR__, 2) . "/prescription_img.pdf","F");
} }
// pdf进行签章 // pdf进行签章
public function test_6(){ public function test_6(){
$pdf_file = $this->test_5(); $pdf_file = fopen("./runtime/prescription_img.pdf",'r');
// $oss = new Oss();
// $filename = "Basic/images/prescription_img.jpg";
//
// $pdf_file = $oss->getObjectToRAM($filename);
// $pdf_file = file_get_contents('./runtime/dsddasdasdasdasdasdsa.pdf');
// $pdf_file = new \CURLFILE('./runtime/dsddasdasdasdasdasdsa.pdf');
// $pdf_file = fopen("/Users/wucongxing/Desktop/work/php/hospital-applets-api/runtime/dsddasdasdasdasdasdsa.pdf",'f');
// dump($pdf_file);die;
$oss = new Oss(); $oss = new Oss();
@ -337,8 +327,6 @@ class TestController extends AbstractController
return fail(HttpEnumCode::SERVER_ERROR); return fail(HttpEnumCode::SERVER_ERROR);
} }
// $sign_image = urlencode($sign_image);
$sign_param = [ $sign_param = [
[ [
"llx"=> "700", // 左边底部X坐标 "llx"=> "700", // 左边底部X坐标
@ -355,7 +343,8 @@ class TestController extends AbstractController
$ca = new Ca(); $ca = new Ca();
$result = $ca->addSignPdf("491925054435950592",$data); $result = $ca->addSignPdf("491925054435950592",$data);
dump($result); // fclose($data['pdf_file']);
} }
// 延迟队列测试 // 延迟队列测试
@ -397,4 +386,11 @@ class TestController extends AbstractController
$ca = new Ca(); $ca = new Ca();
$result = $ca->deleteUserSignConfig("491925054435950592"); $result = $ca->deleteUserSignConfig("491925054435950592");
} }
// 下载签章的pdf文件
public function test_9(){
$ca = new Ca();
$result = $ca->getSignedFile("491925054435950592","1638477783898161153");
}
} }

View File

@ -338,30 +338,30 @@ class DoctorInquiryService extends BaseService
} }
} else { } else {
// 在线问诊限制在线问诊验证修改次数 // 在线问诊限制在线问诊验证修改次数
if ($inquiry_type == 1 && $doctor_inquiry_config['inquiry_price'] != $inquiry_price) { // if ($inquiry_type == 1 && $doctor_inquiry_config['inquiry_price'] != $inquiry_price) {
// 获取月份内总调整次数 // // 获取月份内总调整次数
$params = array(); // $params = array();
$params[] = ['doctor_id', '=', $user_info['client_user_id']]; // $params[] = ['doctor_id', '=', $user_info['client_user_id']];
$params[] = ['inquiry_config_id', '=', $doctor_inquiry_config['inquiry_config_id']]; // $params[] = ['inquiry_config_id', '=', $doctor_inquiry_config['inquiry_config_id']];
$params[] = ['created_at', '>', date('Y-m-01', time())]; // $params[] = ['created_at', '>', date('Y-m-01', time())];
$modify_month_count = DoctorInquiryPriceRecord::getCount($params); // $modify_month_count = DoctorInquiryPriceRecord::getCount($params);
if ($modify_month_count >= 5) { // if ($modify_month_count >= 5) {
// 每自然月仅限调整5次 // // 每自然月仅限调整5次
Db::rollBack(); // Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, "问诊价格每自然月仅限调整5次"); // return fail(HttpEnumCode::HTTP_ERROR, "问诊价格每自然月仅限调整5次");
} // }
//
$params = array(); // $params = array();
$params[] = ['doctor_id', '=', $user_info['client_user_id']]; // $params[] = ['doctor_id', '=', $user_info['client_user_id']];
$params[] = ['inquiry_config_id', '=', $doctor_inquiry_config['inquiry_config_id']]; // $params[] = ['inquiry_config_id', '=', $doctor_inquiry_config['inquiry_config_id']];
$params[] = ['created_at', '>', date('Y-m-d', time())]; // $params[] = ['created_at', '>', date('Y-m-d', time())];
$modify_month_count = DoctorInquiryPriceRecord::getCount($params); // $modify_month_count = DoctorInquiryPriceRecord::getCount($params);
if ($modify_month_count >= 1) { // if ($modify_month_count >= 1) {
// 问诊价格每日仅限调整1次 // // 问诊价格每日仅限调整1次
Db::rollBack(); // Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, "问诊价格每日仅限调整1次"); // return fail(HttpEnumCode::HTTP_ERROR, "问诊价格每日仅限调整1次");
} // }
} // }
// 修改 // 修改
if ($doctor_inquiry_config['work_num_day'] != $work_num_day || $doctor_inquiry_config['inquiry_price'] != $inquiry_price) { if ($doctor_inquiry_config['work_num_day'] != $work_num_day || $doctor_inquiry_config['inquiry_price'] != $inquiry_price) {

View File

@ -28,7 +28,7 @@ class PatientDoctorService extends BaseService
$expertise_id = $this->request->input('expertise_id'); $expertise_id = $this->request->input('expertise_id');
$province_id = $this->request->input('province_id'); $province_id = $this->request->input('province_id');
$city_id = $this->request->input('city_id'); $city_id = $this->request->input('city_id');
$sort_order = $this->request->input('sort_order'); $sort_order = $this->request->input('sort_order',1);
$keyword = $this->request->input('keyword',""); $keyword = $this->request->input('keyword',"");
$page = $this->request->input('page',1); $page = $this->request->input('page',1);
$per_page = $this->request->input('per_page',10); $per_page = $this->request->input('per_page',10);

View File

@ -141,4 +141,5 @@ class Oss
throw new BusinessException($e->getMessage()); throw new BusinessException($e->getMessage());
} }
} }
} }

View File

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