新增处方上报处方平台,未开发完毕,修改药品订单支付金额为0.01
This commit is contained in:
parent
afa721104e
commit
1651896958
@ -7,6 +7,7 @@ use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\DoctorInquiryTime;
|
||||
use App\Model\OrderPrescriptionProduct;
|
||||
use App\Model\UserCaCert;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderPrescription;
|
||||
@ -575,134 +576,30 @@ class TestController extends AbstractController
|
||||
}
|
||||
|
||||
public function test_11(){
|
||||
$oss = new Oss();
|
||||
$prescription_pdf = $oss->getObjectToLocal("applet/prescription/500341310934036481.pdf","./runtime/test.pdf");
|
||||
dump($prescription_pdf);
|
||||
$order_prescription_id = "";
|
||||
|
||||
// 获取处方数据
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_prescription_id;
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)) {
|
||||
throw new BusinessException("处方数据错误");
|
||||
}
|
||||
|
||||
// pdf进行签章
|
||||
public function test_12(){
|
||||
$ca = new Ca();
|
||||
|
||||
$pdf_file = fopen("./runtime/prescription.pdf",'r');
|
||||
|
||||
$oss = new Oss();
|
||||
|
||||
$filename = "basic/file/hospital_signature.png";
|
||||
|
||||
$style = "image/resize,w_300,h_300";
|
||||
|
||||
$sign_image = $oss->getCusTomObjectToRAM($filename,$style);
|
||||
$sign_image = base64_encode($sign_image);
|
||||
if (!$sign_image){
|
||||
return fail(HttpEnumCode::SERVER_ERROR);
|
||||
// 获取处方关联商品数据
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_prescription_id;
|
||||
$order_prescription_product = OrderPrescriptionProduct::getList($params);
|
||||
if (empty($order_prescription_product)) {
|
||||
throw new BusinessException("处方药品数据错误");
|
||||
}
|
||||
|
||||
$sign_param = [
|
||||
[ // 医院签章
|
||||
"llx"=>"1550", // 左边底部X坐标
|
||||
"lly"=>"1350", // 左边底部Y坐标
|
||||
"urx"=>"2250", // 右边上部x坐标
|
||||
"ury"=>"650", // 右边上部y坐标
|
||||
"pageList"=>[1],
|
||||
"sealImg"=>$sign_image
|
||||
],
|
||||
// [ // 药师端
|
||||
// "llx"=>"350", // 左边底部X坐标
|
||||
// "lly"=>"190", // 左边底部Y坐标
|
||||
// "urx"=>"440", // 右边上部x坐标
|
||||
// "ury"=>"140", // 右边上部y坐标
|
||||
// "pageList"=>[1],
|
||||
// "sealImg"=>$sign_image
|
||||
// ]
|
||||
];
|
||||
$data = array();
|
||||
$data['sign_param'] = json_encode($sign_param);
|
||||
$data['pdf_file'] = $pdf_file;
|
||||
|
||||
|
||||
$result = $ca->addSignPdf("5345345461",$data);
|
||||
|
||||
$file_id = $result[0]['fileId'];
|
||||
|
||||
$result = $ca->getSignedFile("5345345461",$file_id);
|
||||
if (empty($result)){
|
||||
return fail();
|
||||
$OrderPrescriptionService = new OrderPrescriptionService();
|
||||
$result = $OrderPrescriptionService->reportPrescription();
|
||||
}
|
||||
|
||||
$file = fopen("./runtime/test.pdf", "w") or die("Unable to open file!");
|
||||
fwrite($file, $result);
|
||||
fclose($file);
|
||||
|
||||
// 上传阿里云oss
|
||||
|
||||
// $oss = new Oss();
|
||||
//
|
||||
// $filename = "applet/doctor/prescription/test.pdf";
|
||||
//
|
||||
// $result = $oss->putObject($filename, $result);
|
||||
// dump($result);
|
||||
}
|
||||
|
||||
public function test_13(){
|
||||
$oss = new Oss();
|
||||
$hospital_sign_image_path = "basic/file/hospital_signature.png";
|
||||
|
||||
// 下载医院签名图片
|
||||
$style = "image/resize,w_300,h_300";
|
||||
$sign_image = $oss->getCusTomObjectToRAM($hospital_sign_image_path,$style);
|
||||
$sign_image = base64_encode($sign_image);
|
||||
if (!$sign_image){
|
||||
throw new BusinessException("医院签名图片下载失败");
|
||||
}
|
||||
|
||||
$sign_param = [
|
||||
[ // 医院签章
|
||||
"llx"=>"370", // 左边底部X坐标 控制左右(越小越左)
|
||||
"lly"=>"210", // 左边底部Y坐标 控制上下(越小越下)
|
||||
"urx"=>"520", // 右边上部x坐标
|
||||
"ury"=>"360", // 右边上部y坐标
|
||||
"pageList"=>[1],
|
||||
"sealImg"=>$sign_image
|
||||
],
|
||||
];
|
||||
|
||||
// 打开处方pdf文件
|
||||
unset($pdf_file);
|
||||
$pdf_file = fopen("./runtime/" . "501402833412673536" . ".pdf",'r');
|
||||
|
||||
$ca = new Ca();
|
||||
|
||||
// 处方pdf进行签章
|
||||
$data = array();
|
||||
$data['sign_param'] = json_encode($sign_param);
|
||||
$data['pdf_file'] = $pdf_file;
|
||||
$hospital_sign_pdf_result = $ca->addSignPdf("5345345461",$data);
|
||||
if (empty($hospital_sign_pdf_result[0]['fileId'])){
|
||||
throw new BusinessException("处方签章失败");
|
||||
}
|
||||
|
||||
dump($hospital_sign_pdf_result);
|
||||
|
||||
dump("处方pdf进行医院签章成功");
|
||||
|
||||
|
||||
|
||||
// 下载处方签章文件
|
||||
unset($prescription_pdf_result);
|
||||
$file_id = $hospital_sign_pdf_result[0]['fileId'];
|
||||
$prescription_pdf_result = $ca->getSignedFile("5345345461",$file_id);
|
||||
|
||||
if (empty($prescription_pdf_result)){
|
||||
throw new BusinessException("下载处方签章文件失败");
|
||||
}
|
||||
|
||||
dump("下载医院处方签章文件成功");
|
||||
|
||||
$file = fopen("./runtime/test.pdf", "w") or die("Unable to open file!");
|
||||
fwrite($file, $prescription_pdf_result);
|
||||
fclose($file);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -207,7 +207,9 @@ class OrderPrescription extends Model
|
||||
"OrderPrescriptionIcd:prescription_icd_id,order_prescription_id,icd_name",
|
||||
"OrderPrescriptionProduct:prescription_product_id,order_prescription_id,product_name,product_spec"
|
||||
])
|
||||
->where($params)->paginate($per_page, $fields, "page", $page);
|
||||
->where($params)
|
||||
->orderBy("created_at",'desc')
|
||||
->paginate($per_page, $fields, "page", $page);
|
||||
|
||||
$data = array();
|
||||
$data['current_page'] = $raw->currentPage();// 当前页码
|
||||
|
||||
@ -4,6 +4,8 @@ namespace App\Services;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\PatientFamily;
|
||||
use App\Model\Product;
|
||||
use App\Model\UserCaCert;
|
||||
use App\Model\HospitalDepartmentCustom;
|
||||
use App\Model\OrderInquiryCase;
|
||||
@ -14,6 +16,7 @@ use App\Model\OrderProductItem;
|
||||
use App\Model\User;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserDoctorInfo;
|
||||
use App\Model\UserPharmacist;
|
||||
use App\Model\UserPharmacistInfo;
|
||||
use Extend\Alibaba\Oss;
|
||||
use Extend\Ca\Ca;
|
||||
@ -108,7 +111,6 @@ class OrderPrescriptionService extends BaseService
|
||||
return OrderPrescription::getCount($params);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 开具处方
|
||||
* 医生-正常开具
|
||||
@ -223,7 +225,11 @@ class OrderPrescriptionService extends BaseService
|
||||
// 处理疾病数据
|
||||
$icd_name = array_column($order_prescription_icd->toArray(), 'icd_name');
|
||||
if (!empty($icd_name)) {
|
||||
if (count($icd_name > 1)){
|
||||
$icd_name = implode(';', $icd_name);
|
||||
}else{
|
||||
$icd_name = $icd_name[0];
|
||||
}
|
||||
} else {
|
||||
$icd_name = "";
|
||||
}
|
||||
@ -550,4 +556,171 @@ class OrderPrescriptionService extends BaseService
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// 上报处方平台
|
||||
public function reportPrescription(array $order_inquiry, array $order_prescription, array $order_prescription_product, array $order_product)
|
||||
{
|
||||
// 获取就诊患者用户数据
|
||||
$params = array();
|
||||
$params['user_id'] = $order_inquiry['user_id'];
|
||||
$user = User::getOne($params);
|
||||
if (empty($user)){
|
||||
throw new BusinessException("用户数据错误");
|
||||
}
|
||||
|
||||
// 获取家庭成员-基本信息
|
||||
$params = array();
|
||||
$params['family_id'] = $order_inquiry['family_id'];
|
||||
$patient_family = PatientFamily::getOne($params);
|
||||
if (empty($patient_family)){
|
||||
throw new BusinessException("用户家庭成员错误");
|
||||
}
|
||||
|
||||
// 获取处方关联疾病数据
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_prescription['order_prescription_id'];
|
||||
$order_prescription_icd = OrderPrescriptionIcd::getList($params);
|
||||
if (empty($order_prescription_icd)) {
|
||||
throw new BusinessException("处方疾病数据错误");
|
||||
}
|
||||
|
||||
// 处理疾病数据
|
||||
$icd_name = array_column($order_prescription_icd->toArray(), 'icd_name');
|
||||
if (!empty($icd_name)) {
|
||||
if (count($icd_name > 1)){
|
||||
$icd_name = implode(';', $icd_name);
|
||||
}else{
|
||||
$icd_name = $icd_name[0];
|
||||
}
|
||||
} else {
|
||||
$icd_name = "";
|
||||
}
|
||||
|
||||
// 获取医生数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_prescription['doctor_id'];
|
||||
$user_doctor = UserDoctor::getOne($params);
|
||||
if (empty($user_doctor)) {
|
||||
throw new BusinessException("医生数据错误");
|
||||
}
|
||||
|
||||
// 获取医生科室
|
||||
$params = array();
|
||||
$params['department_custom_id'] = $user_doctor['department_custom_id'];
|
||||
$hospital_department_custom = HospitalDepartmentCustom::getOne($params);
|
||||
if (empty($hospital_department_custom)) {
|
||||
throw new BusinessException("医生科室数据错误");
|
||||
}
|
||||
|
||||
// 获取医生详情数据
|
||||
$params = array();
|
||||
$params['doctor_id'] = $order_prescription['doctor_id'];
|
||||
$user_doctor_info = UserDoctorInfo::getOne($params);
|
||||
if (empty($user_doctor_info)){
|
||||
throw new BusinessException("医生详情数据错误");
|
||||
}
|
||||
|
||||
// 获取药师数据
|
||||
$params = array();
|
||||
$params['pharmacist_id'] = $order_prescription['pharmacist_id'];
|
||||
$user_pharmacist = UserPharmacist::getOne($params);
|
||||
if (empty($user_pharmacist)){
|
||||
throw new BusinessException("药师数据错误");
|
||||
}
|
||||
|
||||
// 获取药师详情数据
|
||||
$params = array();
|
||||
$params['pharmacist_id'] = $order_prescription['pharmacist_id'];
|
||||
$user_pharmacist_info = UserPharmacistInfo::getOne($params);
|
||||
if (empty($user_pharmacist_info)){
|
||||
throw new BusinessException("药师详情数据错误");
|
||||
}
|
||||
|
||||
// 获取病例数据
|
||||
$params = array();
|
||||
$params['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
|
||||
$params['status'] = 1;
|
||||
$order_inquiry_case = OrderInquiryCase::getOne($params);
|
||||
if (empty($order_inquiry_case)){
|
||||
throw new BusinessException("病例数据错误");
|
||||
}
|
||||
|
||||
$arg = array();
|
||||
$arg['terminalCode'] = "JG-10009";
|
||||
$arg['orderNo'] = $order_product['order_product_no']; // 支付流水号
|
||||
$arg['transactNo'] = $order_product['escrow_trade_no']; // 支付流水号
|
||||
$arg['payDate'] = $order_product['pay_time']; // 支付时间
|
||||
$arg['money'] = $order_product['payment_amount_total']; // 订单金额
|
||||
$arg['takeTypeCode'] = 2; // 取货方式 1 自提 2 快递,目 前只支持快递,传 固定值 2
|
||||
$arg['buyerName'] = $order_product['consignee_name'];// 收货人姓名
|
||||
$arg['buyerPhone'] = $order_product['consignee_tel'];// 收货人联系方式
|
||||
$arg['buyerAddress'] = $order_product['address'];// 收货人地址
|
||||
$arg['provinceCode'] = $order_product['province_id']; // 收货地址(省) 编码
|
||||
$arg['provinceName'] = $order_product['province']; // 收货地址(省) 名称
|
||||
$arg['cityCode'] = $order_product['city_id']; // 收货地址(市) 编码
|
||||
$arg['cityName'] = $order_product['city']; // 收货地址(市) 名称
|
||||
$arg['districtCode'] = $order_product['county_id']; // 收货地址(区 县)编码
|
||||
$arg['districtName'] = $order_product['county']; // 收货地址(区 县)名称
|
||||
$arg['freight'] = $order_product['logistics_fee']; // 运费(单位:元)
|
||||
$arg['prescriptionNo'] = $order_prescription['prescription_code']; // 处方编号
|
||||
$arg['prescriptionSubType'] = 1; // 处方类型 0:无类型 1:普 通处方 2:儿科处 方
|
||||
$arg['patientName'] = $order_prescription['patient_name']; // 就诊人姓名
|
||||
$arg['patientPhone'] = $user['mobile']; // 就诊人联系方式
|
||||
$arg['idCard'] = $patient_family['id_number']; // 身份证号
|
||||
$arg['advice'] = $order_prescription['doctor_advice'] ?: ""; // 医嘱
|
||||
$arg['diagnosisName'] = $icd_name ?: ""; // 诊断
|
||||
$arg['thirdDoctorName'] = $user_doctor['user_name']; // 开方医生姓名
|
||||
$arg['thirdDeptName'] = $hospital_department_custom['department_name'] ?: ""; // 开方科室名称
|
||||
$arg['thirdDoctorNameImg'] = addAliyunOssWebsite($user_doctor_info['sign_image']); // 开方医生签名链接
|
||||
$arg['prescriptionTime'] = $order_prescription['doctor_created_time']; // 开方时间
|
||||
$arg['thirdFirstPharmacist'] = $user_pharmacist['user_name']; // 初审药师姓名
|
||||
$arg['thirdFirstPharmacistImg'] = addAliyunOssWebsite($user_pharmacist_info['sign_image']); // 初审药师签名链接
|
||||
$arg['thirdFirstTime'] = $order_prescription['pharmacist_verify_time']; // 初审时间
|
||||
$arg['thirdLastPharmacist'] = $user_pharmacist['user_name']; // 终审药师姓名
|
||||
$arg['thirdLastPharmacistImg'] = addAliyunOssWebsite($user_pharmacist_info['sign_image']); // 终审药师签名 链接
|
||||
$arg['ThirdLastTime'] = $order_prescription['pharmacist_verify_time']; // 终审时间
|
||||
$arg['thirdSignImg'] = addAliyunOssWebsite("/basic/file/hospital_signature.png"); // 处方签章链接
|
||||
$arg['referenceCharge'] = $order_product['amount_total']; // 处方费用
|
||||
$arg['chiefComplaint'] = $order_inquiry_case['disease_desc'] ?: ""; // 主诉
|
||||
$arg['historyPresent'] = $order_inquiry_case['disease_class_name'] ?: ""; // 现病史
|
||||
$arg['pastHistory'] = $order_inquiry_case['family_history'] ?: "无"; // 既往史
|
||||
$arg['physicalExamination'] = "无"; // 体格检查
|
||||
$arg['supplementaryExamination'] = "无"; // 辅助检查
|
||||
$arg['allergicHistory'] = $order_inquiry_case['allergy_history'] ?: "无"; // 过敏史
|
||||
|
||||
// 药品数据
|
||||
foreach ($order_prescription_product as $key => $item){
|
||||
// 获取商品数据
|
||||
$pamras = array();
|
||||
$pamras['product_id'] = $item['product_id'];
|
||||
$product = Product::getOne($pamras);
|
||||
if (empty($product)){
|
||||
throw new BusinessException("药品数据错误");
|
||||
}
|
||||
|
||||
$arg['drugList'][$key]['drugCode'] = $product['product_pharmacy_code']; // 药品编码
|
||||
$arg['drugList'][$key]['approvalNumber'] = $product['license_number']; // 批准文号
|
||||
$arg['drugList'][$key]['drugName'] = $product['product_name']; // 药品名称
|
||||
$arg['drugList'][$key]['specifications'] = $product['product_spec']; // 药品规格
|
||||
$arg['drugList'][$key]['price'] = $product['product_price']; // 药品单价
|
||||
$arg['drugList'][$key]['packingCount'] = $item['amount']; // 药品数量
|
||||
$arg['drugList'][$key]['surplusPackingCount'] = 0; // 处方药品剩余使用数量
|
||||
$arg['drugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位
|
||||
$arg['drugList'][$key]['singleDosage'] = $product['single_unit']; // 单次用量
|
||||
$arg['drugList'][$key]['singleDosageUnit'] = ""; // 单次用量单位
|
||||
$arg['drugList'][$key]['useName'] = $product['single_use']; // 用法名称
|
||||
$arg['drugList'][$key]['frequencyName'] = $product['frequency_use']; // 频次名称
|
||||
$arg['drugList'][$key]['useDays'] = $product['available_days']; // 使用天数
|
||||
|
||||
$arg['orderDrugList'][$key]['drugCode'] = $product['product_pharmacy_code']; // 药品编码
|
||||
$arg['orderDrugList'][$key]['approvalNumber'] = $product['license_number']; // 批准文号
|
||||
$arg['orderDrugList'][$key]['drugName'] = $product['product_name']; // 药品名称
|
||||
$arg['orderDrugList'][$key]['specifications'] = $product['product_spec']; // 药品规格
|
||||
$arg['orderDrugList'][$key]['price'] = $product['product_price']; // 药品单价
|
||||
$arg['orderDrugList'][$key]['drugCount'] = $item['amount']; // 药品数量
|
||||
$arg['orderDrugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -1245,17 +1245,21 @@ class PatientOrderService extends BaseService
|
||||
}
|
||||
|
||||
// 获取运费金额
|
||||
$Prescription = new Prescription();
|
||||
|
||||
$result = $Prescription->getLogisticsFee();
|
||||
if ($amount_total >= $result['drugCost']){
|
||||
$logistics_fee = 0;
|
||||
}else{
|
||||
if (env("APP_ENV") == "prod"){
|
||||
$Prescription = new Prescription();
|
||||
$result = $Prescription->getLogisticsFee();
|
||||
if ($amount_total < $result['drugCost']){
|
||||
$logistics_fee = $result['freight'];
|
||||
}
|
||||
}
|
||||
|
||||
// 实际支付金额
|
||||
if (env("APP_ENV") == "prod"){
|
||||
$payment_amount_total = 0.01;
|
||||
}else{
|
||||
$payment_amount_total = $amount_total + $logistics_fee;
|
||||
}
|
||||
|
||||
// 获取收货地址
|
||||
$params = array();
|
||||
|
||||
@ -127,8 +127,6 @@ class UserPharmacistService extends BaseService
|
||||
public function putPrescriptionVerify(): array
|
||||
{
|
||||
$user_info = $this->request->getAttribute("userInfo") ?? [];
|
||||
$user_info['user_id'] = "534534546";
|
||||
$user_info['client_user_id'] = "534534546";
|
||||
|
||||
$order_prescription_id = $this->request->route('order_prescription_id');
|
||||
$pharmacist_audit_status = $this->request->input('pharmacist_audit_status');
|
||||
@ -230,6 +228,9 @@ class UserPharmacistService extends BaseService
|
||||
return fail(HttpEnumCode::SERVER_ERROR, "处方审核失败");
|
||||
}
|
||||
|
||||
// 上报处方平台
|
||||
|
||||
|
||||
|
||||
// 发送消息
|
||||
$ImService = new ImService();
|
||||
|
||||
@ -155,6 +155,30 @@ class Prescription
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上报处方
|
||||
* @param array $arg
|
||||
* @return array
|
||||
*/
|
||||
public function reportPrescription(array $arg): array
|
||||
{
|
||||
$option = [
|
||||
"json" => $arg
|
||||
];
|
||||
|
||||
try {
|
||||
$response = $this->httpRequest($this->api_url . $this->version . '/preOrder/receivePreOrder', $option);
|
||||
if (empty($response)){
|
||||
// 返回值为空
|
||||
throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR));
|
||||
}
|
||||
|
||||
return $response;
|
||||
} catch (GuzzleException $e) {
|
||||
throw new BusinessException($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求封装
|
||||
* @param string $path
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user