+20
-14
@@ -12,7 +12,8 @@ use App\Model\UserDoctor;
|
||||
use App\Model\UserDoctorInfo;
|
||||
use App\Model\UserPharmacistInfo;
|
||||
use Extend\Alibaba\Oss;
|
||||
use Extend\Ca\CaOnline;
|
||||
use Extend\Ca\Ca;
|
||||
use Extend\Ca\CaGatewayFactory;
|
||||
use Hyperf\Utils\WaitGroup;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Swoole\Coroutine\Channel;
|
||||
@@ -23,6 +24,8 @@ use TCPDF;
|
||||
*/
|
||||
class CaService extends BaseService
|
||||
{
|
||||
protected Ca $caGateway;
|
||||
|
||||
// 疾病名称
|
||||
protected string $icd_name;
|
||||
|
||||
@@ -63,6 +66,8 @@ class CaService extends BaseService
|
||||
* @param int $type 类型 1:医院 2:医生 3:药师
|
||||
*/
|
||||
public function __construct(array|object $order_prescription,int $type,string|int $user_id = ""){
|
||||
$this->caGateway = $this->buildGateway();
|
||||
|
||||
// 获取用户、医院签名图片地址、用户标识信息
|
||||
if ($type == 1){
|
||||
// 医院
|
||||
@@ -223,13 +228,18 @@ class CaService extends BaseService
|
||||
$this->prescription_pdf_oss_path = "applet/prescription/" . $order_prescription_id. '.pdf';
|
||||
}
|
||||
|
||||
protected function buildGateway(): Ca
|
||||
{
|
||||
return CaGatewayFactory::makeScene('prescription');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取云证书签名+验证云证书签名
|
||||
* @param array|object $order_prescription
|
||||
*/
|
||||
public function getVerifyCertSign(array|object $order_prescription)
|
||||
{
|
||||
$CaOnline = new CaOnline();
|
||||
$caGateway = $this->caGateway;
|
||||
|
||||
// 获取云证书签名
|
||||
$data = array();
|
||||
@@ -254,11 +264,10 @@ class CaService extends BaseService
|
||||
$data['product'][] = $product;
|
||||
}
|
||||
|
||||
dump($this->entity_id);
|
||||
$cert_sign_result = $CaOnline->getCertSign($this->entity_id, $this->entity_id, $data);
|
||||
$cert_sign_result = $caGateway->getCertSign($this->entity_id, $this->entity_id, $data);
|
||||
|
||||
// 验证云证书签名 验证无需处理,只要不返回错误即可
|
||||
$CaOnline->verifyPkcs7($cert_sign_result['signP7'], $data);
|
||||
$caGateway->verifyPkcs7($cert_sign_result['signP7'], $data);
|
||||
|
||||
$this->cert_serial_number = $cert_sign_result['certSerialnumber'];
|
||||
}
|
||||
@@ -421,8 +430,7 @@ class CaService extends BaseService
|
||||
*/
|
||||
public function downCaPdfToLocal(string $file_id): void
|
||||
{
|
||||
$CaOnline = new CaOnline();
|
||||
$prescription_pdf_result = $CaOnline->getSignedFile($this->entity_id, $file_id);
|
||||
$prescription_pdf_result = $this->caGateway->getSignedFile($this->entity_id, $file_id);
|
||||
|
||||
$file = fopen($this->prescription_pdf_local_path, "w");
|
||||
fwrite($file, $prescription_pdf_result);
|
||||
@@ -436,9 +444,7 @@ class CaService extends BaseService
|
||||
*/
|
||||
public function downCaPdfToOss(string $file_id): string
|
||||
{
|
||||
$CaOnline = new CaOnline();
|
||||
|
||||
$prescription_pdf_result = $CaOnline->getSignedFile($this->entity_id, $file_id);
|
||||
$prescription_pdf_result = $this->caGateway->getSignedFile($this->entity_id, $file_id);
|
||||
|
||||
// 上传oss
|
||||
$oss = new Oss();
|
||||
@@ -498,7 +504,7 @@ class CaService extends BaseService
|
||||
],
|
||||
];
|
||||
|
||||
$CaOnline = new CaOnline();
|
||||
$caGateway = $this->caGateway;
|
||||
|
||||
// 检测是否已添加签章配置
|
||||
$params = array();
|
||||
@@ -514,7 +520,7 @@ class CaService extends BaseService
|
||||
$data['sign_param'] = json_encode($sign_param);
|
||||
$data['seal_img'] = $sign_image;
|
||||
|
||||
$CaOnline->addUserSignConfig($this->entity_id,$this->card_num,$data);
|
||||
$caGateway->addUserSignConfig($this->entity_id,$this->card_num,$data);
|
||||
|
||||
$params = array();
|
||||
$params['cert_id'] = $user_ca_cert['cert_id'];
|
||||
@@ -535,11 +541,11 @@ class CaService extends BaseService
|
||||
$data = array();
|
||||
$data['sign_param'] = json_encode($sign_param);
|
||||
$data['pdf_file'] = $pdf_file;
|
||||
$sign_pdf_result = $CaOnline->addSignPdf($this->entity_id, $data);
|
||||
$sign_pdf_result = $caGateway->addSignPdf($this->entity_id, $data);
|
||||
if (empty($sign_pdf_result[0]['fileId'])) {
|
||||
throw new BusinessException("处方签章失败");
|
||||
}
|
||||
|
||||
return $sign_pdf_result[0]['fileId'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user