From 70932a142c85e453fd77a076c45f7f2bf95e2752 Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Thu, 30 Mar 2023 17:28:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8C=BB=E7=94=9F=E5=BC=80?= =?UTF-8?q?=E5=85=B7=E5=A4=84=E6=96=B9=E5=AF=B9=E6=8E=A5ca=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Controller/TestController.php | 15 +++++++-- app/Services/OrderPrescriptionService.php | 18 ++++++++--- app/Services/UserDoctorService.php | 39 +++++++++++++++++------ 3 files changed, 57 insertions(+), 15 deletions(-) diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index b589293..69020a4 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -5,6 +5,7 @@ namespace App\Controller; use App\Amqp\Producer\AssignDoctorProducer; use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer; use App\Constants\HttpEnumCode; +use App\Exception\BusinessException; use App\Model\DoctorInquiryTime; use App\Model\DoctorPharmacistCert; use App\Model\OrderInquiry; @@ -503,7 +504,17 @@ class TestController extends AbstractController } public function test_11(){ - $OrderPrescriptionService = new OrderPrescriptionService(); - $result = $OrderPrescriptionService->doctorOpenPrescription("499871705345941504",1); +// $ca = new Ca(); +// $prescription_pdf_result = $ca->getSignedFile("491925054435950592","1641368425758359554"); +// if (empty($prescription_pdf_result)){ +// throw new BusinessException("下载处方签章文件失败"); +// } +// +// $oss = new Oss(); +// $filename = "applet/prescription/" . "499993319660314624" . '.' . 'pdf'; +// $prescription_pdf_url = $oss->putObject($filename, $prescription_pdf_result); + +// $OrderPrescriptionService = new OrderPrescriptionService(); +// $result = $OrderPrescriptionService->openPrescription("499871705345941504",1); } } \ No newline at end of file diff --git a/app/Services/OrderPrescriptionService.php b/app/Services/OrderPrescriptionService.php index a4322b5..03c252c 100644 --- a/app/Services/OrderPrescriptionService.php +++ b/app/Services/OrderPrescriptionService.php @@ -235,17 +235,20 @@ class OrderPrescriptionService extends BaseService $product['prescription_product_num'] = $item['prescription_product_num'] . $item['packaging_unit']; // 商品数量 + 基本包装单位(例:盒/瓶) $data['product'][] = $product; } - + dump("签名获取成功"); $cert_sign_result = $ca->getCertSign("491925054435950592", "491925054435950592", $data); // 验证云证书签名-验证无需处理,只要不返回错误即可 $ca->verifyPkcs7($cert_sign_result['signP7'],$data); - - // 生成处方pdf图片 + dump("签名验证成功"); + // 下载基础处方pdf图片 $oss = new Oss(); $filename = "basic/file/prescription.jpg"; $prescription_image = $oss->getObjectToRAM($filename); + + dump("下载基础处方pdf图片成功"); + $manager = new ImageManager(); $image = $manager->make($prescription_image); @@ -361,6 +364,7 @@ class OrderPrescriptionService extends BaseService // 图片生成的处方pdf存储为本地文件 $pdf->Output(dirname(__DIR__, 2) . "/" . $filename ,"F"); + dump("图片生成pdf成功"); // 下载签名图片 $style = "image/resize,m_lfit,w_100,h_350"; $sign_image = $oss->getCusTomObjectToRAM($sign_image_path,$style); @@ -369,6 +373,8 @@ class OrderPrescriptionService extends BaseService throw new BusinessException("签名图片下载失败"); } + dump("下载签名图片成功"); + if ($user['user_type'] == 2){ $sign_param = [ [ // 医生端 @@ -406,13 +412,17 @@ class OrderPrescriptionService extends BaseService throw new BusinessException("处方签章失败"); } + dump("处方pdf进行签章成功"); + // 下载处方签章文件 $file_id = $sign_pdf_result[0]['fileId']; $prescription_pdf_result = $ca->getSignedFile("491925054435950592",$file_id); - if (empty($result)){ + if (empty($prescription_pdf_result)){ throw new BusinessException("下载处方签章文件失败"); } + dump("下载处方签章文件成功"); + // 上传oss $filename = "applet/prescription/" . $order_prescription['order_prescription_id'] . '.' . 'pdf'; $prescription_pdf_url = $oss->putObject($filename, $prescription_pdf_result); diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index 449801a..ac2c3a8 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -27,6 +27,7 @@ use App\Model\OrderPrescriptionIcd; use App\Model\OrderPrescriptionProduct; use App\Model\OrderProductItem; use App\Model\Product; +use App\Model\ProductPlatformAmount; use App\Model\SystemInquiryConfig; use App\Model\SystemInquiryTime; use App\Model\User; @@ -1147,7 +1148,7 @@ class UserDoctorService extends BaseService $prescription_icd = $this->request->input('prescription_icd'); $doctor_advice = $this->request->input('doctor_advice'); $prescription_product = $this->request->input('prescription_product'); - return success(); + // 获取医生信息 $params = array(); $params['doctor_id'] = $user_info['client_user_id']; @@ -1237,18 +1238,25 @@ class UserDoctorService extends BaseService // 商品数据 foreach ($prescription_product as $item) { // 获取商品数据 - $params = array(); + $params =array(); $params['product_id'] = $item['product_id']; - $product = Product::getWithAmountOne($params); - if (empty($product)) { - Db::rollBack(); - return fail(HttpEnumCode::HTTP_ERROR,"商品库存不足"); + $product = Product::getOne($params); + if (empty($product)){ + return fail(HttpEnumCode::SERVER_ERROR,"商品错误"); } - if (empty($product['ProductPlatformAmount'])) { + // 获取商品库存 + $params =array(); + $params['product_platform_id'] = $product['product_platform_id']; + $product_platform_amount = ProductPlatformAmount::getOne($params); + if (empty($product_platform_amount)) { // 无药品库存数据 Db::rollBack(); - return fail(); + return fail(HttpEnumCode::SERVER_ERROR,"无药品库存数据"); + } + + if ($product_platform_amount['stock'] <= 0){ + return fail(HttpEnumCode::HTTP_ERROR,"商品库存不足"); } // 检测药品库存数据 @@ -1283,7 +1291,20 @@ class UserDoctorService extends BaseService $OrderPrescriptionService = new OrderPrescriptionService(); - $prescription_img = $OrderPrescriptionService->openPrescription($order_prescription->order_prescription_id,$order_inquiry['order_inquiry_id']); + $prescription_img = $OrderPrescriptionService->openPrescription($order_prescription->order_prescription_id,$user_info['user_id']); + if (empty($prescription_img)){ + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR, "处方开具失败"); + } + + // 修改处方表 + $data = array(); + $data['prescription_img'] = $prescription_img; + $data['doctor_created_time'] = date('Y-m-d H:i:s',time()); + + $params = array(); + $params['order_prescription_id'] = $order_prescription->order_prescription_id; + OrderPrescription::edit($params,$data); // 加入分配药师队列 $data = array();