diff --git a/Dockerfile b/Dockerfile index baaf62fcb..7f62de7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,10 +49,6 @@ WORKDIR /opt/www COPY . /opt/www -#RUN apk add --no-cache $PHPIZE_DEPS \ -# && pecl8 install imagick \ -# && echo "extension=imagick.so" > /etc/php8/conf.d/imagick.ini - RUN composer install --no-dev -o && php bin/hyperf.php EXPOSE 9501 diff --git a/app/Amqp/Consumer/AssignDoctorDelayDirectConsumer.php b/app/Amqp/Consumer/AssignDoctorDelayDirectConsumer.php index 09a095a..891696a 100644 --- a/app/Amqp/Consumer/AssignDoctorDelayDirectConsumer.php +++ b/app/Amqp/Consumer/AssignDoctorDelayDirectConsumer.php @@ -6,9 +6,11 @@ namespace App\Amqp\Consumer; use App\Amqp\Producer\AssignDoctorDelayDirectProducer; use App\Amqp\Producer\CancelUnInquiryOrdersDelayDirectProducer; +use App\Amqp\Producer\DoctorNotYetInquiryDelayDirectProducer; use App\Amqp\Producer\UserCouponExpiredDelayDirectProducer; use App\Constants\HttpEnumCode; use App\Model\OrderInquiry; +use App\Model\OrderInquiryCase; use App\Model\UserDoctor; use App\Services\ImService; use App\Services\InquiryService; @@ -55,6 +57,15 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage return Result::DROP;// 销毁 } + // 获取病例数据 + $params = array(); + $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + $order_inquiry_case = OrderInquiryCase::getOne($params); + if (empty($order_inquiry_case)){ + Log::getInstance('queue-AssignDoctor')->error("错误:患者病例错误"); + return Result::DROP;// 销毁 + } + // 检测订单状态 $res = $this->checkInquiryStatus($order_inquiry); if (!$res){ @@ -121,8 +132,8 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage } // 检测分配时间 - if ($diff_time > 300) { - Log::getInstance("queue-AssignDoctor")->info("信息:超出5分钟,执行退款"); + if ($diff_time > 600) { + Log::getInstance("queue-AssignDoctor")->info("信息:超出10分钟,执行退款"); $InquiryService = new InquiryService(); @@ -234,7 +245,7 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; $message = new CancelUnInquiryOrdersDelayDirectProducer($data); // 快速/购药-5分钟 - $message->setDelayMs(1000 * 60 * 5); + $message->setDelayMs(1000 * 60 * 10); $producer = $this->container->get(Producer::class); $res = $producer->produce($message); if (!$res) { @@ -245,7 +256,7 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage Db::commit(); Log::getInstance("queue-AssignDoctor")->info("成功"); - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollBack(); Log::getInstance("queue-AssignDoctor")->error("失败:" . $e->getMessage()); return Result::REQUEUE; // 重回队列 @@ -262,14 +273,26 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage return Result::ACK; } - // 发送IM消息-等待医生接诊 + // 发送im消息 $imService = new ImService(); + + // 等待医生接诊 $imService->waitDoctorInquiry($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']); // 医生-医生有新问诊 站内、订阅失败发送短信 $MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']); $MessagePush->doctorHaveNewInquiry(); - }catch (\Exception $e){ + + // 加入xx时间未接诊通知队列 + $data = array(); + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + + $time = 1000 * 60 * 3; + $message = new DoctorNotYetInquiryDelayDirectProducer($data); + $message->setDelayMs($time); + $producer = $this->container->get(Producer::class); + $producer->produce($message); + }catch (\Throwable $e){ Log::getInstance("queue-AssignDoctor")->error("发送消息异常错误:" . $e->getMessage()); return Result::ACK; } @@ -340,7 +363,7 @@ class AssignDoctorDelayDirectConsumer extends ConsumerMessage } // 执行次数过多 - if ($redis_value > 3) { + if ($redis_value > 4) { // 加入短信队列,通知管理员 return false; diff --git a/app/Amqp/Consumer/AutoCompleteInquiryDelayDirectConsumer.php b/app/Amqp/Consumer/AutoCompleteInquiryDelayDirectConsumer.php index bb9fd14..770f130 100644 --- a/app/Amqp/Consumer/AutoCompleteInquiryDelayDirectConsumer.php +++ b/app/Amqp/Consumer/AutoCompleteInquiryDelayDirectConsumer.php @@ -147,6 +147,9 @@ class AutoCompleteInquiryDelayDirectConsumer extends ConsumerMessage // 是否需要推送消息 $is_push_prescription_verify_fail = true; + + // 驳回处方id + $order_prescription_id = $item['order_prescription_id']; } } @@ -177,8 +180,9 @@ class AutoCompleteInquiryDelayDirectConsumer extends ConsumerMessage try { if (isset($is_push_prescription_verify_fail)){ // 站内、订阅失败发送短信-医生开具的处方审核未通过 + $order_prescription_id = $order_prescription_id ?? ""; $MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']); - $MessagePush->prescriptionVerifyFail($order_prescription['order_prescription_id']); + $MessagePush->prescriptionVerifyFail($order_prescription_id); } // 发送IM消息-问诊已完成 diff --git a/app/Amqp/Consumer/AutoPharmacistCaVerifyDelayDirectConsumer.php b/app/Amqp/Consumer/AutoPharmacistCaVerifyDelayDirectConsumer.php index f16af85..16628a3 100644 --- a/app/Amqp/Consumer/AutoPharmacistCaVerifyDelayDirectConsumer.php +++ b/app/Amqp/Consumer/AutoPharmacistCaVerifyDelayDirectConsumer.php @@ -134,7 +134,7 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage // 检测执行次数 $res = $this->checkHandleNumber($data['prescription_file_id']); - }catch (\Exception $e){ + }catch (\Throwable $e){ // 检测次数失败 Log::getInstance("queue-AutoPharmacistCaVerify")->info("错误:" . $e->getMessage()); return Result::ACK; @@ -158,14 +158,13 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage Db::commit(); return Result::ACK; - }catch (\Exception $e){ + }catch (\Throwable $e){ Db::rollBack(); Log::getInstance("queue-AutoPharmacistCaVerify")->info("错误:" . $e->getMessage()); return Result::ACK; } } - // 下载医生签章文件 Db::beginTransaction(); try { @@ -199,30 +198,51 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage return Result::REQUEUE; } - Log::getInstance("queue-AutoPharmacistCaVerify")->info("下载医生的签章pdf并上传至oss"); - // 下载医生的签章pdf并上传至oss - $prescription_pdf_oss_path = $this->downCaPdfToOss($order_prescription, $user_doctor['user_id'],2,$order_prescription_file['doctor_ca_file_id']); - if (!$prescription_pdf_oss_path) { + Log::getInstance("queue-AutoPharmacistCaVerify")->info("下载医生的签章pdf并上传至oss"); + $CaService = new CaService($order_prescription,2,$user_doctor['user_id']); + $prescription_pdf_oss_path = $CaService->downCaPdfToOss($order_prescription_file['doctor_ca_file_id']); + if ($prescription_pdf_oss_path == "") { Db::rollBack(); Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:" . $prescription_pdf_oss_path); return Result::REQUEUE; } - // 药师/医院签章 - Log::getInstance("queue-AutoPharmacistCaVerify")->info("药师/医院签章"); + // 药师签章 + Log::getInstance("queue-AutoPharmacistCaVerify")->info("药师签章"); $OrderPrescriptionService = new OrderPrescriptionService(); - $prescription_open_result = $OrderPrescriptionService->openPrescription($data['order_prescription_id'],$user_pharmacist['user_id']); + $prescription_open_result = $OrderPrescriptionService->openPrescription($data['order_prescription_id'],3,$user_pharmacist['user_id']); if (empty($prescription_open_result['file_id'])){ Db::rollBack(); - Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:处方开具失败"); + Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:药师签章失败"); return Result::REQUEUE; } - // 下载医院的签章pdf并上传至oss + // 下载药师签章pdf并上传至oss + Log::getInstance("queue-AutoPharmacistCaVerify")->info("下载药师的签章pdf并上传至oss"); + $CaService = new CaService($order_prescription,3,$user_pharmacist['user_id']); + $prescription_pdf_oss_path = $CaService->downCaPdfToOss($prescription_open_result['file_id']); + if ($prescription_pdf_oss_path == "") { + Db::rollBack(); + Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:" . $prescription_pdf_oss_path); + return Result::REQUEUE; + } + + // 医院签章 + Log::getInstance("queue-AutoPharmacistCaVerify")->info("医院签章"); + $OrderPrescriptionService = new OrderPrescriptionService(); + $prescription_open_result = $OrderPrescriptionService->openPrescription($data['order_prescription_id'],1); + if (empty($prescription_open_result['file_id'])){ + Db::rollBack(); + Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:医院签章失败"); + return Result::REQUEUE; + } + + // 下载医院签章pdf并上传至oss Log::getInstance("queue-AutoPharmacistCaVerify")->info("下载医院的签章pdf并上传至oss"); - $prescription_pdf_oss_path = $this->downCaPdfToOss($order_prescription, $user_pharmacist['user_id'],3,$prescription_open_result['file_id']); - if (!$prescription_pdf_oss_path) { + $CaService = new CaService($order_prescription,1); + $prescription_pdf_oss_path = $CaService->downCaPdfToOss($prescription_open_result['file_id']); + if ($prescription_pdf_oss_path == "") { Db::rollBack(); Log::getInstance("queue-AutoPharmacistCaVerify")->error("错误:" . $prescription_pdf_oss_path); return Result::REQUEUE; @@ -244,7 +264,7 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage Db::commit(); Log::getInstance("queue-AutoPharmacistCaVerify")->info("成功"); - } catch (\Exception $e) { + } catch (\Throwable $e) { Db::rollBack(); Log::getInstance("queue-AutoPharmacistCaVerify")->error("异常错误:" . $e->getMessage()); @@ -279,7 +299,7 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage Log::getInstance("queue-AutoPharmacistCaVerify")->error("添加处方过期队列失败!"); return Result::ACK; } - }catch(\Exception $e){ + }catch(\Throwable $e){ Log::getInstance("queue-AutoPharmacistCaVerify")->error("发送消息异常错误:" . $e->getMessage()); return Result::ACK; } @@ -405,34 +425,6 @@ class AutoPharmacistCaVerifyDelayDirectConsumer extends ConsumerMessage return true; } - /** - * 下载签章pdf并上传至oss - * @param array|object $order_prescription - * @param string $user_id 用户id - * @param string|int $user_type 用户类型 1:患者 2:医生 3:药师 - * @param string $file_id - * @return string|bool oss地址|false(存在异常时) - */ - protected function downCaPdfToOss(array|object $order_prescription, string $user_id, string|int $user_type, string $file_id): string|bool - { - try { - $user = array(); - $user['user_id'] = $user_id; - $user['user_type'] = $user_type; - $CaService = new CaService($order_prescription, $user); - - // 下载签章pdf并上传至oss - if ($user_type == 2){ - return $CaService->downCaPdfToOss($file_id,1); - }else{ - return $CaService->downCaPdfToOss($file_id,2); - } - - } catch (\Exception $e) { - return false; - } - } - /** * 修改处方文件表 * @param string $prescription_file_id 主键id diff --git a/app/Amqp/Consumer/CancelUnInquiryOrdersDelayDirectConsumer.php b/app/Amqp/Consumer/CancelUnInquiryOrdersDelayDirectConsumer.php index 028219b..9480f76 100644 --- a/app/Amqp/Consumer/CancelUnInquiryOrdersDelayDirectConsumer.php +++ b/app/Amqp/Consumer/CancelUnInquiryOrdersDelayDirectConsumer.php @@ -151,6 +151,7 @@ class CancelUnInquiryOrdersDelayDirectConsumer extends ConsumerMessage $user_doctor = UserDoctor::getOne($params); if (empty($user_doctor)) { Log::getInstance()->info("取消未接诊问诊订单成功,发送IM消息失败:医生数据错误"); + return Result::ACK; } // 发送IM消息-医生未接诊 diff --git a/app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php b/app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php index 5daa9e1..0f49592 100644 --- a/app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php +++ b/app/Amqp/Consumer/CancelUnpayOrdersDelayDirectConsumer.php @@ -13,6 +13,7 @@ use App\Model\OrderProductItem; use App\Model\Product; use App\Model\ProductPlatformAmount; use App\Model\UserCoupon; +use App\Services\DetectionService; use App\Services\InquiryService; use App\Services\OrderProductService; use App\Utils\Log; @@ -48,7 +49,7 @@ class CancelUnpayOrdersDelayDirectConsumer extends ConsumerMessage public function consumeMessage($data, AMQPMessage $message): string { - Log::getInstance()->error("开始执行 取消未支付订单 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE)); + Log::getInstance("queue-CancelUnpayOrders")->info("开始执行 取消未支付订单 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE)); Db::beginTransaction(); @@ -63,27 +64,31 @@ class CancelUnpayOrdersDelayDirectConsumer extends ConsumerMessage $OrderProductService = new OrderProductService(); $result = $OrderProductService->cancelUnpayProductOrder($data['order_no'], 3, "支付超时"); + } elseif ($data['order_type'] == 3) { + // 检测订单取消 + $DetectionService = new DetectionService(); + $result = $DetectionService->cancelUnpayDetectionOrder($data['order_no'], 3, "支付超时"); } else { - Log::getInstance()->error("取消未支付订单失败:order_type类型错误"); + Log::getInstance("queue-CancelUnpayOrders")->error("取消未支付订单失败:order_type类型错误"); return Result::DROP;// 销毁 } if ($result['status'] == 0) { Db::rollBack(); - Log::getInstance()->error("取消未支付订单失败:" . $result['message']); + Log::getInstance("queue-CancelUnpayOrders")->error("取消未支付订单失败:" . $result['message']); return Result::DROP;// 销毁 } elseif ($result['status'] == 2) { Db::rollBack(); - Log::getInstance()->info("取消未支付订单成功:" . $result['message']); + Log::getInstance("queue-CancelUnpayOrders")->info("取消未支付订单成功:" . $result['message']); return Result::ACK;// 销毁 } Db::commit(); - Log::getInstance()->info("取消未支付订单 队列执行成功"); + Log::getInstance("queue-CancelUnpayOrders")->info("取消未支付订单 队列执行成功"); return Result::ACK; } catch (\Exception $e) { Db::rollBack(); - Log::getInstance()->error("取消未支付订单执行失败:" . $e->getMessage()); + Log::getInstance("queue-CancelUnpayOrders")->error("取消未支付订单执行失败:" . $e->getMessage()); return Result::ACK; // 重回队列 } } diff --git a/app/Amqp/Consumer/DetectionCompleteDelayDirectConsumer.php b/app/Amqp/Consumer/DetectionCompleteDelayDirectConsumer.php new file mode 100644 index 0000000..e63cae7 --- /dev/null +++ b/app/Amqp/Consumer/DetectionCompleteDelayDirectConsumer.php @@ -0,0 +1,288 @@ +info("开始:" . json_encode($data, JSON_UNESCAPED_UNICODE)); + + // 获取检测订单数据 + $params = array(); + $params['detection_no'] = $data['detection_no']; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)){ + Log::getInstance("queue-DetectionComplete")->error("非法订单"); + return Result::ACK; + } + + // 检测订单状态 + if ($order_detection['detection_status'] != 4){ + Log::getInstance("queue-DetectionComplete")->error("订单状态错误,无法处理"); + return Result::DROP; + } + + if (empty($order_detection['detection_result_pdf'])){ + Log::getInstance("queue-DetectionComplete")->error("无检测报告数据"); + return Result::DROP; + } + + if (!empty($order_detection['order_inquiry_id'])){ + Log::getInstance("queue-DetectionComplete")->info("已创建检测问诊订单,无需继续处理"); + return Result::ACK; + } + + try { + // 检测当前医生是否和患者存在未完成问诊订单 + $InquiryService = new InquiryService(); + $order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($order_detection['patient_id'],$order_detection['doctor_id']); + if (!empty($order_inquiry)){ + // 存在未完成订单 + // 获取现在时间距离订单结束时间的时间差 + $time_diff = $InquiryService->getInquiryFinishTimeDiff($order_inquiry); + if ($time_diff == 0){ + $time_diff = 60; + } + + // 计算时间并重新加入队列 + $queue_data = array(); + $queue_data['detection_no'] = $data['detection_no']; + + $message = new DetectionCompleteDelayDirectProducer($queue_data); + $message->setDelayMs(1000 * $time_diff); + $producer = $this->container->get(Producer::class); + $res = $producer->produce($message); + if (!$res) { + Log::getInstance("queue-DetectionComplete")->error("重新添加队列失败"); + return Result::REQUEUE; + } + + return Result::DROP; + } + + // 获取医生数据 + $params = array(); + $params['doctor_id'] = $order_detection['doctor_id']; + $user_doctor = UserDoctor::getOne($params); + if (empty($user_doctor)){ + Log::getInstance("queue-DetectionComplete")->error("医生数据错误"); + return Result::DROP; + } + + // 获取检测病例数据 + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + $order_detection_case = OrderDetectionCase::getOne($params); + if (empty($order_detection_case)){ + Log::getInstance("queue-DetectionComplete")->error("订单数据错误"); + return Result::DROP; + } + + // 获取检测项目数据 + $params = array(); + $params['detection_project_id'] = $order_detection['detection_project_id']; + $detection_project = DetectionProject::getOne($params); + if (empty($detection_project)){ + Log::getInstance("queue-DetectionComplete")->error("订单数据错误"); + return Result::DROP; + } + + // 检测家庭成员是否存在 + $params = array(); + $params['family_id'] = $order_detection['family_id']; + $params['patient_id'] = $order_detection['patient_id']; + $patient_family = PatientFamily::getOne($params); + if (empty($patient_family)) { + Log::getInstance("queue-DetectionComplete")->error("患者信息错误"); + return Result::DROP; + } + }catch (\Throwable $e){ + Log::getInstance("queue-DetectionComplete")->error($e->getMessage()); + return Result::DROP; + } + + Db::beginTransaction(); + + try { + $generator = $this->container->get(IdGeneratorInterface::class); + + // 创建问诊订单 + $data = array(); + $data['user_id'] = $order_detection['user_id']; + $data['patient_id'] = $order_detection['patient_id']; + $data['doctor_id'] = $order_detection['doctor_id']; + $data['family_id'] = $order_detection['family_id']; + $data['inquiry_type'] = 5; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测) + $data['inquiry_mode'] = 1; // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员) + $data['inquiry_status'] = 4; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消) + $data['inquiry_pay_channel'] = 3; // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付) + $data['inquiry_pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) + $data['inquiry_no'] = $generator->generate();// 订单编号 + $data['escrow_trade_no'] = "GD" . $generator->generate(); // 第三方支付流水号 + $data['amount_total'] = 0;// 订单金额 + $data['coupon_amount_total'] = 0;// 优惠卷总金额 + $data['payment_amount_total'] = 0;// 实际付款金额 + $data['pay_time'] = date('Y-m-d H:i:s', time());// 支付时间 + $data['reception_time'] = date('Y-m-d H:i:s', time());// 接诊时间 + $data['patient_name'] = $patient_family['card_name'];// 患者姓名-就诊人 + $data['patient_name_mask'] = $patient_family['card_name_mask'];// 患者姓名-就诊人(掩码) + $data['patient_sex'] = $patient_family['sex'];// 患者性别-就诊人(0:未知 1:男 2:女) + $data['patient_age'] = $patient_family['age'];// 患者年龄-就诊人 + $order_inquiry = OrderInquiry::addOrderInquiry($data); + if (empty($order_inquiry)) { + Db::rollBack(); + Log::getInstance("queue-DetectionComplete")->error("问诊订单创建失败"); + return Result::DROP; + } + + // 增加患者问诊病例 + $data = array(); + $data['user_id'] = $order_detection['user_id']; + $data['patient_id'] = $order_detection['patient_id']; + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];// 订单-问诊id + $data['family_id'] = $patient_family['family_id']; // 家庭成员id + $data['relation'] = $patient_family['relation']; // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 ) + $data['name'] = $patient_family['card_name']; // 患者名称 + $data['sex'] = $patient_family['sex'] ?? 0; // 患者性别(0:未知 1:男 2:女) + $data['age'] = $patient_family['age'] ?? null; // 患者年龄 + $data['height'] = $patient_family['height'] ?: null; // 身高(cm) + $data['weight'] = $patient_family['weight'] ?: null;; // 体重(kg) + $data['nation_id'] = $order_detection_case['nation_id'] ?: $patient_family['nation_id'] ?: null;; // 民族 + $data['nation_name'] = $order_detection_case['nation_name'] ?: $patient_family['nation_name'] ?: null;; // 民族名称 + $order_inquiry_case = OrderInquiryCase::addOrderInquiryCase($data); + if (empty($order_inquiry_case)) { + Db::rollBack(); + Log::getInstance("queue-DetectionComplete")->error("问诊订单病例创建失败"); + return Result::DROP; + } + + // 修改检测订单 + $data = array(); + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];// 订单-问诊id + + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + OrderDetection::editOrderDetection($params,$data); + + // 添加自动完成队列 + $time = 1000 * 60 * 60 * 24 * 3; + + $data = array(); + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + + $message = new AutoCompleteInquiryDelayDirectProducer($data); + $message->setDelayMs($time); + $producer = $this->container->get(Producer::class); + $res = $producer->produce($message); + if (!$res) { + Db::rollBack(); + Log::getInstance("queue-DetectionComplete")->error("添加自动完成队列失败"); + return Result::DROP; + } + + // 发送im消息 + $imService = new ImService(); + + // 患者病例 + $imService->patientCase( + $order_inquiry, + $user_doctor['user_id'], + $order_inquiry_case['disease_desc'] + ); + + // 发送IM消息-检测报告结果 + $data = [ + "order_inquiry_id" => $order_inquiry['order_inquiry_id'], + "inquiry_type" => $order_inquiry['inquiry_type'], + "detection_no" => $order_detection['detection_no'], + "patient_name" => $order_detection['patient_name'], + "patient_sex" => $order_detection['patient_sex'], + "patient_age" => $order_detection['patient_age'], + "detection_project_name" => $detection_project['detection_project_name'], + "disease_class_names" => $order_detection_case['detection_disease_class_names'], + "detection_result_pdf" => $order_detection['detection_result_pdf'], + "patient_user_id" => $order_detection['user_id'], + "doctor_user_id" => $user_doctor['user_id'], + ]; + $imService->detectionTestReport($data); + + Db::commit(); + }catch (\Throwable $e){ + Db::rollBack(); + Log::getInstance("queue-DetectionComplete")->error($e->getMessage()); + return Result::DROP; + } + + // 发送消息 + try { + // 发送IM消息-检测报告结果-文字 + $data = [ + "order_inquiry_id" => $order_inquiry['order_inquiry_id'], + "inquiry_type" => $order_inquiry['inquiry_type'], + "detection_no" => $order_detection['detection_no'], + "doctor_name" => $user_doctor['user_name'], + "patient_name" => $order_detection['patient_name'], + "patient_sex" => $order_detection['patient_sex'], + "patient_age" => $order_detection['patient_age'], + "detection_project_name" => $detection_project['detection_project_name'], + "patient_user_id" => $order_detection['user_id'], + "doctor_user_id" => $user_doctor['user_id'], + ]; + + $imService->detectionTestReportStr($data); + + // 患者-新报告生成通知 + $MessagePush = new MessagePush($order_detection['user_id']); + $MessagePush->patientDetectionResultNotice($order_detection['order_detection_id']); + + // 医生-通知医生患者检测报告已生成 + $MessagePush = new MessagePush($user_doctor['user_id']); + $MessagePush->doctorDetectionResultNotice($order_detection['order_detection_id']); + }catch (\Throwable $e){ + Log::getInstance("queue-DetectionComplete")->error($e->getMessage()); + return Result::DROP; + } + + return Result::ACK; + } +} diff --git a/app/Amqp/Consumer/DoctorNotYetInquiryDelayDirectConsumer.php b/app/Amqp/Consumer/DoctorNotYetInquiryDelayDirectConsumer.php new file mode 100644 index 0000000..cdf6894 --- /dev/null +++ b/app/Amqp/Consumer/DoctorNotYetInquiryDelayDirectConsumer.php @@ -0,0 +1,80 @@ +info("开始:" . json_encode($data, JSON_UNESCAPED_UNICODE)); + + if (!isset($data['order_inquiry_id'])){ + Log::getInstance("queue-DoctorNotYetInquiry")->error("缺少参数"); + return Result::ACK; + } + + try { + // 获取问诊订单数据 + $params = array(); + $params['order_inquiry_id'] = $data['order_inquiry_id']; + $order_inquiry = OrderInquiry::getOne($params); + if (empty($order_inquiry)){ + Log::getInstance("queue-DoctorNotYetInquiry")->error("未找到对应问诊订单"); + return Result::ACK; + } + + // 检测问诊订单状态 + if ($order_inquiry['inquiry_status'] != 3){ + Log::getInstance("queue-DoctorNotYetInquiry")->error("状态非待接诊,无需发送"); + return Result::ACK; + } + + // 获取订单医生数据 + $params = array(); + $params['doctor_id'] = $order_inquiry['doctor_id']; + $user_doctor = UserDoctor::getOne($params); + if (empty($user_doctor)) { + Log::getInstance("queue-DoctorNotYetInquiry")->error("医生数据错误"); + } + + // 发送站内、订阅消息-医生-超时未接诊 + $MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']); + $MessagePush->doctorNotYetInquiry(); + }catch (\Throwable $e){ + Log::getInstance("queue-DoctorNotYetInquiry")->error("失败:" . $e->getMessage()); + return Result::ACK; + } + + return Result::ACK; + } +} diff --git a/app/Amqp/Consumer/SendSmsMessageConsumer.php b/app/Amqp/Consumer/SendSmsMessageConsumer.php index 66ed41a..1219cda 100644 --- a/app/Amqp/Consumer/SendSmsMessageConsumer.php +++ b/app/Amqp/Consumer/SendSmsMessageConsumer.php @@ -184,6 +184,27 @@ class SendSmsMessageConsumer extends ConsumerMessage case 'SMS_272165092': // 医生修改简介审核拒绝 break; + case 'SMS_462035956': + // 患者-新报告生成通知 + if (!isset($template_param['report'])) { + return false; + } + break; + case 'SMS_461980700': + // 医生-新报告生成通知 + if (!isset($template_param['report'])) { + return false; + } + if (!isset($template_param['name'])) { + return false; + } + break; + case 'SMS_463525093': + // 客服-通知客服 + if (!isset($template_param['code'])) { + return false; + } + break; default: // 非法模版 return false; diff --git a/app/Amqp/Producer/DetectionCompleteDelayDirectProducer.php b/app/Amqp/Producer/DetectionCompleteDelayDirectProducer.php new file mode 100644 index 0000000..4c10686 --- /dev/null +++ b/app/Amqp/Producer/DetectionCompleteDelayDirectProducer.php @@ -0,0 +1,31 @@ +payload = $data; + } +} diff --git a/app/Amqp/Producer/DoctorNotYetInquiryDelayDirectProducer.php b/app/Amqp/Producer/DoctorNotYetInquiryDelayDirectProducer.php new file mode 100644 index 0000000..ffe1d5b --- /dev/null +++ b/app/Amqp/Producer/DoctorNotYetInquiryDelayDirectProducer.php @@ -0,0 +1,30 @@ +payload = $data; + } +} diff --git a/app/Command/ReportPreProductOrderCommand.php b/app/Command/ReportPreProductOrderCommand.php index dcd829f..6c23d29 100644 --- a/app/Command/ReportPreProductOrderCommand.php +++ b/app/Command/ReportPreProductOrderCommand.php @@ -4,8 +4,11 @@ declare(strict_types=1); namespace App\Command; +use App\Exception\BusinessException; use App\Model\OrderPrescription; use App\Model\OrderProduct; +use App\Model\OrderSystem; +use App\Model\UserDoctor; use App\Model\UserPatient; use App\Services\MessagePush; use App\Services\OrderPrescriptionService; @@ -55,6 +58,20 @@ class ReportPreProductOrderCommand extends HyperfCommand foreach ($order_product_ids as $item){ $this->line("本次请求订单号:" . $item['order_product_id']); + // 获取商品订单数据 + $params = array(); + $params['order_product_id'] = $item['order_product_id']; + $order_product = OrderProduct::getOne($params); + if (empty($order_product)) { + $this->line("结束,商品订单数据错误"); + continue; + } + + if ($order_product['report_pre_status'] == 1){ + $this->line("结束,订单已上报"); + continue; + } + Db::beginTransaction(); try { @@ -69,14 +86,27 @@ class ReportPreProductOrderCommand extends HyperfCommand // 修改药品订单表上报处方平台状态 $this->saveOrderProductPeportPreStatus($item['order_product_id'],2,"超出最大上报次数"); - // 修改失败时药品订单数据 - $this->savePreFailedOrderStatus($item['order_product_id'],"药房处方复核失败,平台会在24小时内进行退款处理"); - - // 退款 - $OrderProductService = new OrderProductService(); - $OrderProductService->OrderProductRefund($item['order_product_id'],"药品订单退款"); +// // 修改失败时药品订单数据 +// $this->savePreFailedOrderStatus($item['order_product_id'],"药房处方复核失败,平台会在24小时内进行退款处理"); +// +// // 退款 +// $OrderProductService = new OrderProductService(); +// $OrderProductService->OrderProductRefund($item['order_product_id'],"药品订单退款"); Db::commit(); + + // 获取系统配置 + $params = array(); + $params['system_permission'] = "reportPreNotice"; + $order_system = OrderSystem::getOne($params); + if (!empty($order_system)){ + if ($order_system['is_sms'] == 1 && !empty($order_system['sms_mobile'])){ + // 客服-通知客服药品订单上报处方平台失败 + $MessagePush = new MessagePush(); + $MessagePush->noticeReport($order_product['order_product_no'],$order_system['sms_mobile']); + } + } + continue; } }catch(\Exception $e){ diff --git a/app/Command/editDoctorInquiryConfigCommand.php b/app/Command/editDoctorInquiryConfigCommand.php new file mode 100644 index 0000000..da76e3d --- /dev/null +++ b/app/Command/editDoctorInquiryConfigCommand.php @@ -0,0 +1,123 @@ +setDescription('修改医生问诊配置'); + } + + public function handle() + { + $this->line('开始'); + + // 获取医生信息 + $params = array(); + $user_doctors = UserDoctor::getList($params); + if (empty($user_doctors)) { + $this->line('结束,无医生需处理'); + return; + } + + // 获取系统问诊配置 + $params = array(); + $params['inquiry_type'] = 4; + $params['inquiry_mode'] = 1; + $system_inquiry_config = SystemInquiryConfig::getOne($params); + if (empty($system_inquiry_config)) { + $this->line('结束,系统问诊配置获取失败'); + return; + } + + foreach ($user_doctors as $user_doctor){ + Db::beginTransaction(); + + try { + // 是否参加专家图文接诊 + if ($user_doctor['is_img_expert_reception'] == 1){ + $params = array(); + $params['doctor_id'] = $user_doctor['doctor_id']; + $params['inquiry_type'] = 1; + $params['inquiry_mode'] = 1; + + $data['is_enable'] = 1; + DoctorInquiryConfig::editInquiryConfig($params,$data); + } + + // 是否参加快速图文接诊 + if ($user_doctor['is_img_quick_reception'] == 1){ + $params = array(); + $params['doctor_id'] = $user_doctor['doctor_id']; + $params['inquiry_type'] = 2; + $params['inquiry_mode'] = 1; + + $data['is_enable'] = 1; + DoctorInquiryConfig::editInquiryConfig($params,$data); + } + + // 是否参加公益图文问诊 + if ($user_doctor['is_img_welfare_reception'] == 1){ + $params = array(); + $params['doctor_id'] = $user_doctor['doctor_id']; + $params['inquiry_type'] = 3; + $params['inquiry_mode'] = 1; + + $data['is_enable'] = 1; + DoctorInquiryConfig::editInquiryConfig($params,$data); + } + + // 医生多点执业认证状态 + if ($user_doctor['multi_point_status'] == 1){ + // 查询是否已设置多点执业认证状态 + $params = array(); + $params['doctor_id'] = $user_doctor['doctor_id']; + $params['inquiry_type'] = 4; + $params['inquiry_mode'] = 1; + $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); + if (empty($doctor_inquiry_config)) { + $data = array(); + $data['doctor_id'] = $user_doctor['doctor_id']; + $data['inquiry_type'] = 4; + $data['inquiry_mode'] = 1; + $data['is_enable'] = 1; + $data['work_num_day'] = $system_inquiry_config["max_work_num_day"]; + $data['inquiry_price'] = $system_inquiry_config["inquiry_price"]; + + $doctorInquiryConfig = DoctorInquiryConfig::addInquiryConfig($data); + if (empty($doctorInquiryConfig)){ + Db::rollBack(); + $this->line('失败:问诊购药处理失败'); + return; + } + } + } + + Db::commit(); + }catch (\Throwable $e){ + Db::rollBack(); + // 记录失败次数 + $this->line("失败:" . $e->getMessage()); + } + } + $this->line('结束'); + } +} diff --git a/app/Common/Common.php b/app/Common/Common.php index 41da95f..bff6f43 100644 --- a/app/Common/Common.php +++ b/app/Common/Common.php @@ -170,6 +170,8 @@ function inquiryTypeToString(int|string $inquiry_type): string $result = "公益问诊"; } elseif ($inquiry_type == 4) { $result = "问诊购药"; + } elseif ($inquiry_type == 5) { + $result = "检测问诊"; } else { $result = "未知"; } diff --git a/app/Constants/HttpEnumCode.php b/app/Constants/HttpEnumCode.php index 0e4efef..36fc837 100644 --- a/app/Constants/HttpEnumCode.php +++ b/app/Constants/HttpEnumCode.php @@ -22,12 +22,12 @@ class HttpEnumCode extends AbstractConstants const HTTP_ERROR = -1; /** - * @Message("用户状态异常") + * @Message("账户状态异常,请联系客服:010-87573022") */ const USER_STATUS_ERROR = 201; /** - * @Message("用户已被禁用") + * @Message("账户已被禁用,请联系客服:010-87573022") */ const USER_STATUS_DISABLE = 202; diff --git a/app/Controller/BasicDataController.php b/app/Controller/BasicDataController.php index a1ef98b..c30d142 100644 --- a/app/Controller/BasicDataController.php +++ b/app/Controller/BasicDataController.php @@ -129,6 +129,22 @@ class BasicDataController extends AbstractController return $this->response->json($data); } + /** + * 获取商品数据-分页 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function getProductPage(): ResponseInterface + { + $request = $this->container->get(BasicDataRequest::class); + $request->scene('getProductPage')->validateResolved(); + + $BasicDataService = new BasicDataService(); + $data = $BasicDataService->getProductPage(); + return $this->response->json($data); + } + /** * 搜索平台疾病分类 * @return ResponseInterface @@ -204,4 +220,20 @@ class BasicDataController extends AbstractController $data = $BasicDataService->getHotSearchKeyword(); return $this->response->json($data); } + + /** + * 获取检测疾病分类列表 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function getDetectionDiseaseList(): ResponseInterface + { + $request = $this->container->get(BasicDataRequest::class); + $request->scene('getDetectionDiseaseList')->validateResolved(); + + $BasicDataService = new BasicDataService(); + $data = $BasicDataService->getDetectionDiseaseList(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Controller/CallBackController.php b/app/Controller/CallBackController.php index 188ff6b..54e5c9d 100644 --- a/app/Controller/CallBackController.php +++ b/app/Controller/CallBackController.php @@ -3,13 +3,22 @@ namespace App\Controller; use App\Amqp\Producer\AssignDoctorDelayDirectProducer; +use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer; +use App\Amqp\Producer\DetectionCompleteDelayDirectProducer; +use App\Amqp\Producer\DoctorNotYetInquiryDelayDirectProducer; use App\Constants\DoctorTitleCode; use App\Constants\HttpEnumCode; use App\Exception\BusinessException; +use App\Model\BasicDetectionOrgan; use App\Model\BasicLogisticsCompany; +use App\Model\DetectionProject; use App\Model\Hospital; use App\Model\MessageIm; +use App\Model\OrderDetection; +use App\Model\OrderDetectionCase; +use App\Model\OrderDetectionRefund; use App\Model\OrderInquiry; +use App\Model\OrderInquiryCase; use App\Model\OrderInquiryCoupon; use App\Model\OrderInquiryRefund; use App\Model\OrderPrescription; @@ -17,17 +26,22 @@ use App\Model\OrderProduct; use App\Model\OrderProductItem; use App\Model\OrderProductLogistic; use App\Model\OrderProductRefund; +use App\Model\PatientFamily; use App\Model\Product; use App\Model\ProductPlatformAmount; +use App\Model\User; use App\Model\UserCoupon; use App\Model\UserDoctor; use App\Model\UserPatient; +use App\Model\UserSystem; use App\Services\BaseService; use App\Services\ImService; use App\Services\InquiryService; use App\Services\MessagePush; use App\Services\OrderPrescriptionService; +use App\Services\UserService; use App\Utils\Log; +use Extend\Alibaba\Oss; use Extend\TencentIm\Account; use Extend\TencentIm\Message; use Extend\TencentIm\Profile; @@ -38,6 +52,7 @@ use Hyperf\DbConnection\Db; use Hyperf\HttpMessage\Stream\SwooleFileStream; use Hyperf\HttpMessage\Stream\SwooleStream; use Hyperf\Redis\Redis; +use Hyperf\Snowflake\IdGeneratorInterface; use Hyperf\Utils\ApplicationContext; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; @@ -82,6 +97,15 @@ class CallBackController extends AbstractController return $server->serve(); } + // 获取病例数据 + $params = array(); + $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + $order_inquiry_case = OrderInquiryCase::getOne($params); + if (empty($order_inquiry_case)){ + Log::getInstance()->info("问诊微信支付回调数据处理失败,患者病例错误"); + return $server->serve(); + } + // 验证订单状态 if ($order_inquiry['inquiry_status'] != 1) { // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消) @@ -166,14 +190,26 @@ class CallBackController extends AbstractController return $server->serve(); } - // 发送IM消息-等待医生接诊 + // 发送im消息 $imService = new ImService(); + + // 等待医生接诊 $imService->waitDoctorInquiry($order_inquiry, $user_doctor['user_id'], $order_inquiry['user_id']); // 发送站内、订阅失败发送短信消息-医生有新问诊 $MessagePush = new MessagePush($user_doctor['user_id'], $order_inquiry['order_inquiry_id']); $MessagePush->doctorHaveNewInquiry(); + // 加入xx时间未接诊通知队列 + $data = array(); + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + + $time = 1000 * 60 * 60 * 2; + $message = new DoctorNotYetInquiryDelayDirectProducer($data); + $message->setDelayMs($time); + $producer = $this->container->get(Producer::class); + $producer->produce($message); + Log::getInstance()->info("发送im消息成功"); } } @@ -247,7 +283,7 @@ class CallBackController extends AbstractController // 验证订单支付状态 if (in_array($order_inquiry['inquiry_pay_status'], [1, 3, 4, 5, 6, 7])) { // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) - Log::getInstance()->error("队列执行失败原因:订单未支付"); + Log::getInstance()->info("订单支付状态错误:当前为" . $order_inquiry['inquiry_pay_status']); return $server->serve(); } @@ -265,7 +301,7 @@ class CallBackController extends AbstractController if (empty($inquiry_refund_status)) { // 错误,无退款状态 - Log::getInstance()->error("队列执行失败原因:订单未支付"); + Log::getInstance()->info("订单支付状态错误:未接收到退款状态"); return $this->wxPayErrorReturn("退款状态错误"); } @@ -601,10 +637,9 @@ class CallBackController extends AbstractController { $request_params = $this->request->all(); try { - Log::getInstance()->info("Im回调数据:" . json_encode($request_params, JSON_UNESCAPED_UNICODE)); + Log::getInstance("CallBackController-imCallBack")->info("Im回调数据:" . json_encode($request_params, JSON_UNESCAPED_UNICODE)); if (empty($request_params['RequestTime']) || empty($request_params['Sign'])) { - Log::getInstance()->error("Im回调数据处理失败:缺少时间时间戳/签名字段"); return $this->ImErrorReturn("缺少时间时间戳/签名字段"); } @@ -612,37 +647,31 @@ class CallBackController extends AbstractController $imService = new ImService(); $result = $imService->validateSign($request_params['RequestTime'], $request_params['Sign']); if (!$result) { - Log::getInstance()->error("Im回调数据处理失败:回调签名不匹配"); return $this->ImErrorReturn("回调签名不匹配"); } // 验证消息内容 if (empty($request_params['MsgBody'])) { - Log::getInstance()->error("Im回调数据处理失败:消息内容错误"); return $this->ImErrorReturn("消息内容错误,缺少MsgBody"); } // 验证消息内容类型 if (empty($request_params['MsgBody'][0]['MsgType'])) { - Log::getInstance()->error("Im回调数据处理失败:缺少MsgType"); return $this->ImErrorReturn("消息内容错误,缺少MsgType"); } // 验证消息内容详情 if (empty($request_params['MsgBody'][0]['MsgContent'])) { - Log::getInstance()->error("Im回调数据处理失败:缺少MsgContent"); return $this->ImErrorReturn("消息内容错误,缺少MsgContent"); } // 验证接收方user_id if (empty($request_params['To_Account'])) { - Log::getInstance()->error("Im回调数据处理失败:接收用户错误"); return $this->ImErrorReturn("消息内容错误,接收用户错误"); } // 验证消息唯一id if (empty($request_params['MsgKey'])) { - Log::getInstance()->error("Im回调数据处理失败:消息唯一标识错误"); return $this->ImErrorReturn("消息内容错误,消息唯一标识错误"); } @@ -652,7 +681,7 @@ class CallBackController extends AbstractController $message = MessageIm::getExists($params); if ($message) { // 消息重复 - Log::getInstance()->info("Im回调数据处理失败:消息重复"); + Log::getInstance("CallBackController-imCallBack")->info("消息重复"); return $this->ImSuccessReturn(); } @@ -673,7 +702,6 @@ class CallBackController extends AbstractController $params['order_inquiry_id'] = $cloud_custom_data['order_inquiry_id']; $order_inquiry = OrderInquiry::getOne($params); if (empty($order_inquiry)) { - Log::getInstance()->error("Im回调数据处理失败:非法订单"); return $this->ImErrorReturn("消息内容错误,非法订单"); } @@ -712,13 +740,21 @@ class CallBackController extends AbstractController $data['message_custom_content'] = $request_params['CloudCustomData'] ?? ""; $message = MessageIm::addMessage($data); if (empty($message)) { - Log::getInstance()->error("Im回调数据处理失败:存储数据库失败"); - return $this->wxPayErrorReturn("存储数据库失败"); + return $this->ImErrorReturn("存储数据库失败"); + } + + // im消息通知 + if ($is_system == 0 && isset($message_send_result) && isset($order_inquiry_id)){ + try { + $UserService = new UserService(); + $UserService->userImMessageNotice($request_params['To_Account'],$order_inquiry_id,$request_params['MsgBody']); + }catch (\Throwable $e){ + Log::getInstance("CallBackController-imCallBack")->error("im消息通知失败"); + } } } catch (\Exception $e) { // 验证失败 - Log::getInstance()->error("Im回调数据处理失败:" . $e->getMessage()); - return $this->wxPayErrorReturn($e->getMessage()); + return $this->ImErrorReturn($e->getMessage()); } Log::getInstance()->info("Im回调数据处理成功"); @@ -732,6 +768,7 @@ class CallBackController extends AbstractController */ protected function ImErrorReturn(string $message): ResponseInterface { + Log::getInstance("CallBackController-imCallBack")->error("Im回调数据处理失败:接收用户错误"); return $this->response ->withStatus(200) ->withBody( @@ -1102,4 +1139,573 @@ class CallBackController extends AbstractController ); } + /** + * 患者端检测支付回调 + * @return ResponseInterface + * @throws \Throwable + */ + public function wxPayDetectionSuccessCallBack(): ResponseInterface + { + try { + // 处理支付结果事件 + $WechatPay = new WechatPay(1, 3); + $app = $WechatPay->createApp(); + $server = $app->getServer(); + + $message = $server->getRequestMessage(); + if (empty($message)) { + return $this->response->withStatus(500)->withBody(new SwooleStream(strval(json_encode(['code' => 'ERROR', 'message' => "问诊微信支付回调数据为空"], JSON_UNESCAPED_UNICODE)))); + } + + // 验证推送消息签名 + $app->getValidator()->validate($app->getRequest()); + + Log::getInstance()->info("检测微信支付回调数据:" . json_encode($message->toArray(), JSON_UNESCAPED_UNICODE)); + + if (empty($message['out_trade_no'])) { + Log::getInstance()->info("检测微信支付回调数据处理失败,缺少外部订单号"); + return $server->serve(); + } + + // 查询订单 + $params = array(); + $params['detection_no'] = $message['out_trade_no']; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)) { + Log::getInstance()->info("检测微信支付回调数据处理失败,无订单数据"); + return $server->serve(); + } + + // 验证订单状态 + if ($order_detection['detection_status'] != 1) { + // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + Log::getInstance()->info("检测微信支付回调数据处理失败,订单状态当前为" . $order_detection['detection_status']); + return $server->serve(); + } + + // 支付状态无需验证,如第一次支付失败,会修改支付状态,再次支付时,会出现验证不通过的情况 + + // 修改支付状态 + $data = array(); + if ($message['trade_state'] == "SUCCESS") { + // 支付成功 + $data['detection_pay_status'] = 2; + $data['pay_time'] = date('Y-m-d H:i:s', strtotime($message['success_time']));// 支付时间 + $data['detection_status'] = 2;// 2:待绑定 + if (empty($message['amount'])){ + Log::getInstance()->error("检测微信支付回调数据处理失败:无支付金额"); + return $this->wxPayErrorReturn("检测微信支付回调数据处理失败:无支付金额"); + } + } elseif ($message['trade_state'] == "CLOSED") { + // 已关闭 + $data['detection_pay_status'] = 6; + } elseif ($message['trade_state'] == "REVOKED") { + // 已撤销(付款码支付) + $data['detection_pay_status'] = 7; + } elseif ($message['trade_state'] == "USERPAYING") { + // 用户支付中(付款码支付) + $data['detection_pay_status'] = 3; + } elseif ($message['trade_state'] == "PAYERROR") { + // 支付失败(其他原因,如银行返回失败) + $data['detection_pay_status'] = 4; + } + + $data['escrow_trade_no'] = $message['transaction_id']; + $data['updated_at'] = date('Y-m-d H:i:s', time()); + + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + OrderDetection::editOrderDetection($params, $data); + } catch (\Exception $e) { + // 验证失败 + Log::getInstance()->error("问诊微信支付回调数据处理失败:" . $e->getMessage()); + return $this->wxPayErrorReturn($e->getMessage()); + } + + Log::getInstance()->info("检测微信支付回调处理成功"); + + return $server->serve(); + } + + /** + * 微信检测退款回调 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + * @throws \Throwable + */ + public function wxPayDetectionRefundCallBack(): ResponseInterface + { + Db::beginTransaction(); + + try { + // 处理支付结果事件 + $WechatPay = new WechatPay(1, 1); + $app = $WechatPay->createApp(); + $server = $app->getServer(); + + $message = $server->getRequestMessage(); + if (empty($message)) { + Db::rollBack(); + return $this->response->withStatus(500)->withBody(new SwooleStream(strval(json_encode(['code' => 'ERROR', 'message' => "回调数据为空"], JSON_UNESCAPED_UNICODE)))); + } + + // 验证推送消息签名 + $app->getValidator()->validate($app->getRequest()); + + Log::getInstance()->info("微信退款回调数据:" . json_encode($message->toArray(), JSON_UNESCAPED_UNICODE)); + + if (empty($message['out_trade_no'])) { + Log::getInstance()->info("微信退款回调数据错误"); + return $server->serve(); + } + + // 验证订单数据 + $params = array(); + $params['detection_no'] = $message['out_trade_no']; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)) { + Log::getInstance()->info("非法订单"); + return $server->serve(); + } + + // 验证订单状态 + if ($order_detection['detection_status'] == 1) { + // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + Log::getInstance()->info("订单状态错误:当前为" . $order_detection['detection_status']); + return $server->serve(); + } + + // 验证订单退款状态 + if ($order_detection['detection_refund_status'] == 3) { + // 检测订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常) + Log::getInstance()->info("订单退款状态错误:当前为" . $order_detection['detection_refund_status']); + return $server->serve(); + } + + // 验证订单支付状态 + if (in_array($order_detection['detection_pay_status'], [1, 3, 4, 5, 6, 7])) { + // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) + Log::getInstance()->info("订单支付状态错误:当前为" . $order_detection['detection_pay_status']); + return $server->serve(); + } + + // 退款状态 + if ($message['refund_status'] == "SUCCESS") { + // 退款成功 + $detection_refund_status = 3; + } elseif ($message['refund_status'] == "CLOSED") { + // 退款关闭 + $detection_refund_status = 5; + } elseif ($message['refund_status'] == "ABNORMAL") { + // 退款异常 + $detection_refund_status = 6; + } + + if (empty($detection_refund_status)) { + // 错误,无退款状态 + Log::getInstance()->error("队列执行失败原因:订单未支付"); + return $this->wxPayErrorReturn("退款状态错误"); + } + + // 修改订单 + $data = array(); + $data['detection_refund_status'] = $detection_refund_status; + + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + OrderDetection::editOrderDetection($params, $data); + + // 修改退款订单 + $data = array(); + $data['detection_refund_status'] = $detection_refund_status; + $data['success_time'] = $message['success_time']; + + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + OrderDetectionRefund::edit($params, $data); + + Db::commit(); + } catch (\Exception $e) { + // 验证失败 + Db::rollBack(); + Log::getInstance()->error("微信支付回调数据验证失败:" . $e->getMessage()); + return $this->wxPayErrorReturn($e->getMessage()); + } + + Log::getInstance()->info("微信退款回调处理成功"); + + return $server->serve(); + } + + /** + * 检测所结果回调 + * @return ResponseInterface + */ + public function DetectionResultCallBack(): ResponseInterface + { + $request_params = $this->request->all(); + $auth = $this->request->header("Authorization"); + if (empty($auth)){ + return $this->detectionResultFailReturn("非法请求"); + } + + Log::getInstance("CallBackController-DetectionResultCallBack")->info("处理检测所结果"); + + try { + // 检测参数 + if (!isset($request_params['appId'])){ + return $this->detectionResultFailReturn("缺少appId参数"); + } + + if (!isset($request_params['orderCode'])){ + return $this->detectionResultFailReturn("缺少orderCode参数"); + } + + if (!isset($request_params['detectBarcode'])){ + return $this->detectionResultFailReturn("缺少detectBarcode参数"); + } + + if (!isset($request_params['pdfReport'])){ + return $this->detectionResultFailReturn("缺少pdfReport参数"); + } + + // 检测签名 + $params = array(); + $params['app_id'] = $request_params['appId']; + $basic_detection_organ = BasicDetectionOrgan::getOne($params); + if (empty($basic_detection_organ)){ + return $this->detectionResultFailReturn("非法appId"); + } + + $time = date('Ymd'); + $sign = md5($basic_detection_organ['app_id'] . $basic_detection_organ['app_secret'] . $time); + dump($sign); + if ($auth != $sign){ + return $this->detectionResultFailReturn("签名错误"); + } + + // 检测pdf文件 + $pdfData = base64_decode($request_params['pdfReport']); + if (!$pdfData){ + return $this->detectionResultFailReturn("文件错误"); + } + + // 获取检测订单数据 + $params = array(); + $params['detection_no'] = $request_params['orderCode']; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)){ + return $this->detectionResultFailReturn("非法订单"); + } + + // 检测订单状态 + if ($order_detection['detection_status'] != 3){ + return $this->detectionResultFailReturn("订单状态错误,无法处理"); + } + + if (!empty($order_detection['detection_result_pdf'])){ + return $this->detectionResultSuccessReturn(); + } + + if ($order_detection['detection_bar_code'] != $request_params['detectBarcode']){ + return $this->detectionResultFailReturn("检测条码无法对应"); + } + + // 上传处方图片至oss + $oss = new Oss(); + $detection_result_pdf_name = "applet/patient/detection/pdf/" . $order_detection['order_detection_id'] . '.' . 'pdf'; + $detection_result_pdf = $oss->putObject($detection_result_pdf_name, $pdfData); + $detection_result_pdf = '/' . $detection_result_pdf; + + // 回填检测结果字段 + $order_detection['detection_result_pdf'] = $detection_result_pdf; + + // 获取医生数据 + $params = array(); + $params['doctor_id'] = $order_detection['doctor_id']; + $user_doctor = UserDoctor::getOne($params); + if (empty($user_doctor)){ + return $this->detectionResultFailReturn("医生数据错误"); + } + + // 获取检测病例数据 + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + $order_detection_case = OrderDetectionCase::getOne($params); + if (empty($order_detection_case)){ + return $this->detectionResultFailReturn("订单数据错误"); + } + + // 获取检测项目数据 + $params = array(); + $params['detection_project_id'] = $order_detection['detection_project_id']; + $detection_project = DetectionProject::getOne($params); + if (empty($detection_project)){ + return $this->detectionResultFailReturn("订单数据错误"); + } + + // 发送im消息 + $imService = new ImService(); + + // 检测当前医生是否和患者存在未完成问诊订单 + $InquiryService = new InquiryService(); + $order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($order_detection['patient_id'],$order_detection['doctor_id']); + if(!empty($order_inquiry)){ + // 存在问诊订单 + $time_diff = $InquiryService->getInquiryFinishTimeDiff($order_inquiry); + if ($time_diff == 0){ + $time_diff = 60; + } + + dump($time_diff); + // 计算时间并重新加入队列 + $queue_data = array(); + $queue_data['detection_no'] = $order_detection['detection_no']; + + $message = new DetectionCompleteDelayDirectProducer($queue_data); + $message->setDelayMs(1000 * $time_diff); + $producer = $this->container->get(Producer::class); + $res = $producer->produce($message); + if (!$res) { + return $this->detectionResultFailReturn("加入队列失败"); + } + + // 修改检测订单 + $data = array(); + $data['detection_status'] = 4; + $data['detection_result_pdf'] = $detection_result_pdf; + $data['detection_result_date'] = date('Y-m-d H:i:s',time()); + + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + OrderDetection::editOrderDetection($params,$data); + + // 发送IM消息-检测报告结果 + $data = [ + "order_inquiry_id" => $order_inquiry['order_inquiry_id'], + "inquiry_type" => $order_inquiry['inquiry_type'], + "detection_no" => $order_detection['detection_no'], + "patient_name" => $order_inquiry['patient_name'], + "patient_sex" => $order_inquiry['patient_sex'], + "patient_age" => $order_inquiry['patient_age'], + "detection_project_name" => $detection_project['detection_project_name'], + "disease_class_names" => $order_detection_case['detection_disease_class_names'], + "detection_result_pdf" => $order_detection['detection_result_pdf'], + "patient_user_id" => $order_detection['user_id'], + "doctor_user_id" => $user_doctor['user_id'], + ]; + $imService->detectionTestReport($data); + + // 发送IM消息-检测报告结果-文字 + $data = [ + "order_inquiry_id" => $order_inquiry['order_inquiry_id'], + "inquiry_type" => $order_inquiry['inquiry_type'], + "detection_no" => $order_detection['detection_no'], + "doctor_name" => $user_doctor['user_name'], + "patient_name" => $order_inquiry['patient_name'], + "patient_sex" => $order_inquiry['patient_sex'], + "patient_age" => $order_inquiry['patient_age'], + "detection_project_name" => $detection_project['detection_project_name'], + "patient_user_id" => $order_detection['user_id'], + "doctor_user_id" => $user_doctor['user_id'], + ]; + + $imService->detectionTestReportStr($data); + + return $this->detectionResultSuccessReturn(); + }else{ + // 检测家庭成员是否存在 + $params = array(); + $params['family_id'] = $order_detection['family_id']; + $params['patient_id'] = $order_detection['patient_id']; + $patient_family = PatientFamily::getOne($params); + if (empty($patient_family)) { + return $this->detectionResultFailReturn("患者信息错误"); + } + + Db::beginTransaction(); + + try { + $generator = $this->container->get(IdGeneratorInterface::class); + + // 创建问诊订单 + $data = array(); + $data['user_id'] = $order_detection['user_id']; + $data['patient_id'] = $order_detection['patient_id']; + $data['doctor_id'] = $order_detection['doctor_id']; + $data['family_id'] = $order_detection['family_id']; + $data['inquiry_type'] = 5; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测) + $data['inquiry_mode'] = 1; // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员) + $data['inquiry_status'] = 4; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消) + $data['inquiry_pay_channel'] = 3; // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付) + $data['inquiry_pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) + $data['inquiry_no'] = $generator->generate();// 订单编号 + $data['escrow_trade_no'] = "GD" . $generator->generate(); // 第三方支付流水号 + $data['amount_total'] = 0;// 订单金额 + $data['coupon_amount_total'] = 0;// 优惠卷总金额 + $data['payment_amount_total'] = 0;// 实际付款金额 + $data['pay_time'] = date('Y-m-d H:i:s', time());// 支付时间 + $data['reception_time'] = date('Y-m-d H:i:s', time());// 接诊时间 + $data['patient_name'] = $patient_family['card_name'];// 患者姓名-就诊人 + $data['patient_name_mask'] = $patient_family['card_name_mask'];// 患者姓名-就诊人(掩码) + $data['patient_sex'] = $patient_family['sex'];// 患者性别-就诊人(0:未知 1:男 2:女) + $data['patient_age'] = $patient_family['age'];// 患者年龄-就诊人 + $order_inquiry = OrderInquiry::addOrderInquiry($data); + if (empty($order_inquiry)) { + Db::rollBack(); + return $this->detectionResultFailReturn("问诊订单创建失败"); + } + + // 增加患者问诊病例 + $data = array(); + $data['user_id'] = $order_detection['user_id']; + $data['patient_id'] = $order_detection['patient_id']; + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];// 订单-问诊id + $data['family_id'] = $patient_family['family_id']; // 家庭成员id + $data['relation'] = $patient_family['relation']; // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 ) + $data['name'] = $patient_family['card_name']; // 患者名称 + $data['sex'] = $patient_family['sex'] ?? 0; // 患者性别(0:未知 1:男 2:女) + $data['age'] = $patient_family['age'] ?? null; // 患者年龄 + $data['height'] = $patient_family['height'] ?: null; // 身高(cm) + $data['weight'] = $patient_family['weight'] ?: null;; // 体重(kg) + $data['nation_id'] = $order_detection_case['nation_id'] ?: $patient_family['nation_id'] ?: null;; // 民族 + $data['nation_name'] = $order_detection_case['nation_name'] ?: $patient_family['nation_name'] ?: null;; // 民族名称 + $order_inquiry_case = OrderInquiryCase::addOrderInquiryCase($data); + if (empty($order_inquiry_case)) { + Db::rollBack(); + return $this->detectionResultFailReturn("问诊订单病例创建失败"); + } + + // 修改检测订单 + $data = array(); + $data['detection_status'] = 4; + $data['detection_result_pdf'] = $detection_result_pdf; + $data['detection_result_date'] = date('Y-m-d H:i:s',time()); + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];// 订单-问诊id + + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + OrderDetection::editOrderDetection($params,$data); + + // 添加自动完成队列 + $time = 1000 * 60 * 60 * 24 * 3; + + $data = array(); + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + + $message = new AutoCompleteInquiryDelayDirectProducer($data); + $message->setDelayMs($time); + $producer = $this->container->get(Producer::class); + $res = $producer->produce($message); + if (!$res) { + Db::rollBack(); + return $this->detectionResultFailReturn("添加自动完成队列失败"); + } + + $imService->patientCase( + $order_inquiry, + $user_doctor['user_id'], + $order_inquiry_case['disease_desc'] + ); + + // 发送IM消息-检测报告结果 + $data = [ + "order_inquiry_id" => $order_inquiry['order_inquiry_id'], + "inquiry_type" => $order_inquiry['inquiry_type'], + "detection_no" => $order_detection['detection_no'], + "patient_name" => $order_detection['patient_name'], + "patient_sex" => $order_detection['patient_sex'], + "patient_age" => $order_detection['patient_age'], + "detection_project_name" => $detection_project['detection_project_name'], + "disease_class_names" => $order_detection_case['detection_disease_class_names'], + "detection_result_pdf" => $order_detection['detection_result_pdf'], + "patient_user_id" => $order_detection['user_id'], + "doctor_user_id" => $user_doctor['user_id'], + ]; + $imService->detectionTestReport($data); + + // 发送IM消息-检测报告结果-文字 + $data = [ + "order_inquiry_id" => $order_inquiry['order_inquiry_id'], + "inquiry_type" => $order_inquiry['inquiry_type'], + "detection_no" => $order_detection['detection_no'], + "doctor_name" => $user_doctor['user_name'], + "patient_name" => $order_detection['patient_name'], + "patient_sex" => $order_detection['patient_sex'], + "patient_age" => $order_detection['patient_age'], + "detection_project_name" => $detection_project['detection_project_name'], + "patient_user_id" => $order_detection['user_id'], + "doctor_user_id" => $user_doctor['user_id'], + ]; + + $imService->detectionTestReportStr($data); + + Db::commit(); + } catch (\Throwable $e) { + Db::rollBack(); + return $this->detectionResultFailReturn($e->getMessage()); + } + } + + try { + // 患者-新报告生成通知 + $MessagePush = new MessagePush($order_detection['user_id']); + $MessagePush->patientDetectionResultNotice($order_detection['order_detection_id']); + + // 医生-通知医生患者检测报告已生成 + $MessagePush = new MessagePush($user_doctor['user_id']); + $MessagePush->doctorDetectionResultNotice($order_detection['order_detection_id']); + }catch (\Throwable $e){ + Log::getInstance("detectionResult")->error($e->getMessage()); + } + + return $this->detectionResultSuccessReturn(); + } catch (\Throwable $e) { + return $this->detectionResultFailReturn("异常:" . $e->getMessage()); + } + } + + /** + * 检测所结果回调失败 + * @param string $message + * @return ResponseInterface + */ + protected function detectionResultFailReturn(string $message): ResponseInterface + { + return $this->response + ->withStatus(200) + ->withBody( + new SwooleStream( + strval( + json_encode([ + 'code' => 0, + 'msg' => $message, + ], JSON_UNESCAPED_UNICODE) + ) + ) + ); + } + + /** + * 检测所结果回调成功 + * @param string $message + * @return ResponseInterface + */ + protected function detectionResultSuccessReturn(string $message = ""): ResponseInterface + { + return $this->response + ->withStatus(200) + ->withBody( + new SwooleStream( + strval( + json_encode([ + 'code' => 1, + 'msg' => $message, + ], JSON_UNESCAPED_UNICODE) + ) + ) + ); + } + } \ No newline at end of file diff --git a/app/Controller/DetectionController.php b/app/Controller/DetectionController.php new file mode 100644 index 0000000..ae6a7a5 --- /dev/null +++ b/app/Controller/DetectionController.php @@ -0,0 +1,122 @@ +getDetectionProjectList(); + return $this->response->json($data); + } + + /** + * 获取合作公司检测项目详情 + * @return ResponseInterface + */ + public function getDetectionProject(): ResponseInterface + { + $detectionService = new DetectionService(); + $data = $detectionService->getDetectionProject(); + return $this->response->json($data); + } + + /** + * 获取检测机构合作医生列表 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function getDetectionDoctorList(): ResponseInterface + { + $request = $this->container->get(DetectionRequest::class); + $request->scene('getDetectionDoctorList')->validateResolved(); + + $detectionService = new DetectionService(); + $data = $detectionService->getDetectionDoctorList(); + return $this->response->json($data); + } + + /** + * 获取检测项目用途列表 + * @return ResponseInterface + */ + public function getDetectionProjectPurposeList(): ResponseInterface + { + $detectionService = new DetectionService(); + $data = $detectionService->getDetectionProjectPurposeList(); + return $this->response->json($data); + } + + /** + * 创建检测订单 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function addDetectionOrder(): ResponseInterface + { + $request = $this->container->get(DetectionRequest::class); + $request->scene('addDetectionOrder')->validateResolved(); + + $detectionService = new DetectionService(); + $data = $detectionService->addDetectionOrder(); + return $this->response->json($data); + } + + /** + * 获取患者进行中的检测订单 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function getDetectionOrderFirst(): ResponseInterface + { + $request = $this->container->get(DetectionRequest::class); + $request->scene('getDetectionOrderFirst')->validateResolved(); + + $detectionService = new DetectionService(); + $data = $detectionService->getDetectionOrderFirst(); + return $this->response->json($data); + } + + /** + * 绑定检测管 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function bindDetectionTube(): ResponseInterface + { + $request = $this->container->get(DetectionRequest::class); + $request->scene('bindDetectionTube')->validateResolved(); + + $detectionService = new DetectionService(); + $data = $detectionService->bindDetectionTube(); + return $this->response->json($data); + } + + /** + * 创建检测问诊订单 + * @return ResponseInterface + */ + public function addDetectionInquiryOrder(): ResponseInterface + { + $detectionService = new DetectionService(); + $data = $detectionService->addDetectionInquiryOrder(); + return $this->response->json($data); + } + +} \ No newline at end of file diff --git a/app/Controller/InquiryController.php b/app/Controller/InquiryController.php index 8003941..a6e083a 100644 --- a/app/Controller/InquiryController.php +++ b/app/Controller/InquiryController.php @@ -131,4 +131,18 @@ class InquiryController extends AbstractController $data = $InquiryService->putFinishInquiry(); return $this->response->json($data); } + + /** + * 获取患者最后一条问诊订单id + * @return ResponseInterface + */ + public function getPatientLastInquiryId(): ResponseInterface + { + $request = $this->container->get(InquiryRequest::class); + $request->scene('getPatientLastInquiryId')->validateResolved(); + + $InquiryService = new InquiryService(); + $data = $InquiryService->getPatientLastInquiryId(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Controller/PatientOrderController.php b/app/Controller/PatientOrderController.php index 67e5afc..7a491e4 100644 --- a/app/Controller/PatientOrderController.php +++ b/app/Controller/PatientOrderController.php @@ -236,4 +236,66 @@ class PatientOrderController extends AbstractController $data = $PatientOrderService->deletePatientPrescriptionOrder(); return $this->response->json($data); } + + /** + * 获取患者检测订单列表 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function getPatientDetectionOrderList(): ResponseInterface + { + $request = $this->container->get(PatientOrderRequest::class); + $request->scene('getPatientDetectionOrderList')->validateResolved(); + + $PatientOrderService = new PatientOrderService(); + $data = $PatientOrderService->getPatientDetectionOrderList(); + return $this->response->json($data); + } + + /** + * 获取患者检测订单详情 + * @return ResponseInterface + */ + public function getPatientDetectionOrderInfo(): ResponseInterface + { + $PatientOrderService = new PatientOrderService(); + $data = $PatientOrderService->getPatientDetectionOrderInfo(); + return $this->response->json($data); + } + + /** + * 删除检测订单 + * @return ResponseInterface + */ + public function deletePatientDetectionOrder(): ResponseInterface + { + $PatientOrderService = new PatientOrderService(); + $data = $PatientOrderService->deletePatientDetectionOrder(); + return $this->response->json($data); + } + + /** + * 取消检测订单 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function putCancelPatientDetectionOrder(): ResponseInterface + { + $PatientOrderService = new PatientOrderService(); + $data = $PatientOrderService->putCancelPatientDetectionOrder(); + return $this->response->json($data); + } + + /** + * 检测订单取消支付 + * @return ResponseInterface + */ + public function putPatientDetectionOrderCancelPay(): ResponseInterface + { + $PatientOrderService = new PatientOrderService(); + $data = $PatientOrderService->putPatientDetectionOrderCancelPay(); + return $this->response->json($data); + } } \ No newline at end of file diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 098f35c..f068759 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -370,33 +370,221 @@ class TestController extends AbstractController } public function test_15(){ - $env_version = "release"; - $app_env = \Hyperf\Support\env("APP_ENV",'dev'); - if ($app_env == "dev"){ - $env_version = "trial"; + $params = array(); + $params[] = ['inquiry_type','=',2]; + $params[] = ['inquiry_mode','=',1]; + $params[] = ['start_time','<',date('H',time()) . date('i',time())]; + $params[] = ['end_time','>',date('H',time()) . date('i',time())]; + + $user_doctor_params = array(); + $user_doctor_params['is_platform_deep_cooperation'] = 1; + + $doctor_inquiry_config_params = array(); + $doctor_inquiry_config_params['inquiry_type'] = 2; + $doctor_inquiry_config_params['inquiry_mode'] = 1; + $doctor_inquiry_config_params['is_enable'] = 1; + + $doctor_inquiry_times = DoctorInquiryTime::getMinPlatDeepCooperationDoctor($params,$user_doctor_params,[],$doctor_inquiry_config_params); + dump($doctor_inquiry_times); + } + + // 设置坐班医生 + public function setDoctor(){ +// $timestamp = time(); // 当前时间戳 +// +// // 计算本周一的时间戳 +// $weekStartTimestamp = strtotime("Monday this week", $timestamp); +// +// // 获取每日日期 +// for ($i = 21; $i < 28; $i++) { +// $date = date('Y-m-d', strtotime("+$i days", $weekStartTimestamp)); +// $this->secondDoctor($date); +// } + } + + function firstDoctor($date){ + $dayOfWeek = date('N', strtotime($date)); + + // 第一周 + if ($dayOfWeek == 1){ + $doctor_id = "534770104371658752"; // 吕明磊 + } elseif ($dayOfWeek == 2){ + $doctor_id = "534770104371658752"; // 吕明磊 + } elseif ($dayOfWeek == 3){ + $doctor_id = "515881272740962304"; // 乔新勋 + } elseif ($dayOfWeek == 4){ + $doctor_id = "534770104371658752"; // 吕明磊 + } elseif ($dayOfWeek == 5){ + $doctor_id = "515881272740962304"; // 乔新勋 + } elseif ($dayOfWeek == 6){ + $doctor_id = "515881272740962304"; // 乔新勋 + } elseif ($dayOfWeek == 7){ + $doctor_id = "515881272740962304"; // 乔新勋 } - $options = [ - "jump_wxa" => [ - "path" => "pages/expertDetail/expertDetail", - "query" => "doctor_id=539452507563012096", - "env_version" => $env_version, - ], + $data = array(); + $data['doctor_id'] = $doctor_id; + $data['inquiry_type'] = 2; + $data['inquiry_mode'] = 1; + $data['inquiry_date'] = $date; + $data['start_time'] = "1000"; + $data['end_time'] = "1230"; + $doctor_inquiry_time = DoctorInquiryTime::add($data); + if (empty($doctor_inquiry_time)){ + return fail(); + } - "expire_type" => 1, - "expire_interval" => 1, + $data = array(); + $data['doctor_id'] = $doctor_id; + $data['inquiry_type'] = 2; + $data['inquiry_mode'] = 1; + $data['inquiry_date'] = $date; + $data['start_time'] = "1430"; + $data['end_time'] = "1730"; + $doctor_inquiry_time = DoctorInquiryTime::add($data); + if (empty($doctor_inquiry_time)){ + return fail(); + } - ]; + $data = array(); + $data['doctor_id'] = $doctor_id; + $data['inquiry_type'] = 2; + $data['inquiry_mode'] = 1; + $data['inquiry_date'] = $date; + $data['start_time'] = "1830"; + $data['end_time'] = "2130"; + $doctor_inquiry_time = DoctorInquiryTime::add($data); + if (empty($doctor_inquiry_time)){ + return fail(); + } - $Wechat = new Wechat(1); - $result = $Wechat->createUrlScheme($options); - dump($result); + $data = array(); + $data['doctor_id'] = $doctor_id; + $data['inquiry_type'] = 4; + $data['inquiry_mode'] = 1; + $data['inquiry_date'] = $date; + $data['start_time'] = "1000"; + $data['end_time'] = "1230"; + $doctor_inquiry_time = DoctorInquiryTime::add($data); + if (empty($doctor_inquiry_time)){ + return fail(); + } - $options = [ - "scheme" => $result['openlink'] - ]; + $data = array(); + $data['doctor_id'] = $doctor_id; + $data['inquiry_type'] = 4; + $data['inquiry_mode'] = 1; + $data['inquiry_date'] = $date; + $data['start_time'] = "1430"; + $data['end_time'] = "1730"; + $doctor_inquiry_time = DoctorInquiryTime::add($data); + if (empty($doctor_inquiry_time)){ + return fail(); + } - $result = $Wechat->getUrlScheme($options); - dump($result); + $data = array(); + $data['doctor_id'] = $doctor_id; + $data['inquiry_type'] = 4; + $data['inquiry_mode'] = 1; + $data['inquiry_date'] = $date; + $data['start_time'] = "1830"; + $data['end_time'] = "2130"; + $doctor_inquiry_time = DoctorInquiryTime::add($data); + if (empty($doctor_inquiry_time)){ + return fail(); + } + } + + function secondDoctor($date){ + $dayOfWeek = date('N', strtotime($date)); + + // 第一周 + if ($dayOfWeek == 1){ + $doctor_id = "515881272740962304"; // 乔新勋 + } elseif ($dayOfWeek == 2){ + $doctor_id = "534770104371658752"; // 吕明磊 + } elseif ($dayOfWeek == 3){ + $doctor_id = "515881272740962304"; // 乔新勋 + } elseif ($dayOfWeek == 4){ + $doctor_id = "534770104371658752"; // 吕明磊 + } elseif ($dayOfWeek == 5){ + $doctor_id = "515881272740962304"; // 乔新勋 + } elseif ($dayOfWeek == 6){ + $doctor_id = "534770104371658752"; // 吕明磊 + } elseif ($dayOfWeek == 7){ + $doctor_id = "515881272740962304"; // 乔新勋 + } + + $data = array(); + $data['doctor_id'] = $doctor_id; + $data['inquiry_type'] = 2; + $data['inquiry_mode'] = 1; + $data['inquiry_date'] = $date; + $data['start_time'] = "1000"; + $data['end_time'] = "1230"; + $doctor_inquiry_time = DoctorInquiryTime::add($data); + if (empty($doctor_inquiry_time)){ + return fail(); + } + + $data = array(); + $data['doctor_id'] = $doctor_id; + $data['inquiry_type'] = 2; + $data['inquiry_mode'] = 1; + $data['inquiry_date'] = $date; + $data['start_time'] = "1430"; + $data['end_time'] = "1730"; + $doctor_inquiry_time = DoctorInquiryTime::add($data); + if (empty($doctor_inquiry_time)){ + return fail(); + } + + $data = array(); + $data['doctor_id'] = $doctor_id; + $data['inquiry_type'] = 2; + $data['inquiry_mode'] = 1; + $data['inquiry_date'] = $date; + $data['start_time'] = "1830"; + $data['end_time'] = "2130"; + $doctor_inquiry_time = DoctorInquiryTime::add($data); + if (empty($doctor_inquiry_time)){ + return fail(); + } + + $data = array(); + $data['doctor_id'] = $doctor_id; + $data['inquiry_type'] = 4; + $data['inquiry_mode'] = 1; + $data['inquiry_date'] = $date; + $data['start_time'] = "1000"; + $data['end_time'] = "1230"; + $doctor_inquiry_time = DoctorInquiryTime::add($data); + if (empty($doctor_inquiry_time)){ + return fail(); + } + + $data = array(); + $data['doctor_id'] = $doctor_id; + $data['inquiry_type'] = 4; + $data['inquiry_mode'] = 1; + $data['inquiry_date'] = $date; + $data['start_time'] = "1430"; + $data['end_time'] = "1730"; + $doctor_inquiry_time = DoctorInquiryTime::add($data); + if (empty($doctor_inquiry_time)){ + return fail(); + } + + $data = array(); + $data['doctor_id'] = $doctor_id; + $data['inquiry_type'] = 4; + $data['inquiry_mode'] = 1; + $data['inquiry_date'] = $date; + $data['start_time'] = "1830"; + $data['end_time'] = "2130"; + $doctor_inquiry_time = DoctorInquiryTime::add($data); + if (empty($doctor_inquiry_time)){ + return fail(); + } } } \ No newline at end of file diff --git a/app/Controller/UserController.php b/app/Controller/UserController.php index 82a0825..fd32538 100644 --- a/app/Controller/UserController.php +++ b/app/Controller/UserController.php @@ -168,209 +168,52 @@ class UserController extends AbstractController return $this->response->json($data); } - // 支付测试 - public function testpay(){ - // 发起支付 - $out_trade_no = $this->request->input('out_trade_no'); -// $generator = $this->container->get(IdGeneratorInterface::class); -// -// $WechatPay = new WechatPay(1,2); -// -// // 获取预支付交易会话标识 -// $total = 0.01 * 100; -// $prepay = $WechatPay->getJsapiPrepayId($out_trade_no,$total,"omgU35DlE-rxTAGgcBjOuc4xdcX8"); -// if (empty($prepay)){ -// return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败"); -// } -// -// // 获取小程序支付配置 -// $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); -// return $this->response->json($pay_config); + /** + * 上报用户地址 + * @return ResponseInterface + */ + public function postLocation(): ResponseInterface + { + $UserService = new UserService(); + $data = $UserService->postLocation(); + return $this->response->json($data); + } - // 发起退款 -// $WechatPay = new WechatPay(1,2); -// -// $params = array(); -// $params['order_inquiry_id'] = 1; -// $order_inquiry = OrderInquiry::getOne($params); -// -// -// $options = array(); -// $options['transaction_id'] = "4200001756202303145016495897"; -// $options['out_refund_no'] = "123456"; -// $options['reason'] = "退款原因"; -// $options['amount'] = [ -// 'refund' => (int)1, -// 'total' => (int)1, -// 'currency' => "CNY", -// ]; -// -// $result = $WechatPay->refund($options); -// dump($result); + /** + * 获取用户地址 + * @return ResponseInterface + */ + public function getLocation(): ResponseInterface + { + $UserService = new UserService(); + $data = $UserService->getLocation(); + return $this->response->json($data); + } - // 创建账号 - $account = new Account(); - $profile = new Profile(); - $group = new Group(); - $friend = new Friend(); - $message = new Message(); -// $result = $account->createAccount(10009,'测试患者9',"https://img.applets.igandanyiyuan.com/applet/doctor/avatar/03dc8df2-e7c0-4ad9-b87e-5133e40e0f76.jpg"); - - // 查询账号导入状态 -// $result = $account->checkAccountStatus("123456"); - - // 设置账户资料 -// $arg = array(); -// $arg['Tag_Profile_IM_Gender'] = "Gender_Type_Male"; -// $arg['Tag_Profile_IM_BirthDay'] = 19961007; -// $arg['Tag_Profile_Custom_Hname'] = "协和医院"; -// $arg['Tag_Profile_Custom_Title'] = "主任医师"; -// $result = $profile->setProfile("123456",$arg); - - // 添加用户好友分组 -// $result = $group->addUserGroup('123456'); - - // 获取用户好友分组 -// $result = $group->getUserGroup('123456'); - - // 添加好友 -// $result = $friend->addFriend("123456",'1234567',"快速问诊"); - - // 发送消息 -// $arg = array(); -//// $arg['From_Account'] = "10000"; // 发送方user_id 如系统发送,无需填写 -// $arg['To_Account'] = "10000"; // 接收方user_id -//// $arg['ForbidCallbackControl'] = ['ForbidBeforeSendMsgCallback']; -//// $arg['SendMsgControl'] = []; -// -// $arg['MsgBody'] = [ -//// [ -//// "MsgType" => "TIMTextElem", -//// "MsgContent" => [ -//// "Text" => "ceshi", -//// ], -//// ] -// [ -// "MsgType" => "TIMCustomElem", -// "MsgContent" => [ -// "Data" => "{\"message_type\":1,\"content\":\"\"}", -// "Desc" => "自定义消息", -// "Ext" => "url", -// "Sound" => "dingdong.aiff", -// ], -// ] -// ]; -// -// // 自定义消息 -// $cloud_custom_data = array(); -// $cloud_custom_data['order_inquiry_id'] = 1; -// $cloud_custom_data['is_system'] = 0; -// $cloud_custom_data['inquiry_type'] = 2; -// -// $arg['CloudCustomData'] = json_encode($cloud_custom_data,JSON_UNESCAPED_UNICODE); -// -// $result = $message->sendMessage($arg); -// -//// $result = $profile->getOneAccountPortraitList("123456"); -// -// dump($result); - - - // 专家-公益,发送im消息 -// $ImService = new ImService(); -// -// // 获取订单医生数据 -// $params = array(); -// $params['doctor_id'] = "491925054779883520"; -// $user_doctor = UserDoctor::getOne($params); -// if (empty($user_doctor)){ -// Log::getInstance()->info("医生数据错误"); -// } -// -// // 发送消息 -// $ImService->sendMessage($user_doctor['user_id'],"491923510680424449","等待医生接诊",491937904055369728); - -// -// $data = array(); -// $data['order_inquiry_id'] = 4; -// $data['to_user_id'] = 10004; -// $data['patient_name'] = "用户4"; -// $data['patient_sex'] = 2; -// $data['patient_age'] = 19; -// $data['inquiry_status'] = 1; -// $data['message_send_time'] = 1678112190; -// $data['message_seq'] = 101; -// $data['message_type'] = "TIMTextElem"; -// $data['last_message_content']['Text'] = "测试消息4"; -// -// $imService = new ImService(); -// $imService->addRecentContactRecordCache("491925054779883520", 2, 10004, $data); - - // 银行卡三要素认证 -// $BankCard = new BankCard(); -// -// $params = array(); -// $params['bankCardNo'] = "6217000010175646317"; -// $params['name'] = "吴从兴"; -// $params['idCardNo'] = "372929199610075412"; -// $res = $BankCard->checkBankCard($params); -// if (!empty($res)) { -// return fail(HttpEnumCode::HTTP_ERROR, $res); -// } - - // 对接处方平台 -// $Prescription = new Prescription(); -// $token = $Prescription->getProd(); -// dump($token); - - // 创建im账号 -// $account = new Account(); - // 创建单个账号 -// $account->createAccount("111295","测试患者1",""); -// $profile = new Profile(); -// $result = $profile->getOneAccountPortraitList("111295"); -// dump($result); -// $arg = array(); -// $arg['Tag_Profile_IM_Image'] = "https://img.applets.igandanyiyuan.com/applet/doctor/avatar/03dc8df2-e7c0-4ad9-b87e-5133e40e0f76.jpg"; -// $profile->setProfile("111295",$arg); - -// $ImService = new ImService(); -// $ImService->setUserProfile("491925054435950592"); - -// $Prescription = new Prescription(); -// $token = $Prescription->getLogisticsFee(); -// dump($token); - - -// $ImService = new ImService(); -// -// // 发送消息 -// $ImService->sendMessage("491925054435950592","492404831991414785","等待医生接诊","494837308861095936",1); - - - -// $ImService = new ImService(); -// // 发送消息 - // 自定义消息 -// $cloud_custom_data = array(); -// $cloud_custom_data['order_inquiry_id'] = "494837308861095936"; -// $cloud_custom_data['is_system'] = 1; -// $cloud_custom_data['inquiry_type'] = 1; -// -// // 消息内容 -// $message_content_data = array(); -// $message_content_data['message_type'] = 1; -// $message_content_data['content'] = "--测试--"; -// $message_content_data['desc'] = "温馨提示:您可继续补充问诊内容,便于更快确认病情,医生均在临床一线工作,还请耐心等待,医生接诊会第一时间短信通知您。"; -// $message_content = [ -// 'Data' => json_encode($message_content_data,JSON_UNESCAPED_UNICODE), -// ]; -// -// $ImService->sendMessage("491925054435950592", "492404831991414785", $message_content, "TIMCustomElem", $cloud_custom_data); -// -// $RecentContact = new RecentContact(); -// $result = $RecentContact->getRecentContactPage(); + /** + * 获取用户配置 + * @return ResponseInterface + */ + public function getUserSystem(): ResponseInterface + { + $UserService = new UserService(); + $data = $UserService->getUserSystem(); + return $this->response->json($data); + } + /** + * 修改用户配置 + * @return ResponseInterface + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function putUserSystem(): ResponseInterface + { + $request = $this->container->get(UserRequest::class); + $request->scene('putUserSystem')->validateResolved(); + $UserService = new UserService(); + $data = $UserService->putUserSystem(); + return $this->response->json($data); } } \ No newline at end of file diff --git a/app/Controller/UserDoctorController.php b/app/Controller/UserDoctorController.php index 0844187..3e15027 100644 --- a/app/Controller/UserDoctorController.php +++ b/app/Controller/UserDoctorController.php @@ -2,7 +2,6 @@ namespace App\Controller; -use App\Amqp\Producer\PrescriptionDistributePhProducer; use App\Constants\HttpEnumCode; use App\Model\OrderPrescriptionIcd; use App\Model\OrderPrescriptionProduct; diff --git a/app/Model/BasicCompany.php b/app/Model/BasicCompany.php new file mode 100644 index 0000000..df2e14b --- /dev/null +++ b/app/Model/BasicCompany.php @@ -0,0 +1,73 @@ +first($fields); + } + + /** + * 获取数据-多 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增-批量 + * @param array $data 新增数据 + * @return \Hyperf\Database\Model\Model|BasicCompany + */ + public static function addBasicCompany(array $data): \Hyperf\Database\Model\Model|BasicCompany + { + return self::create($data); + } + + /** + * 修改-批量 + * @param array $params + * @param array $data + * @return int + */ + public static function editBasicCompany(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } +} diff --git a/app/Model/BasicDetectionOrgan.php b/app/Model/BasicDetectionOrgan.php new file mode 100644 index 0000000..1967aac --- /dev/null +++ b/app/Model/BasicDetectionOrgan.php @@ -0,0 +1,83 @@ +first($fields); + } + + /** + * 获取数据-多 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增-批量 + * @param array $data 新增数据 + * @return \Hyperf\Database\Model\Model|BasicDetectionOrgan + */ + public static function add(array $data): \Hyperf\Database\Model\Model|BasicDetectionOrgan + { + return self::create($data); + } + + /** + * 修改-批量 + * @param array $params + * @param array $data + * @return int + */ + public static function edit(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } + +} diff --git a/app/Model/DetectionProject.php b/app/Model/DetectionProject.php new file mode 100644 index 0000000..b84bfa7 --- /dev/null +++ b/app/Model/DetectionProject.php @@ -0,0 +1,82 @@ +first($fields); + } + + /** + * 获取数据-多 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增-批量 + * @param array $data 新增数据 + * @return \Hyperf\Database\Model\Model|DetectionProject + */ + public static function addBasicCompany(array $data): \Hyperf\Database\Model\Model|DetectionProject + { + return self::create($data); + } + + /** + * 修改-批量 + * @param array $params + * @param array $data + * @return int + */ + public static function editBasicCompany(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } +} diff --git a/app/Model/DetectionProjectPurpose.php b/app/Model/DetectionProjectPurpose.php new file mode 100644 index 0000000..bb8bb2c --- /dev/null +++ b/app/Model/DetectionProjectPurpose.php @@ -0,0 +1,77 @@ +first($fields); + } + + /** + * 获取数据-多 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增-批量 + * @param array $data 新增数据 + * @return \Hyperf\Database\Model\Model|DetectionProjectPurpose + */ + public static function addDetectionProjectPurpose(array $data): \Hyperf\Database\Model\Model|DetectionProjectPurpose + { + return self::create($data); + } + + /** + * 修改-批量 + * @param array $params + * @param array $data + * @return int + */ + public static function editDetectionProjectPurpose(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } +} diff --git a/app/Model/DiseaseClassDetection.php b/app/Model/DiseaseClassDetection.php new file mode 100644 index 0000000..f430aef --- /dev/null +++ b/app/Model/DiseaseClassDetection.php @@ -0,0 +1,80 @@ +first($fields); + } + + /** + * 获取数据-多 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增-批量 + * @param array $data 新增数据 + * @return \Hyperf\Database\Model\Model|DiseaseClassDetection + */ + public static function addDiseaseClassDetection(array $data): \Hyperf\Database\Model\Model|DiseaseClassDetection + { + return self::create($data); + } + + /** + * 修改-批量 + * @param array $params + * @param array $data + * @return int + */ + public static function editDiseaseClassDetection(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } +} diff --git a/app/Model/DoctorInquiryConfig.php b/app/Model/DoctorInquiryConfig.php index 9c48ba3..5a81372 100644 --- a/app/Model/DoctorInquiryConfig.php +++ b/app/Model/DoctorInquiryConfig.php @@ -14,6 +14,8 @@ use Hyperf\Snowflake\Concern\Snowflake; * @property string $doctor_id 医生id * @property int $inquiry_type 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) * @property int $inquiry_mode 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员) + * @property int $is_enable 是否启用(0:否 1:是) + * @property int $last_enable_method 最后开启方式(1:自己 2:后台) * @property int $work_num_day 每日接诊数量 * @property string $inquiry_price 接诊价格(专家问诊-公益问诊) * @property \Carbon\Carbon $created_at 创建时间 @@ -31,12 +33,12 @@ class DoctorInquiryConfig extends Model /** * The attributes that are mass assignable. */ - protected array $fillable = ['inquiry_config_id', 'doctor_id', 'inquiry_type', 'inquiry_mode', 'work_num_day', 'inquiry_price', 'created_at', 'updated_at']; + protected array $fillable = ['inquiry_config_id', 'doctor_id', 'inquiry_type', 'inquiry_mode', 'is_enable', 'last_enable_method', 'work_num_day', 'inquiry_price', 'created_at', 'updated_at']; /** * The attributes that should be cast to native types. */ - protected array $casts = ['inquiry_config_id' => 'string', 'doctor_id' => 'string', 'inquiry_type' => 'integer', 'inquiry_mode' => 'integer', 'work_num_day' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime']; + protected array $casts = ['inquiry_config_id' => 'string', 'doctor_id' => 'string', 'inquiry_type' => 'integer', 'inquiry_mode' => 'integer', 'work_num_day' => 'integer', 'created_at' => 'datetime', 'updated_at' => 'datetime', 'is_enable' => 'integer', 'last_enable_method' => 'integer']; protected string $primaryKey = "inquiry_config_id"; @@ -52,14 +54,14 @@ class DoctorInquiryConfig extends Model } /** - * 获取医生接诊配置信息-单条 + * 获取医生接诊配置信息 * @param array $params * @param array $fields * @return object|null */ - public static function getInquiryConfigOne(array $params, array $fields = ['*']): object|null + public static function getInquiryConfigList(array $params, array $fields = ['*']): object|null { - return self::where($params)->first($fields); + return self::where($params)->get($fields); } /** @@ -70,7 +72,7 @@ class DoctorInquiryConfig extends Model * @param array $inquiry_type_in_params * @return object|null */ - public static function getInquiryConfigList(array $params, array $fields = ['*'] , array $inquiry_type_in_params = [1,3]): object|null + public static function getInquiryConfigListByInquiryType(array $params, array $fields = ['*'] , array $inquiry_type_in_params = [1,3]): object|null { return self::where($params)->whereIn("inquiry_type",$inquiry_type_in_params)->get($fields); } diff --git a/app/Model/DoctorInquiryTime.php b/app/Model/DoctorInquiryTime.php index 1fbb332..beb5748 100644 --- a/app/Model/DoctorInquiryTime.php +++ b/app/Model/DoctorInquiryTime.php @@ -6,11 +6,10 @@ namespace App\Model; -use Hyperf\Database\Model\Builder; use Hyperf\Database\Model\Collection; -use Hyperf\Database\Model\Model; use Hyperf\Database\Model\Relations\HasOne; use Hyperf\Snowflake\Concern\Snowflake; +use Hyperf\DbConnection\Db; /** * @property int $inquiry_time_id 主键id @@ -114,4 +113,30 @@ class DoctorInquiryTime extends Model ->get($fields); } + public static function add(array $data): \Hyperf\Database\Model\Model|DoctorInquiryTime + { + return self::create($data); + } + + /** + * 获取坐班时间包含某时间的平台深度合作医生 + * @param array $params + * @param array $user_doctor_params + * @param array $user_doctor_not_in_params + * @param array $doctor_inquiry_config_params + * @param array $fields + * @return array|\Hyperf\Collection\Collection|Collection + */ + public static function getMinPlatDeepCooperationDoctor(array $params = [],array $user_doctor_params = [], array $user_doctor_not_in_params = [],array $doctor_inquiry_config_params = [], array $fields = ['*']): Collection|array|\Hyperf\Collection\Collection + { + $doctor_ids = Db::table('doctor_inquiry_config')->where($doctor_inquiry_config_params)->select("doctor_id"); + + $result = self::whereHas('UserDoctor' , function($query) use ($user_doctor_params,$user_doctor_not_in_params){ + $query->where($user_doctor_params)->whereNotIn('doctor_id',$user_doctor_not_in_params); + }) + ->where($params) + ->whereIn("doctor_id",$doctor_ids) + ->get($fields); + return $result; + } } diff --git a/app/Model/OrderDetection.php b/app/Model/OrderDetection.php new file mode 100644 index 0000000..cae0655 --- /dev/null +++ b/app/Model/OrderDetection.php @@ -0,0 +1,168 @@ +first($fields); + } + + /** + * 获取信息-单条 + * @param array $params + * @param array $fields + * @return object|null + */ + public static function getLastOne(array $params, array $fields = ['*']): object|null + { + return self::where($params)->latest()->first($fields); + } + + /** + * 获取数据-多 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增-批量 + * @param array $data 新增数据 + * @return \Hyperf\Database\Model\Model|OrderDetection + */ + public static function addOrderDetection(array $data): \Hyperf\Database\Model\Model|OrderDetection + { + return self::create($data); + } + + /** + * 修改-批量 + * @param array $params + * @param array $data + * @return int + */ + public static function editOrderDetection(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } + + /** + * 获取未完成订单 + * @param array $params + * @param array $fields + * @return object|null + */ + public static function getNotFinishedOrderDetectionOne(array $params,array $fields = ['*']): object|null + { + return self::where($params)->whereIn('detection_status',[1,2,3])->first($fields); + } + + /** + * 获取问诊订单分页 + * 已结束 + * @param array $params + * @param array $detection_status_params + * @param array $fields + * @param int|null $page + * @param int|null $per_page + * @return array + */ + public static function getPatientOrderDetectionPage(array $params, array $detection_status_params, array $fields = ["*"], int $page = null, ?int $per_page = 10): array + { + $raw = self::where($params) + ->when($detection_status_params, function ($query, $detection_status_params) { + $query->whereIn('detection_status', $detection_status_params); + }) + ->orderBy('created_at', 'desc') + ->paginate($per_page, $fields, "page", $page); + + $data = array(); + $data['current_page'] = $raw->currentPage();// 当前页码 + $data['total'] = $raw->total();//数据总数 + $data['data'] = $raw->items();//数据 + $data['per_page'] = $raw->perPage();//每页个数 + $data['last_page'] = $raw->lastPage();//最后一页 + + return $data; + } + + /** + * 获取数量 + * @param array $params + * @return int + */ + public static function getCount(array $params): int + { + return self::where($params)->count(); + } +} diff --git a/app/Model/OrderDetectionCase.php b/app/Model/OrderDetectionCase.php new file mode 100644 index 0000000..e233fbb --- /dev/null +++ b/app/Model/OrderDetectionCase.php @@ -0,0 +1,87 @@ +first($fields); + } + + /** + * 获取数据-多 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增-批量 + * @param array $data 新增数据 + * @return \Hyperf\Database\Model\Model|OrderDetectionCase + */ + public static function addOrderDetectionCase(array $data): \Hyperf\Database\Model\Model|OrderDetectionCase + { + return self::create($data); + } + + /** + * 修改-批量 + * @param array $params + * @param array $data + * @return int + */ + public static function editOrderDetectionCase(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } + +} diff --git a/app/Model/OrderDetectionRefund.php b/app/Model/OrderDetectionRefund.php new file mode 100644 index 0000000..4b5b5cb --- /dev/null +++ b/app/Model/OrderDetectionRefund.php @@ -0,0 +1,84 @@ +first($fields); + } + + /** + * 获取数据-多 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增-批量 + * @param array $data 新增数据 + * @return \Hyperf\Database\Model\Model|OrderDetectionRefund + */ + public static function add(array $data): \Hyperf\Database\Model\Model|OrderDetectionRefund + { + return self::create($data); + } + + /** + * 修改-批量 + * @param array $params + * @param array $data + * @return int + */ + public static function edit(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } +} diff --git a/app/Model/OrderInquiry.php b/app/Model/OrderInquiry.php index 172accf..669597b 100644 --- a/app/Model/OrderInquiry.php +++ b/app/Model/OrderInquiry.php @@ -8,6 +8,7 @@ namespace App\Model; use Hyperf\Database\Model\Collection; use Hyperf\Database\Model\Relations\HasOne; use Hyperf\Database\Query\Builder; +use Hyperf\DbConnection\Db; use Hyperf\Snowflake\Concern\Snowflake; /** @@ -434,4 +435,102 @@ class OrderInquiry extends Model ->limit($limit) ->get($fields); } + + /** + * 获取问诊结束会话列表-分页 + * @param array $params + * @param array $fields + * @param int|null $page + * @param int|null $per_page + * @return array + */ + public static function getInquiryEndPage(array $params, int $page = null, ?int $per_page = 10): array + { +// 参考sql +// SELECT t1.* FROM test t1 INNER JOIN ( +// SELECT user_id, MAX(create_at) AS max_create_at FROM test GROUP BY user_id +// ) t2 ON t1.user_id = t2.user_id AND t1.create_at = t2.max_create_at; + $subQuery = self::select(["user_id","family_id",Db::raw('max(reception_time) as at')]) + ->whereNotIn('user_id', function ($query) use ($params){ + $query->select('user_id') + ->from('order_inquiry') + ->whereIn('inquiry_status', [1,2,3,4]) + ->where($params) + ->groupBy(["user_id"]); + }) + ->where($params) + ->groupBy(["user_id","family_id"]); + + + $query = self:: joinSub($subQuery, 'sub_query', function($join) { + $join->on('order_inquiry.user_id', '=', 'sub_query.user_id') + ->on('order_inquiry.family_id', '=', 'sub_query.family_id') + ->on('order_inquiry.reception_time', '=', 'sub_query.at'); + }) + ->whereIn('inquiry_status', [5,6]) + ->where($params) + ->orderBy("sub_query.at",'desc'); + + + $fields = [ + 'order_inquiry.order_inquiry_id', + 'order_inquiry.user_id', + 'order_inquiry.patient_id', + 'order_inquiry.doctor_id', + 'order_inquiry.family_id', + 'order_inquiry.inquiry_type', + 'order_inquiry.inquiry_mode', + 'order_inquiry.inquiry_status', + 'order_inquiry.inquiry_no', + 'order_inquiry.reception_time', + 'order_inquiry.complete_time', + 'order_inquiry.finish_time', + 'order_inquiry.cancel_time', + 'order_inquiry.cancel_reason', + 'order_inquiry.cancel_remarks', + 'order_inquiry.patient_name', + 'order_inquiry.patient_sex', + 'order_inquiry.patient_age', + 'order_inquiry.created_at', + ]; + + $result = $query->paginate($per_page, $fields, "page", $page); + + $data = array(); + $data['current_page'] = $result->currentPage();// 当前页码 + $data['total'] = $result->total();//数据总数 + $data['data'] = $result->items();//数据 + $data['per_page'] = $result->perPage();//每页个数 + $data['last_page'] = $result->lastPage();//最后一页 + + return $data; + } + + /** + * 获取某种状态的最后一条订单 + * @param array $params + * @param array $inquiry_status_params + * @param array $fields + * @return object|null + */ + public static function getInquiryStatusLastOne(array $params, array $inquiry_status_params,array $fields = ["*"]): object|null + { + return self::where($params) + ->whereIn("inquiry_status", $inquiry_status_params) + ->latest() + ->first($fields); + } + + /** + * 获取最后一条订单 + * @param array $params + * @param array $fields + * @return object|null + */ + public static function getInquiryLastOne(array $params,array $fields = ["*"]): object|null + { + return self::where($params) + ->latest() + ->first($fields); + } } diff --git a/app/Model/OrderInquiryCase.php b/app/Model/OrderInquiryCase.php index e65bbec..1584daf 100644 --- a/app/Model/OrderInquiryCase.php +++ b/app/Model/OrderInquiryCase.php @@ -32,12 +32,14 @@ use Hyperf\Snowflake\Concern\Snowflake; * @property string $family_history 家族病史描述 * @property int $is_pregnant 是否备孕、妊娠、哺乳期(0:否 1:是) * @property string $pregnant 备孕、妊娠、哺乳期描述 - * @property int $is_taboo 是否存在禁忌药物(0:否 1:是)问诊购药时存在 + * @property int $is_taboo 是否服用过禁忌药物,且无相关禁忌(0:否 1:是)问诊购药时存在 + * @property int $nation_id 民族 + * @property string $nation_name 民族名称 * @property \Carbon\Carbon $created_at 创建时间 * @property \Carbon\Carbon $updated_at 修改时间 - * @property-read BasicJob $BasicJob - * @property-read BasicNation $BasicNation - * @property-read OrderInquiry $OrderInquiry + * @property-read BasicJob|null $BasicJob + * @property-read BasicNation|null $BasicNation + * @property-read OrderInquiry|null $OrderInquiry */ class OrderInquiryCase extends Model { @@ -51,7 +53,7 @@ class OrderInquiryCase extends Model /** * The attributes that are mass assignable. */ - protected array $fillable = ['inquiry_case_id', 'user_id', 'patient_id', 'order_inquiry_id', 'family_id', 'relation', 'status', 'name', 'sex', 'age', 'height', 'weight', 'disease_class_id', 'disease_class_name', 'diagnosis_date', 'disease_desc', 'diagnose_images', 'is_allergy_history', 'allergy_history', 'is_family_history', 'family_history', 'is_pregnant', 'pregnant', 'is_taboo', 'created_at', 'updated_at']; + protected array $fillable = ['inquiry_case_id', 'user_id', 'patient_id', 'order_inquiry_id', 'family_id', 'relation', 'status', 'name', 'sex', 'age', 'height', 'weight', 'disease_class_id', 'disease_class_name', 'diagnosis_date', 'disease_desc', 'diagnose_images', 'is_allergy_history', 'allergy_history', 'is_family_history', 'family_history', 'is_pregnant', 'pregnant', 'is_taboo', 'nation_id', 'nation_name', 'created_at', 'updated_at']; protected string $primaryKey = "inquiry_case_id"; @@ -119,4 +121,15 @@ class OrderInquiryCase extends Model { return self::create($data); } + + /** + * 修改-批量 + * @param array $params + * @param array $data + * @return int + */ + public static function edit(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } } diff --git a/app/Model/OrderSystem.php b/app/Model/OrderSystem.php new file mode 100644 index 0000000..d5d7e3c --- /dev/null +++ b/app/Model/OrderSystem.php @@ -0,0 +1,82 @@ +first($fields); + } + + /** + * 获取数据-多 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增数据 + * @param array $data + * @return \Hyperf\Database\Model\Model|OrderSystem + */ + public static function addOrderSystem(array $data = []): \Hyperf\Database\Model\Model|OrderSystem + { + return self::create($data); + } + + /** + * 修改 + * @param array $params + * @param array $data + * @return int + */ + public static function edit(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } + +} diff --git a/app/Model/Product.php b/app/Model/Product.php index 2f4b1b7..7059df5 100644 --- a/app/Model/Product.php +++ b/app/Model/Product.php @@ -159,6 +159,39 @@ class Product extends Model return $data; } + /** + * 获取列表-分页 + * @param array $params 条件 + * @param string $keyword 搜索条件 + * @param array $fields 字段 + * @param int|null $page 页码 + * @param int|null $per_page 每页个数 + * @return array + */ + public static function getWithAmountPage(array $params,string $keyword, array $fields = ["*"], int $page = null, ?int $per_page = 10): array + { + $raw = self::with([ + 'ProductPlatformAmount:amount_id,product_platform_id,stock' + ]) + ->when($keyword, function ($query, $keyword) { + $query->where(function ($query) use ($keyword) { + $query->orwhere("product_name", 'like', '%' . $keyword . '%'); + $query->orwhere("common_name", 'like', '%' . $keyword . '%'); + $query->orwhere("mnemonic_code", 'like', '%' . $keyword . '%'); + }); + }) + ->where($params)->paginate($per_page, $fields, "page", $page); + + $data = array(); + $data['current_page'] = $raw->currentPage();// 当前页码 + $data['total'] = $raw->total();//数据总数 + $data['data'] = $raw->items();//数据 + $data['per_page'] = $raw->perPage();//每页个数 + $data['last_page'] = $raw->lastPage();//最后一页 + + return $data; + } + /** * 新增 * @param array $data diff --git a/app/Model/User.php b/app/Model/User.php index 5a452fb..9a19c85 100644 --- a/app/Model/User.php +++ b/app/Model/User.php @@ -9,20 +9,22 @@ use Hyperf\Database\Model\Builder; use Hyperf\Snowflake\Concern\Snowflake; /** - * @property string $user_id 主键 + * @property int $user_id 主键 * @property string $user_name 用户名称 * @property string $user_account 账号 * @property string $mobile 手机号 - * @property int $sex 性别(0:未知 1:男 2:女) - * @property string $avatar 头像 * @property string $wx_mobile 微信手机号 * @property string $user_password 密码 * @property string $salt 密码混淆码 * @property int $user_type 用户类型(1:患者 2:医师 3:药师) * @property int $user_status 状态(0:禁用 1:正常 2:删除) - * @property int $register_method 注册方式(1:微信小程序 ) + * @property int $register_method 注册方式(1:微信小程序 2:后台添加 ) + * @property int $age 年龄 + * @property int $sex 性别(0:未知 1:男 2:女) + * @property string $avatar 头像 * @property string $login_ip 登陆ip * @property string $last_login_at 最后登陆时间 + * @property string $created_by 创建者id(后台用户表id null:自己注册) * @property \Carbon\Carbon $created_at 创建时间 * @property \Carbon\Carbon $updated_at 修改时间 */ @@ -38,7 +40,7 @@ class User extends Model /** * The attributes that are mass assignable. */ - protected array $fillable = ['user_id', 'user_name', 'user_account', 'mobile', 'sex', 'avatar', 'wx_mobile', 'user_password', 'salt', 'user_type', 'user_status', 'register_method', 'login_ip', 'last_login_at', 'created_at', 'updated_at']; + protected array $fillable = ['user_id', 'user_name', 'user_account', 'mobile', 'wx_mobile', 'user_password', 'salt', 'user_type', 'user_status', 'register_method', 'age', 'sex', 'avatar', 'login_ip', 'last_login_at', 'created_by', 'created_at', 'updated_at']; protected string $primaryKey = "user_id"; diff --git a/app/Model/UserDoctor.php b/app/Model/UserDoctor.php index c7a505e..ff6b0c7 100644 --- a/app/Model/UserDoctor.php +++ b/app/Model/UserDoctor.php @@ -183,12 +183,12 @@ class UserDoctor extends Model // 是否在线(0:不在线 1:在线) $params["is_online"] = 1; - // 是否参加专家图文接诊(0:否 1:是) - $params["is_img_expert_reception"] = 1; +// // 是否参加专家图文接诊(0:否 1:是) +// $params["is_img_expert_reception"] = 1; $datas = self::with([ 'Hospital:hospital_id,hospital_name,hospital_level_name', - 'DoctorInquiryConfig', + "DoctorInquiryConfig", ]) ->where($params) ->orderBy("is_recommend", "desc") @@ -202,6 +202,108 @@ class UserDoctor extends Model return $datas; } +// /** +// * 获取问诊医生列表 +// * 专家问诊-公益问诊共用 +// * @param string $keyword +// * @param array $hospital_params 医院搜索条件 +// * @param array $doctor_params 医生搜索条件 +// * @param array $doctor_expertise_params +// * @param string|int $sort_order +// * @param array $fields +// * @param int|null $page +// * @param int|null $per_page +// * @return array +// */ +// public static function getInquiryDoctorPage(string $keyword = "", array $hospital_params = [], array $doctor_params = [], array $doctor_expertise_params = [], string|int $sort_order = 1, array $fields = ["*"], int $page = null, ?int $per_page = 10): array +// { +// $query = self::with([ +// "Hospital:hospital_id,hospital_name,hospital_status,hospital_level_name,province_id,city_id", +// "DoctorExpertise", +// "DoctorInquiryConfig" => function ($query) use ($sort_order) { +// $query->whereIn('inquiry_type', [1, 3]) +// ->where('inquiry_mode', 1); +// }, +// ]) +// ->where($doctor_params) +// ->when($keyword, function ($query, $keyword) { +// $query->where(function ($query) use ($keyword) { +// $query->orwhere("user_name", 'like', '%' . $keyword . '%'); +// $query->orwhere("department_custom_name", 'like', '%' . $keyword . '%'); +// $query->orWhereHas('Hospital', function ($query) use ($keyword) { +// $query->where('hospital_name', 'like', '%' . $keyword . '%'); +// }); +// }); +// }) +// ->whereHas('Hospital', function ($query) use ($hospital_params) { +// $query->where($hospital_params); +// }) +// ->whereHas('DoctorExpertise', function ($query) use ($doctor_expertise_params) { +// $query->where($doctor_expertise_params); +// }) +// ->whereHas('DoctorInquiryConfig', function ($query) { +// $params = array(); +// $params['inquiry_mode'] = 1;// 接诊方式:图文 +// $query->where($params)->whereIn('inquiry_type', [1, 3]); +// }); +// +// if (!empty($sort_order)){ +// if (in_array($sort_order,[1,3,4])){ +// $query = $query->join('doctor_inquiry_config', function ($query) { +// $query->on('user_doctor.doctor_id', '=', 'doctor_inquiry_config.doctor_id') +// ->whereIn('inquiry_type', [1, 3]) +// ->where('inquiry_mode', 1) +// ->orderBy('inquiry_price', 'desc') +// ->take(1); +// }) +// ->select("user_doctor.*") +// ->groupBy("user_doctor.doctor_id"); +// } +// +// if ($sort_order == 1) { +// // 综合-价格从低到高 +// $query->orderBy('is_recommend', 'desc');// 是否首页推荐(0:否 1:是) +// $query->orderByRaw('avg_response_time = 0 ASC'); +// $query->orderBy('avg_response_time'); +// $query->orderBy('served_patients_num', 'desc');// 服务数从多到少 +// $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 +// $query->orderBy('doctor_inquiry_config.inquiry_price', 'asc'); +// } elseif ($sort_order == 2) { +// // 响应时间快 +// $query->orderByRaw('avg_response_time = 0 ASC'); +// $query->orderBy('avg_response_time'); +// $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 +// } elseif ($sort_order == 3) { +// // 价格从低到高 +// $query->orderBy('doctor_inquiry_config.inquiry_price', 'asc'); +// $query->orderByRaw('avg_response_time = 0 ASC'); +// $query->orderBy('avg_response_time'); +// $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 +// } elseif ($sort_order == 4) { +// // 价格从高到低 +// $query->orderBy('doctor_inquiry_config.inquiry_price', 'desc'); +// $query->orderByRaw('avg_response_time = 0 ASC'); +// $query->orderBy('avg_response_time'); +// $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 +// } elseif ($sort_order == 5) { +// // 服务数从多到少 +// $query->orderBy('served_patients_num', 'desc'); +// $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 +// } +// } +// +// $result = $query->paginate($per_page, $fields, "page", $page); +// +// $data = array(); +// $data['current_page'] = $result->currentPage();// 当前页码 +// $data['total'] = $result->total();//数据总数 +// $data['data'] = $result->items();//数据 +// $data['per_page'] = $result->perPage();//每页个数 +// $data['last_page'] = $result->lastPage();//最后一页 +// +// return $data; +// } + /** * 获取问诊医生列表 * 专家问诊-公益问诊共用 @@ -209,40 +311,24 @@ class UserDoctor extends Model * @param array $hospital_params 医院搜索条件 * @param array $doctor_params 医生搜索条件 * @param array $doctor_expertise_params + * @param array $inquiry_type * @param string|int $sort_order * @param array $fields * @param int|null $page * @param int|null $per_page * @return array */ - public static function getInquiryDoctorPage(string $keyword = "", array $doctor_params = [], string|int $sort_order = 1, array $fields = ["*"], int $page = null, ?int $per_page = 10): array + public static function getInquiryDoctorPage(string $keyword = "", array $hospital_params = [], array $doctor_params = [], array $doctor_expertise_params = [],array $inquiry_type = [1,3], string|int $sort_order = 1, array $fields = ["*"], int $page = null, ?int $per_page = 10): array { $query = self::with([ "Hospital:hospital_id,hospital_name,hospital_status,hospital_level_name,province_id,city_id", "DoctorExpertise", - "DoctorExpertise.DiseaseClassExpertise:expertise_id,expertise_name", - "DoctorInquiryConfig" => function ($query) use ($sort_order) { - $params = array(); - $params['inquiry_mode'] = 1;// 接诊方式:图文 - $query->where($params)->whereIn('inquiry_type', [1, 3]); -// if ($sort_order == 1) { -// // 综合 -// $query->orderBy('inquiry_price', 'asc');// 价格从低到高 -// } elseif ($sort_order == 3) { -// // 价格从低到高 -// $query->orderBy('inquiry_price', 'asc'); -// } elseif ($sort_order == 4) { -// // 价格从高到低 -// $query->orderBy('inquiry_price', 'desc');// 价格从高到低 -// } - - return $query; + "DoctorInquiryConfig" => function ($query) use ($inquiry_type) { + $query->whereIn('inquiry_type', $inquiry_type) + ->where('inquiry_mode', 1); }, ]) ->where($doctor_params) -// ->whereHas('Hospital', function ($query) use ($hospital_params) { -// $query->where($hospital_params); -// }) ->when($keyword, function ($query, $keyword) { $query->where(function ($query) use ($keyword) { $query->orwhere("user_name", 'like', '%' . $keyword . '%'); @@ -252,32 +338,63 @@ class UserDoctor extends Model }); }); }) - ->when($sort_order, function ($query, $sort_order) { - if ($sort_order == 1) { - $query->orderBy('is_recommend', 'desc');// 是否首页推荐(0:否 1:是) - $query->orderBy('avg_response_time', 'desc');// 响应时间快 - $query->orderBy('served_patients_num', 'desc');// 服务数从多到少 - $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 - } elseif ($sort_order == 2) { - // 响应时间快 - $query->orderBy('avg_response_time', 'desc'); - $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 - } elseif ($sort_order == 3) { - // 响应时间快 - $query->orderBy('avg_response_time', 'desc'); - $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 - } elseif ($sort_order == 4) { - // 响应时间快 - $query->orderBy('avg_response_time', 'desc'); - $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 - } elseif ($sort_order == 5) { - // 服务数从多到少 - $query->orderBy('served_patients_num', 'desc'); - $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 - } - return $query; + ->whereHas('Hospital', function ($query) use ($hospital_params) { + $query->where($hospital_params); + }) + ->whereHas('DoctorExpertise', function ($query) use ($doctor_expertise_params) { + $query->where($doctor_expertise_params); + }) + ->whereHas('DoctorInquiryConfig', function ($query) use ($inquiry_type) { + $params = array(); + $params['inquiry_mode'] = 1;// 接诊方式:图文 + $query->where($params)->whereIn('inquiry_type', $inquiry_type); }); + if (!empty($sort_order)){ + if (in_array($sort_order,[1,3,4])){ + $query = $query->join('doctor_inquiry_config', function ($query) { + $query->on('user_doctor.doctor_id', '=', 'doctor_inquiry_config.doctor_id') + ->whereIn('inquiry_type', [1, 3]) + ->where('inquiry_mode', 1) + ->orderBy('inquiry_price', 'desc') + ->take(1); + }) + ->select("user_doctor.*") + ->groupBy("user_doctor.doctor_id"); + } + + if ($sort_order == 1) { + // 综合-价格从低到高 + $query->orderBy('is_recommend', 'desc');// 是否首页推荐(0:否 1:是) + $query->orderByRaw('avg_response_time = 0 ASC'); + $query->orderBy('avg_response_time'); + $query->orderBy('served_patients_num', 'desc');// 服务数从多到少 + $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 + $query->orderBy('doctor_inquiry_config.inquiry_price', 'asc'); + } elseif ($sort_order == 2) { + // 响应时间快 + $query->orderByRaw('avg_response_time = 0 ASC'); + $query->orderBy('avg_response_time'); + $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 + } elseif ($sort_order == 3) { + // 价格从低到高 + $query->orderBy('doctor_inquiry_config.inquiry_price', 'asc'); + $query->orderByRaw('avg_response_time = 0 ASC'); + $query->orderBy('avg_response_time'); + $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 + } elseif ($sort_order == 4) { + // 价格从高到低 + $query->orderBy('doctor_inquiry_config.inquiry_price', 'desc'); + $query->orderByRaw('avg_response_time = 0 ASC'); + $query->orderBy('avg_response_time'); + $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 + } elseif ($sort_order == 5) { + // 服务数从多到少 + $query->orderBy('served_patients_num', 'desc'); + $query->orderBy(Db::raw("convert(substr(user_name,1,1) using `GBK`)"), 'asc');// 名称排名 + } + } + $result = $query->paginate($per_page, $fields, "page", $page); $data = array(); @@ -290,6 +407,7 @@ class UserDoctor extends Model return $data; } + /** * 获取是否存在 * @param array $params @@ -363,4 +481,41 @@ class UserDoctor extends Model { return self::where($params)->decrement($field,$numeral); } + + /** + * 获取先思达合作医生列表 + * @param array $params + * @param array $hospital_params + * @param array $fields + * @return array|Collection + */ + public static function getDiagnoCoopDoctorList(array $params,array $hospital_params,array $fields = ['*']): array|Collection + { + return self::with([ + "Hospital:hospital_id,hospital_name,hospital_level_name" + ]) + ->whereHas('Hospital', function ($query) use ($hospital_params) { + $query->where($hospital_params); + }) + ->where($params) + ->get($fields); + } + + /** + * 获取医生数据-医生配置 + * @param array $params + * @param array $not_in_params + * @param array $doctor_inquiry_config_params + * @param array $fields + * @return Collection|array|\Hyperf\Utils\Collection + */ + public static function getListWithConfig(array $params = [], array $not_in_params = [],array $doctor_inquiry_config_params = [],array $fields = ['*']): Collection|array|\Hyperf\Utils\Collection + { + $doctor_ids = Db::table('doctor_inquiry_config')->where($doctor_inquiry_config_params)->select("doctor_id"); + + return self::where($params) + ->whereNotIn('doctor_id',$not_in_params) + ->whereIn("doctor_id",$doctor_ids) + ->get($fields); + } } diff --git a/app/Model/UserLocation.php b/app/Model/UserLocation.php new file mode 100644 index 0000000..2448f5f --- /dev/null +++ b/app/Model/UserLocation.php @@ -0,0 +1,82 @@ +first($fields); + } + + /** + * 获取数据-多 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 新增-批量 + * @param array $data 新增数据 + * @return \Hyperf\Database\Model\Model|UserLocation + */ + public static function addUserLocation(array $data): \Hyperf\Database\Model\Model|UserLocation + { + return self::create($data); + } + + /** + * 修改-批量 + * @param array $params + * @param array $data + * @return int + */ + public static function editUserLocation(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } +} diff --git a/app/Model/UserSystem.php b/app/Model/UserSystem.php new file mode 100644 index 0000000..7c578d1 --- /dev/null +++ b/app/Model/UserSystem.php @@ -0,0 +1,98 @@ +first($fields); + } + + /** + * 获取数据-多 + * @param array $params + * @param array $fields + * @return Collection|array + */ + public static function getList(array $params = [], array $fields = ['*']): Collection|array + { + return self::where($params)->get($fields); + } + + /** + * 获取是否存在 + * @param array $params + * @return bool + */ + public static function getExists(array $params): bool + { + return self::where($params)->exists(); + } + + /** + * 获取数量 + * @param array $params + * @return int + */ + public static function getCount(array $params): int + { + return self::where($params)->count(); + } + + /** + * 新增 + * @param array $data + * @return \Hyperf\Database\Model\Model|UserSystem + */ + public static function addUserSystem(array $data): \Hyperf\Database\Model\Model|UserSystem + { + return self::create($data); + } + + /** + * 修改 + * @param array $params + * @param array $data + * @return int + */ + public static function edit(array $params = [], array $data = []): int + { + return self::where($params)->update($data); + } + +} diff --git a/app/Request/BasicDataRequest.php b/app/Request/BasicDataRequest.php index af81eae..9fc11d8 100644 --- a/app/Request/BasicDataRequest.php +++ b/app/Request/BasicDataRequest.php @@ -28,6 +28,12 @@ class BasicDataRequest extends FormRequest 'client_type', 'keyword_place', ], + 'getDetectionDiseaseList' => [ // 获取检测疾病分类列表 + 'detection_project_id', + ], + 'getProductPage' => [ // 获取商品数据-分页 + 'keyword', + ], ]; /** @@ -49,6 +55,7 @@ class BasicDataRequest extends FormRequest 'disease_class_name' => 'required', 'client_type' => 'required|integer|min:1|max:1', 'keyword_place' => 'required|integer|min:1|max:1', + 'detection_project_id' => 'required', ]; } @@ -69,6 +76,7 @@ class BasicDataRequest extends FormRequest 'keyword_place.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), 'keyword_place.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), 'keyword_place.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'detection_project_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), ]; } } diff --git a/app/Request/DetectionRequest.php b/app/Request/DetectionRequest.php new file mode 100644 index 0000000..e244678 --- /dev/null +++ b/app/Request/DetectionRequest.php @@ -0,0 +1,88 @@ + [ // 创建检测订单 + 'company_id', + 'patient_id', + 'family_id', + 'nation_id', + 'detection_disease_class_ids', + 'detection_project_id', // 检测项目id + 'purpose_id', // 检测项目用途id + 'doctor_id', // 医生id + 'client_type', // 客户端类型(1:手机 2:电脑) + ], + 'getDetectionOrderFirst' => [ // 获取患者进行中的检测订单 + 'family_id', + 'detection_project_id', + ], + 'bindDetectionTube' => [ // 绑定检测管 + 'detection_bar_code', + 'detection_pic', + ], + 'getDetectionDoctorList' => [ // 绑定检测管 + 'province_id', + 'city_id', + 'county_id', + 'company_id' + ], + ]; + + /** + * Determine if the user is authorized to make this request. + */ + public function authorize(): bool + { + return true; + } + + /** + * Get the validation rules that apply to the request. + */ + public function rules(): array + { + return [ + 'patient_id' => 'required', + 'family_id' => 'required', + 'nation_id' => 'required', + 'detection_disease_class_ids' => 'required', + 'detection_project_id' => 'required', + 'doctor_id' => 'required', + 'client_type' => 'required|integer|min:1|max:2', + 'detection_bar_code' => 'required', + 'province_id' => 'required_with:city_id,county_id', + 'city_id' => 'required_with:county_id', + ]; + } + + /** + * 获取已定义验证规则的错误消息. + */ + public function messages(): array + { + return [ + 'patient_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'family_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'nation_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'detection_disease_class_ids.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'detection_project_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'doctor_id.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'client_type.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'client_type.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'client_type.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'client_type.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'detection_bar_code.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'province_id.required_with' => "请选择省份", + 'city_id.required_with' => "请选择城市", + ]; + } +} diff --git a/app/Request/InquiryRequest.php b/app/Request/InquiryRequest.php index 802999c..78d8cda 100644 --- a/app/Request/InquiryRequest.php +++ b/app/Request/InquiryRequest.php @@ -42,6 +42,10 @@ class InquiryRequest extends FormRequest 'getPatientInquiryCase' => [ // 获取患者问诊病例 'order_inquiry_id', ], + 'getPatientLastInquiryId' => [ // 获取患者最后一条问诊订单id + 'patient_id', + 'doctor_id', + ], ]; /** diff --git a/app/Request/PatientOrderRequest.php b/app/Request/PatientOrderRequest.php index 18a5879..e162d12 100644 --- a/app/Request/PatientOrderRequest.php +++ b/app/Request/PatientOrderRequest.php @@ -19,7 +19,7 @@ class PatientOrderRequest extends FormRequest 'family_id',// 家庭成员id(就诊用户) ], 'getPatientOrderPayInfo' => [ // 获取患者订单支付数据 - "order_type", // 订单类型(1:问诊订单 2:药品订单) + "order_type", // 订单类型(1:问诊订单 2:药品订单 3:检测订单) "order_no"// 订单编号 ], 'addPatientOrderPay' => [ // 模拟支付成功-金额为0时使用 @@ -33,6 +33,10 @@ class PatientOrderRequest extends FormRequest ], 'getPatientPrescriptionOrderList' => [ // 获取处方订单列表 ], + 'getPatientDetectionOrderList' => [ // 获取患者检测订单列表 + 'detection_status',// 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + 'family_id',// 家庭成员id(就诊用户) + ], ]; /** @@ -69,12 +73,13 @@ class PatientOrderRequest extends FormRequest 'inquiry_status' => 'required|integer|min:0|max:4', - 'order_type' => 'required|integer|min:1|max:2', + 'order_type' => 'required|integer|min:1|max:3', 'order_no' => 'required', 'order_prescription_id' => 'required', 'address_id' => 'required', 'product_ids' => 'required|array|min:1', + 'detection_status' => 'required|integer|min:0|max:5', ]; } @@ -127,6 +132,10 @@ class PatientOrderRequest extends FormRequest 'product_ids.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), 'product_ids.array' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), 'product_ids.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'detection_status.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'detection_status.integer' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'detection_status.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'detection_status.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), ]; } } diff --git a/app/Request/SafeRequest.php b/app/Request/SafeRequest.php index 72e2e2e..5d68fb4 100644 --- a/app/Request/SafeRequest.php +++ b/app/Request/SafeRequest.php @@ -31,7 +31,7 @@ class SafeRequest extends FormRequest { return [ 'user_type' => 'required|integer|min:1|max:3', - 'scene' => 'required|integer|min:1|max:2', + 'scene' => 'required|integer|min:1|max:4', ]; } diff --git a/app/Request/UserDoctorRequest.php b/app/Request/UserDoctorRequest.php index 236818c..0e823ad 100644 --- a/app/Request/UserDoctorRequest.php +++ b/app/Request/UserDoctorRequest.php @@ -101,7 +101,7 @@ class UserDoctorRequest extends FormRequest 'province_id' => 'required|required_with:city_id,county_id', 'city_id' => 'required|required_with:county_id', 'county_id' => 'required', - 'pharmacist_audit_status' => 'required|integer|min:0|max:3', + 'pharmacist_audit_status' => 'required|integer|min:0|max:2', 'words_type' => 'required|integer|min:1|max:3', 'words' => 'required', 'doctor_id' => 'required', diff --git a/app/Request/UserRequest.php b/app/Request/UserRequest.php index 7c1686f..ad685c9 100644 --- a/app/Request/UserRequest.php +++ b/app/Request/UserRequest.php @@ -41,6 +41,9 @@ class UserRequest extends FormRequest 'is_default', 'tag', ], + 'putUserSystem' => [ // 修改用户配置 + 'is_accept_im_message_push', + ], ]; /** @@ -59,7 +62,6 @@ class UserRequest extends FormRequest return [ 'avatar' => 'required|url', 'user_name' => 'required', - 'province_id' => 'required_with:city_id,county_id', 'city_id' => 'required_with:county_id', 'county_id' => 'required', @@ -68,6 +70,7 @@ class UserRequest extends FormRequest 'consignee_tel' => 'required', 'is_default' => ['required','numeric','min:0','max:1'], 'tag' => ['sometimes','required','numeric','min:1','max:4'], + 'is_accept_im_message_push' => ['required','numeric','min:0','max:1'], ]; } @@ -95,6 +98,10 @@ class UserRequest extends FormRequest 'tag.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), 'tag.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), 'tag.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'is_accept_im_message_push.required' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'is_accept_im_message_push.numeric' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'is_accept_im_message_push.min' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), + 'is_accept_im_message_push.max' => HttpEnumCode::getMessage(HttpEnumCode::CLIENT_HTTP_ERROR), ]; } } diff --git a/app/Services/BasicDataService.php b/app/Services/BasicDataService.php index 21b12b9..06c4ce0 100644 --- a/app/Services/BasicDataService.php +++ b/app/Services/BasicDataService.php @@ -8,6 +8,7 @@ use App\Model\BasicDoctorTitle; use App\Model\BasicJob; use App\Model\BasicNation; use App\Model\DiseaseClass; +use App\Model\DiseaseClassDetection; use App\Model\DiseaseClassExpertise; use App\Model\DiseaseClassIcd; use App\Model\Hospital; @@ -394,4 +395,75 @@ class BasicDataService extends BaseService return success($hot_search_keyword->toArray()); } + + /** + * 获取检测疾病分类列表 + * @return array + */ + public function getDetectionDiseaseList(): array + { + $detection_project_id = $this->request->route('detection_project_id',1); + + $params = array(); + $params['detection_project_id'] = $detection_project_id; + $params['status'] = 1; + $params['enable'] = 1; + $disease_class_detections = DiseaseClassDetection::getList($params); + if (empty($disease_class_detections)){ + return success(); + } + + return success($disease_class_detections->toArray()); + } + + /** + * 获取商品数据-分页 + * @return array + */ + public function getProductPage(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $keyword = $this->request->input('keyword',""); + + $page = $this->request->input('page', 1); + $per_page = $this->request->input('per_page', 10); + + $fields = [ + 'product_id', + 'product_platform_id', + 'product_name', + 'product_price', + 'product_cover_img', + 'product_spec', + 'manufacturer', + 'single_unit', + 'single_use', + 'packaging_unit', + 'frequency_use', + 'available_days', + ]; + + $params = array(); + + + $product = Product::getWithAmountPage($params, $keyword,$fields, $page, $per_page); + if (empty($product['data'])) { + return success($product); + } + + foreach ($product['data'] as &$item) { + $item['product_cover_img'] = addAliyunOssWebsite($item['product_cover_img']); + + $item['product_name'] = $item['product_name'] . ' ' . $item['product_spec']; + $item['stock'] = 0; + if (!empty($item['ProductPlatformAmount'])){ + $item['stock'] = $item['ProductPlatformAmount']['stock']; + } + + unset($item['ProductPlatformAmount']); + } + + return success($product); + } } \ No newline at end of file diff --git a/app/Services/CaService.php b/app/Services/CaService.php index 6d55e1a..371493d 100644 --- a/app/Services/CaService.php +++ b/app/Services/CaService.php @@ -38,81 +38,77 @@ class CaService extends BaseService // 是否已添加签章配置(第一次需申请) protected string $is_sign_config; - // 用户签名图片地址 + // 签名图片地址 public string $sign_image_path; - // 医院签名图片地址 - protected string $hospital_sign_image_path; - - // 用户唯一标识 - protected string $user_entity_id; - - // 医院唯一标识 - protected string $hospital_entity_id; + // 唯一标识 + protected string $entity_id; // 证书序列号 protected string $cert_serial_number; - // 身份证号 + // 身份证号/信用代码 protected string $card_num; - // 信用代码 - protected string $org_num; - // 处方pdf本地地址 protected string $prescription_pdf_local_path; // 处方pdf oss地址 protected string $prescription_pdf_oss_path; - /** * 初始化类,此处会获取基础数据 * @param array|object $order_prescription 处方表数据 - * @param array|object $user 用户表数据 + * @param string|int $user_id 用户id + * @param int $type 类型 1:医院 2:医生 3:药师 */ - public function __construct(array|object $order_prescription,array|object $user){ + public function __construct(array|object $order_prescription,int $type,string|int $user_id = ""){ // 获取用户、医院签名图片地址、用户标识信息 - $params = array(); - $params['user_id'] = $user['user_id']; - if ($user['user_type'] == 2) { + if ($type == 1){ + // 医院 + $this->sign_image_path = "basic/file/hospital_signature.png"; + $this->entity_id = "5345345461"; + $this->card_num = "91510106MABTJY4K9R"; + }elseif($type == 2){ + // 用户 + $params = array(); + $params['user_id'] = $user_id; $user_doctor_info = UserDoctorInfo::getOne($params); if (empty($user_doctor_info)) { throw new BusinessException("用户数据错误"); } - $user_sign_image_path = $user_doctor_info['sign_image']; + $this->sign_image_path = substr($user_doctor_info['sign_image'], 1, strlen($user_doctor_info['sign_image']) - 1); $app_env = config('app_env','dev'); if ($app_env == 'prod'){ - $this->user_entity_id = $user_doctor_info['user_id']; + $this->entity_id = $user_doctor_info['user_id']; }else{ - $this->user_entity_id = "491925054435950592"; + $this->entity_id = "491925054435950592"; } $this->card_num = $user_doctor_info['card_num']; - } else { + } elseif ($type == 3){ + $params = array(); + $params['user_id'] = $user_id; $user_pharmacist_info = UserPharmacistInfo::getOne($params); if (empty($user_pharmacist_info)) { throw new BusinessException("用户数据错误"); } - $user_sign_image_path = $user_pharmacist_info['sign_image']; - $this->user_entity_id = $user['user_id']; - $this->card_num = $user_pharmacist_info['card_num']; + // 去除用户签名图片第一个/ oss不识别 + $this->sign_image_path = substr($user_pharmacist_info['sign_image'], 1, strlen($user_pharmacist_info['sign_image']) - 1); - $this->hospital_sign_image_path = "basic/file/hospital_signature.png"; - $this->hospital_entity_id = "5345345461"; - $this->org_num = "91510106MABTJY4K9R"; + $this->entity_id = $user_id; + $this->card_num = $user_pharmacist_info['card_num']; + } else{ + throw new BusinessException("用户类型错误"); } - if (empty($user_sign_image_path) || empty($this->user_entity_id)) { + if (empty($this->sign_image_path) || empty($this->entity_id)) { throw new BusinessException("无签名图片/用户唯一标识"); } - // 去除用户签名图片第一个/ oss不识别 - $this->sign_image_path = substr($user_sign_image_path, 1, strlen($user_sign_image_path) - 1); - $order_prescription_id = $order_prescription['order_prescription_id']; // 创建协程客户端 @@ -225,9 +221,8 @@ class CaService extends BaseService /** * 获取云证书签名+验证云证书签名 * @param array|object $order_prescription - * @param int $type 类型 1:用户 2:医院 */ - public function getVerifyCertSign(array|object $order_prescription,int $type) + public function getVerifyCertSign(array|object $order_prescription) { $CaOnline = new CaOnline(); @@ -254,13 +249,7 @@ class CaService extends BaseService $data['product'][] = $product; } - if ($type == 1){ - // 用户 - $cert_sign_result = $CaOnline->getCertSign($this->user_entity_id, $this->user_entity_id, $data); - }else{ - // 医院 - $cert_sign_result = $CaOnline->getCertSign($this->hospital_entity_id, $this->hospital_entity_id, $data); - } + $cert_sign_result = $CaOnline->getCertSign($this->entity_id, $this->entity_id, $data); // 验证云证书签名 验证无需处理,只要不返回错误即可 $CaOnline->verifyPkcs7($cert_sign_result['signP7'], $data); @@ -411,38 +400,23 @@ class CaService extends BaseService /** * 下载Oss中处方pdf - * 存在:当次发版内医生开具后,药师再去开具 - * 不存在:医生开具后,进行发版过,此时需重新下载 * @return void */ public function downOssPdfToLocal(): void { - $res = file_exists($this->prescription_pdf_local_path); - if (!$res){ - // 去除第一个/ oss不识别 -// $prescription_pdf_path = substr($doctor_pdf_oss_path, 1, strlen($doctor_pdf_oss_path) - 1); - - $oss = new Oss(); - $oss->getObjectToLocal($this->prescription_pdf_oss_path, $this->prescription_pdf_local_path); - } + $oss = new Oss(); + $oss->getObjectToLocal($this->prescription_pdf_oss_path, $this->prescription_pdf_local_path); } /** * 下载CA中pdf至本地文件 * @param string $file_id - * @param int $type 类型 1:用户 2:医院 * @return void */ - public function downCaPdfToLocal(string $file_id,int $type): void + public function downCaPdfToLocal(string $file_id): void { $CaOnline = new CaOnline(); - if ($type == 1){ - // 用户 - $prescription_pdf_result = $CaOnline->getSignedFile($this->user_entity_id, $file_id); - }else{ - // 医院 - $prescription_pdf_result = $CaOnline->getSignedFile($this->hospital_entity_id, $file_id); - } + $prescription_pdf_result = $CaOnline->getSignedFile($this->entity_id, $file_id); $file = fopen($this->prescription_pdf_local_path, "w"); fwrite($file, $prescription_pdf_result); @@ -452,20 +426,13 @@ class CaService extends BaseService /** * 下载CA中的pdf并上传至oss * @param string $file_id - * @param int $type 类型 1:用户 2:医院 * @return string oss地址 */ - public function downCaPdfToOss(string $file_id,int $type): string + public function downCaPdfToOss(string $file_id): string { $CaOnline = new CaOnline(); - if ($type == 1){ - // 用户 - $prescription_pdf_result = $CaOnline->getSignedFile($this->user_entity_id, $file_id); - }else{ - // 医院 - $prescription_pdf_result = $CaOnline->getSignedFile($this->hospital_entity_id, $file_id); - } + $prescription_pdf_result = $CaOnline->getSignedFile($this->entity_id, $file_id); // 上传oss $oss = new Oss(); @@ -479,27 +446,15 @@ class CaService extends BaseService */ public function addSignPdf(string $type): string { - // 下载签名图片 + $oss = new Oss(); + if ($type == 1){ - $local_path = "./extend/Ca/hospital_signature.png"; - $res = file_exists($local_path); - if ($res){ - // 读取本地文件 - $sign_image = fopen($local_path,'r'); - } + $style = "image/resize,w_300,h_300"; + }else{ + $style = "image/resize,m_lfit,w_100,h_350"; } - if (!isset($sign_image)){ - $oss = new Oss(); - - if ($type == 1){ - $style = "image/resize,w_300,h_300"; - $sign_image = $oss->getCusTomObjectToRAM($this->hospital_sign_image_path, $style); - }else{ - $style = "image/resize,m_lfit,w_100,h_350"; - $sign_image = $oss->getCusTomObjectToRAM($this->sign_image_path, $style); - } - } + $sign_image = $oss->getCusTomObjectToRAM($this->sign_image_path, $style); $sign_image = base64_encode($sign_image); if (!$sign_image) { @@ -512,24 +467,18 @@ class CaService extends BaseService $lly = "210"; // 左边底部Y坐标 控制上下(越小越下) $urx = "520"; // 右边上部x坐标 $ury = "360"; // 右边上部y坐标 - - $entity_id = $this->hospital_entity_id; } elseif ($type == 2){ // 医生端 $llx = "120"; // 左边底部X坐标 $lly = "190"; // 左边底部Y坐标 $urx = "190"; // 右边上部x坐标 $ury = "140"; // 右边上部y坐标 - - $entity_id = $this->user_entity_id; }else{ // 药师端 $llx = "350"; // 左边底部X坐标 $lly = "190"; // 左边底部Y坐标 $urx = "440"; // 右边上部x坐标 $ury = "140"; // 右边上部y坐标 - - $entity_id = $this->user_entity_id; } $sign_param = [ @@ -559,11 +508,7 @@ class CaService extends BaseService $data['sign_param'] = json_encode($sign_param); $data['seal_img'] = $sign_image; - if ($type == 1){ - $CaOnline->addUserSignConfig($entity_id,$this->org_num,$data); - }else{ - $CaOnline->addUserSignConfig($entity_id,$this->card_num,$data); - } + $CaOnline->addUserSignConfig($this->entity_id,$this->card_num,$data); $params = array(); $params['cert_id'] = $user_ca_cert['cert_id']; @@ -580,17 +525,16 @@ class CaService extends BaseService throw new BusinessException("处方pdf打开失败"); } + // 处方pdf进行签章 $data = array(); $data['sign_param'] = json_encode($sign_param); $data['pdf_file'] = $pdf_file; - $sign_pdf_result = $CaOnline->addSignPdf($entity_id, $data); + $sign_pdf_result = $CaOnline->addSignPdf($this->entity_id, $data); if (empty($sign_pdf_result[0]['fileId'])) { throw new BusinessException("处方签章失败"); } return $sign_pdf_result[0]['fileId']; } - - } \ No newline at end of file diff --git a/app/Services/DetectionService.php b/app/Services/DetectionService.php new file mode 100644 index 0000000..60bae2c --- /dev/null +++ b/app/Services/DetectionService.php @@ -0,0 +1,981 @@ +request->input("company_id",1); + + // 获取合作公司数据 + $params = array(); + $params['company_id'] = $company_id; + $basic_company = BasicCompany::getOne($params); + if (empty($basic_company)){ + return fail(); + } + + // 获取项目数据 + $params = array(); + $params['company_id'] = $company_id; + $detection_projects = DetectionProject::getList($params); + if (empty($detection_projects)){ + return fail(); + } + + foreach ($detection_projects as &$value){ + $value['img_path'] = addAliyunOssWebsite($value['img_path']); + } + + return success($detection_projects->toArray()); + } + + /** + * 获取合作公司检测项目详情 + * @return array + */ + public function getDetectionProject(): array + { + $company_id = $this->request->input("company_id",1); + $detection_project_id = $this->request->route('detection_project_id',1); + + // 获取合作公司数据 + $params = array(); + $params['company_id'] = $company_id; + $basic_company = BasicCompany::getOne($params); + if (empty($basic_company)){ + return fail(); + } + + // 获取项目数据 + $params = array(); + $params['detection_project_id'] = $detection_project_id; + $detection_project = DetectionProject::getOne($params); + if (empty($detection_project)){ + return fail(); + } + + $detection_project['img_path'] = addAliyunOssWebsite($detection_project['img_path']); + + return success($detection_project->toArray()); + } + + /** + * 获取检测机构合作医生列表 + * @return array + */ + public function getDetectionDoctorList(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + $company_id = $this->request->input("company_id",1); + $province_id = $this->request->input("province_id"); + $city_id = $this->request->input("city_id"); + $county_id = $this->request->input("county_id"); + + // 获取合作公司数据 + $params = array(); + $params['company_id'] = $company_id; + $basic_company = BasicCompany::getOne($params); + if (empty($basic_company)){ + return fail(); + } + + // 搜索数据 + $hospital_params = array(); + + if (!empty($province_id)){ + $params = array(); + $params['area_id'] = $province_id; + $params['area_type'] = 2; + $area_province = Area::getOne($params); + if (!empty($area_province)){ + // 搜索条件 + $hospital_params['province_id'] = $area_province['area_id']; + } + } + + if (!empty($city_id)){ + $params = array(); + $params['area_id'] = $city_id; + $params['parent_id'] = $province_id; + $params['area_type'] = 3; + $area_city = Area::getOne($params); + if (!empty($area_city)){ + // 搜索条件 + $hospital_params['city_id'] = $area_city['area_id']; + } + } + + if (!empty($county_id)){ + $params = array(); + $params['area_id'] = $county_id; + $params['parent_id'] = $city_id; + $params['area_type'] = 4; + $area_county = Area::getOne($params); + if (!empty($area_county)){ + // 搜索条件 + $hospital_params['county_id'] = $area_county['area_id']; + } + } + + // 获取医生 + $params = array(); + $params['status'] = 1; + $params['idcard_status'] = 1; + $params['iden_auth_status'] = 1; + $params['is_sys_diagno_cooperation'] = 1; + + $fields = [ + "doctor_id", + "user_id", + "user_name", + "avatar", + "doctor_title", + "hospital_id", + ]; + $user_doctors = UserDoctor::getDiagnoCoopDoctorList($params,$hospital_params,$fields); + if (!empty($user_doctors)){ + foreach ($user_doctors as &$value){ + if (!empty($value['Hospital'])){ + $value['hospital_name'] = $value['Hospital']['hospital_name']; + } + + unset($value['Hospital']); + + $value['avatar'] = addAliyunOssWebsite($value['avatar']); + } + } + + return success($user_doctors->toArray()); + } + + /** + * 获取检测项目用途列表 + * @return array + */ + public function getDetectionProjectPurposeList(): array + { + $detection_project_id = $this->request->input("detection_project_id",1); + + // 获取项目数据 + $params = array(); + $params['detection_project_id'] = $detection_project_id; + $detection_project_purpose = DetectionProjectPurpose::getList($params); + if (empty($detection_project_purpose)){ + return fail(); + } + + return success($detection_project_purpose->toArray()); + } + + /** + * 创建检测订单 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function addDetectionOrder(): array + { + $result = array(); + $result['status'] = 1; + $result['message'] = "成功"; + $result['data'] = [ + "inquiry_no" => "", + "order_detection_id" => "", + ]; + + $user_info = $this->request->getAttribute("userInfo") ?? []; + $request_params = $this->request->all(); + + // 检测家庭成员是否存在 + $params = array(); + $params['family_id'] = $request_params['family_id']; + $params['patient_id'] = $user_info['client_user_id']; + $params['status'] = 1; + $patient_family = PatientFamily::getOne($params); + if (empty($patient_family)) { + return fail(HttpEnumCode::HTTP_ERROR, "患者信息错误"); + } + + // 检测是否存在同类型未完成的检测订单 + $params = array(); + $params['patient_id'] = $user_info['client_user_id']; + $params['family_id'] = $request_params['family_id']; + $params['detection_project_id'] = $request_params['detection_project_id']; + $order_detection = OrderDetection::getNotFinishedOrderDetectionOne($params); + if (!empty($order_detection)){ + $result['status'] = 2; + $result['message'] = "当前患者存在未完成的检测订单"; + $result['data']['order_no'] = $order_detection['detection_no']; + return success($result); + } + + // 检测民族 + $params = array(); + $params['nation_id'] = $request_params['nation_id']; + $nation = BasicNation::getOne($params); + if (empty($nation)){ + return fail(HttpEnumCode::HTTP_ERROR,"民族选择错误"); + } + + // 检测疾病分类 + $detection_disease_class_ids = explode(',',$request_params['detection_disease_class_ids']); + if (count($detection_disease_class_ids) > 3){ + return fail(HttpEnumCode::HTTP_ERROR,"既往病史最多可选三项"); + } + + $detection_disease_class_names = ""; + + foreach ($detection_disease_class_ids as $value){ + $params = array(); + $params['id'] = $value; + $disease_class_detection = DiseaseClassDetection::getOne($params); + if (empty($disease_class_detection)){ + return fail(HttpEnumCode::HTTP_ERROR,"既往病史错误"); + } + + if ($disease_class_detection['status'] != 1){ + return fail(HttpEnumCode::HTTP_ERROR,"既往病史错误"); + } + + if ($disease_class_detection['enable'] != 1){ + return fail(HttpEnumCode::HTTP_ERROR,"既往病史错误"); + } + + if (empty($detection_disease_class_names)){ + $detection_disease_class_names = $disease_class_detection['name']; + }else{ + $detection_disease_class_names = $detection_disease_class_names . ',' . $disease_class_detection['name']; + } + } + + // 检测项目 + $params = array(); + $params['detection_project_id'] = $request_params['detection_project_id']; + $detection_project = DetectionProject::getOne($params); + if (empty($detection_project)){ + return fail(HttpEnumCode::HTTP_ERROR,"检测项目错误"); + } + + if ($detection_project['detection_project_price'] <= 0){ + return fail(HttpEnumCode::HTTP_ERROR,"订单金额错误"); + } + + // 检测用途 + $params = array(); + $params['purpose_id'] = $request_params['purpose_id']; + $params['detection_project_id'] = $request_params['detection_project_id']; + $detection_project_purpose = DetectionProjectPurpose::getOne($params); + if (empty($detection_project_purpose)){ + return fail(); + } + + // 检测医生 + $params = array(); + $params['doctor_id'] = $request_params['doctor_id']; + $user_doctor = UserDoctor::getOne($params); + if (empty($user_doctor)){ + return fail(HttpEnumCode::HTTP_ERROR,"医生错误"); + } + + if ($user_doctor['is_sys_diagno_cooperation'] != 1){ + return fail(HttpEnumCode::HTTP_ERROR,"医生错误"); + } + + // 确定支付渠道 + // 支付渠道(1:小程序支付 2:微信扫码支付) + if ($request_params['client_type'] == 1) { + $detection_pay_channel = 1; + } elseif ($request_params['client_type'] == 2) { + $detection_pay_channel = 2; + } + + Db::beginTransaction(); + + $generator = $this->container->get(IdGeneratorInterface::class); + + try { + // 新增检测订单 + $data = array(); + $data['user_id'] = $user_info['user_id']; + $data['patient_id'] = $user_info['client_user_id']; + $data['doctor_id'] = $user_doctor['doctor_id']; + $data['family_id'] = $patient_family['family_id']; + $data['detection_project_id'] = $detection_project['detection_project_id']; + $data['purpose_id'] = $detection_project_purpose['purpose_id']; + $data['detection_status'] = 1; // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + $data['detection_pay_channel'] = $detection_pay_channel; // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付) + $data['detection_no'] = "D" . $generator->generate(); // 系统订单编号 + $data['amount_total'] = $detection_project['detection_project_price']; // 订单金额 + $data['coupon_amount_total'] = 0;// 优惠卷总金额 + $data['payment_amount_total'] = $detection_project['detection_project_price']; // 实际付款金额 + $data['patient_name'] = $patient_family['card_name'];// 患者姓名-就诊人 + $data['patient_name_mask'] = $patient_family['card_name_mask'];// 患者姓名-就诊人(掩码) + $data['patient_sex'] = $patient_family['sex'];// 患者性别-就诊人(0:未知 1:男 2:女) + $data['patient_age'] = $patient_family['age'];// 患者年龄-就诊人 + $order_detection = OrderDetection::addOrderDetection($data); + if (empty($order_detection)){ + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败"); + } + + // 新增检测订单病例 + $data = array(); + $data['order_detection_id'] = $order_detection['order_detection_id']; + $data['family_id'] = $patient_family['family_id']; + $data['doctor_id'] = $user_doctor['doctor_id']; + $data['relation'] = $patient_family['relation']; // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 ) + $data['name'] = $patient_family['card_name']; // 患者名称 + $data['sex'] = $patient_family['sex'] ?? 0; // 患者性别(0:未知 1:男 2:女) + $data['age'] = $patient_family['age'] ?? null; // 患者年龄 + $data['nation_id'] = $nation['nation_id'] ?? null; // 民族 + $data['nation_name'] = $nation['nation_name'] ?? null; // 民族名称 + $data['detection_disease_class_ids'] = $request_params['detection_disease_class_ids']; // 疾病id-检测-逗号分隔 + $data['detection_disease_class_names'] = $detection_disease_class_names; // 疾病名称-检测-逗号分隔 + $order_detection_case = OrderDetectionCase::addOrderDetectionCase($data); + if (empty($order_detection_case)){ + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败"); + } + + // 增加至未支付取消订单延迟队列 + $data = array(); + $data['order_no'] = $order_detection['detection_no']; + $data['order_type'] = 3; + + $message = new CancelUnpayOrdersDelayDirectProducer($data); + $message->setDelayMs(1000 * 60 * 30); + $producer = $this->container->get(Producer::class); + $res = $producer->produce($message); + if (!$res) { + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败"); + } + + Db::commit(); + }catch (\Exception $e){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage()); + } + + $result['status'] = 1; + $result['data']['order_detection_id'] = (string)$order_detection['order_detection_id']; // 订单主键id + $result['data']['inquiry_no'] = (string)$order_detection['detection_no']; // 订单编号 + return success($result); + } + + /** + * 获取患者进行中的检测订单 + * @return array + */ + public function getDetectionOrderFirst(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $family_id = $this->request->input("family_id"); + $detection_project_id = $this->request->input("detection_project_id"); + + // 检测是否存在同类型未完成的检测订单 + $params = array(); + $params['patient_id'] = $user_info['client_user_id']; + $params['family_id'] = $family_id; + $params['detection_project_id'] = $detection_project_id; + $order_detection = OrderDetection::getNotFinishedOrderDetectionOne($params); + if (!empty($order_detection)){ + return success($order_detection['detection_no']); + } + + return success(""); + } + + /** + * 绑定检测管 + * @return array + */ + public function bindDetectionTube(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $order_detection_id = $this->request->route("order_detection_id"); + + $request_params = $this->request->all(); + + $params = array(); + $params['patient_id'] = $user_info['client_user_id']; + $params['order_detection_id'] = $order_detection_id; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)){ + return fail(); + } + + // 检测订单状态 + if ($order_detection['detection_status'] != 2){ + return fail(HttpEnumCode::HTTP_ERROR,"订单状态错误"); + } + + if ($order_detection['detection_pay_status'] != 2){ + return fail(HttpEnumCode::HTTP_ERROR,"订单未支付"); + } + + if (!empty($order_detection['detection_bar_code'])){ + return fail(HttpEnumCode::HTTP_ERROR,"请勿重复绑定"); + } + + if (!empty($order_detection['detection_pic']) && !empty($request_params['detection_pic'])){ + return fail(HttpEnumCode::HTTP_ERROR,"请勿重复绑定"); + } + + // 处理检测管图片 + if (!empty($request_params['detection_pic'])){ + $detection_pic = implode(',', $request_params['detection_pic']); + $detection_pic = PcreMatch::pregRemoveOssWebsite($detection_pic); + } + + + + // 检测检测管编码是否已被使用 + $params = array(); + $params['detection_bar_code'] = $request_params['detection_bar_code']; + $result = OrderDetection::getOne($params); + if (!empty($result)){ + return fail(HttpEnumCode::HTTP_ERROR,"检测管已被使用"); + } + + // 获取检测码对应的检测所 + $detection_organ_code = substr($request_params['detection_bar_code'], 3, 1); + if (!$detection_organ_code){ + return fail(HttpEnumCode::HTTP_ERROR,"检测码错误"); + } + + // 获取检测所数据 + $params = array(); + $params['detection_organ_code'] = $detection_organ_code; + $basic_detection_organ = BasicDetectionOrgan::getOne($params); + if (empty($basic_detection_organ)){ + return fail(HttpEnumCode::HTTP_ERROR,"检测码错误"); + } + + Db::beginTransaction(); + try { + // 修改检测订单 + $data = array(); + if (isset($detection_pic)){ + $data['detection_pic'] = $detection_pic; + } + + $data['detection_bar_code'] = $request_params['detection_bar_code']; + $data['detection_status'] = 3; + $data['detection_organ_id'] = $basic_detection_organ['detection_organ_id'];// 检测机构id + $data['detection_time'] = date('Y-m-d H:i:s', time());// 上传检测时间 + + $params = array(); + $params['order_detection_id'] = $order_detection_id; + $res = OrderDetection::editOrderDetection($params,$data); + if (!$res){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR,"绑定失败"); + } + + // 上报数据 + $wy = new Wy($basic_detection_organ['detection_organ_id']); + $wy->report($order_detection_id); + + Db::commit(); + }catch (\Throwable $e){ + Db::rollBack(); + Log::getInstance("DetectionService-bindDetectionTube")->error($e->getMessage()); + return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage()); + } + + return success(); + } + + /** + * 创建检测问诊订单 + * @return array + */ + public function addDetectionInquiryOrder(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $order_detection_id = $this->request->route("order_detection_id"); + + // 定义返回数据 + /* + * status解释 + * 1:成功 + * 2:存在待支付订单 + * 3:存在待接诊订单 + * 4:存在接诊中订单 + * */ + $result = array(); + $result['status'] = 1; + $result['message'] = "成功"; + $result['data'] = ""; + + $params = array(); + $params['patient_id'] = $user_info['client_user_id']; + $params['order_detection_id'] = $order_detection_id; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)){ + return fail(); + } + + // 检测订单状态 + if ($order_detection['detection_status'] != 4){ + return fail(HttpEnumCode::HTTP_ERROR,"订单状态错误"); + } + + // 检测是否已经创建问诊订单 + if (!empty($order_detection['order_inquiry_id'])){ + $result['status'] = 1; + $result['message'] = "成功"; + $result['data'] = (string)$order_detection['order_inquiry_id']; + + return success($result); + } + + Db::beginTransaction(); + try { + // 检测当前医生是否和患者存在未完成问诊订单 + $InquiryService = new InquiryService(); + $order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($order_detection['patient_id'],$order_detection['doctor_id']); + if (!empty($order_inquiry)){ + if ($order_inquiry['inquiry_status'] == 1){ + // 待支付 + Db::rollBack(); + + $result['status'] = 2; + $result['message'] = "当前医生有您未支付的订单,点击“继续”将为您取消订单直接进入报告解读服务。"; + $result['data'] = (string)$order_inquiry['order_inquiry_id']; + + return success($result); + } + + if ($order_inquiry['inquiry_status'] == 3){ + // 待接诊 + Db::rollBack(); + + $result['status'] = 3; + $result['message'] = "当前医生有您待接诊的订单,点击“继续”将为您取消订单直接进入报告解读服务。"; + $result['data'] = (string)$order_inquiry['order_inquiry_id']; + + return success($result); + } + + if ($order_inquiry['inquiry_status'] == 4){ + // 已接诊 + Db::rollBack(); + + $result['status'] = 4; + $result['message'] = "当前医生有您问诊中的订单,点击“继续”将进入聊天详情。"; + $result['data'] = (string)$order_inquiry['order_inquiry_id']; + + return success($result); + } + } + + // 获取医生数据 + $params = array(); + $params['doctor_id'] = $order_detection['doctor_id']; + $user_doctor = UserDoctor::getOne($params); + if (empty($user_doctor)){ + Db::rollBack(); + return fail(); + } + + // 获取检测病例数据 + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + $order_detection_case = OrderDetectionCase::getOne($params); + if (empty($order_detection_case)){ + Db::rollBack(); + return fail(); + } + + // 获取检测项目数据 + $params = array(); + $params['detection_project_id'] = $order_detection['detection_project_id']; + $detection_project = DetectionProject::getOne($params); + if (empty($detection_project)){ + Db::rollBack(); + return fail(); + } + + // 检测家庭成员是否存在 + $params = array(); + $params['family_id'] = $order_detection['family_id']; + $params['patient_id'] = $order_detection['patient_id']; + $patient_family = PatientFamily::getOne($params); + if (empty($patient_family)) { + Db::rollBack(); + return fail(); + } + + $generator = $this->container->get(IdGeneratorInterface::class); + + // 创建问诊订单 + $data = array(); + $data['user_id'] = $order_detection['user_id']; + $data['patient_id'] = $order_detection['patient_id']; + $data['doctor_id'] = $order_detection['doctor_id']; + $data['family_id'] = $order_detection['family_id']; + $data['inquiry_type'] = 5; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测) + $data['inquiry_mode'] = 1; // 订单问诊方式(1:图文 2:视频 3:语音 4:电话 5:会员) + $data['inquiry_status'] = 4; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消) + $data['inquiry_pay_channel'] = 3; // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付) + $data['inquiry_pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) + $data['inquiry_no'] = $generator->generate();// 订单编号 + $data['escrow_trade_no'] = "GD" . $generator->generate(); // 第三方支付流水号 + $data['amount_total'] = 0;// 订单金额 + $data['coupon_amount_total'] = 0;// 优惠卷总金额 + $data['payment_amount_total'] = 0;// 实际付款金额 + $data['pay_time'] = date('Y-m-d H:i:s', time());// 支付时间 + $data['reception_time'] = date('Y-m-d H:i:s', time());// 接诊时间 + $data['patient_name'] = $patient_family['card_name'];// 患者姓名-就诊人 + $data['patient_name_mask'] = $patient_family['card_name_mask'];// 患者姓名-就诊人(掩码) + $data['patient_sex'] = $patient_family['sex'];// 患者性别-就诊人(0:未知 1:男 2:女) + $data['patient_age'] = $patient_family['age'];// 患者年龄-就诊人 + $order_inquiry = OrderInquiry::addOrderInquiry($data); + if (empty($order_inquiry)) { + Db::rollBack(); + return fail(); + } + + // 增加患者问诊病例 + $data = array(); + $data['user_id'] = $order_detection['user_id']; + $data['patient_id'] = $order_detection['patient_id']; + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];// 订单-问诊id + $data['family_id'] = $patient_family['family_id']; // 家庭成员id + $data['relation'] = $patient_family['relation']; // 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 ) + $data['name'] = $patient_family['card_name']; // 患者名称 + $data['sex'] = $patient_family['sex'] ?? 0; // 患者性别(0:未知 1:男 2:女) + $data['age'] = $patient_family['age'] ?? null; // 患者年龄 + $data['height'] = $patient_family['height'] ?: null; // 身高(cm) + $data['weight'] = $patient_family['weight'] ?: null;; // 体重(kg) + $data['nation_id'] = $order_detection_case['nation_id'] ?: $patient_family['nation_id'] ?: null;; // 民族 + $data['nation_name'] = $order_detection_case['nation_name'] ?: $patient_family['nation_name'] ?: null;; // 民族名称 + $order_inquiry_case = OrderInquiryCase::addOrderInquiryCase($data); + if (empty($order_inquiry_case)) { + Db::rollBack(); + return fail(); + } + + // 修改检测订单 + $data = array(); + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];// 订单-问诊id + + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + OrderDetection::editOrderDetection($params,$data); + + // 添加自动完成队列 + $time = 1000 * 60 * 60 * 24 * 3; + + $data = array(); + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + + $message = new AutoCompleteInquiryDelayDirectProducer($data); + $message->setDelayMs($time); + $producer = $this->container->get(Producer::class); + $res = $producer->produce($message); + if (!$res) { + Db::rollBack(); + return fail(); + } + + // 发送im消息 + $imService = new ImService(); + + // 患者病例 + $imService->patientCase( + $order_inquiry, + $user_doctor['user_id'], + $order_inquiry_case['disease_desc'] + ); + + // 发送IM消息-检测报告结果 + $data = [ + "order_inquiry_id" => $order_inquiry['order_inquiry_id'], + "inquiry_type" => $order_inquiry['inquiry_type'], + "detection_no" => $order_detection['detection_no'], + "patient_name" => $order_detection['patient_name'], + "patient_sex" => $order_detection['patient_sex'], + "patient_age" => $order_detection['patient_age'], + "detection_project_name" => $detection_project['detection_project_name'], + "disease_class_names" => $order_detection_case['detection_disease_class_names'], + "detection_result_pdf" => $order_detection['detection_result_pdf'], + "patient_user_id" => $order_detection['user_id'], + "doctor_user_id" => $user_doctor['user_id'], + ]; + $imService->detectionTestReport($data); + + // 发送IM消息-检测报告结果-文字 + $data = [ + "order_inquiry_id" => $order_inquiry['order_inquiry_id'], + "inquiry_type" => $order_inquiry['inquiry_type'], + "detection_no" => $order_detection['detection_no'], + "doctor_name" => $user_doctor['user_name'], + "patient_name" => $order_detection['patient_name'], + "patient_sex" => $order_detection['patient_sex'], + "patient_age" => $order_detection['patient_age'], + "detection_project_name" => $detection_project['detection_project_name'], + "patient_user_id" => $order_detection['user_id'], + "doctor_user_id" => $user_doctor['user_id'], + ]; + + $imService->detectionTestReportStr($data); + + Db::commit(); + }catch (\Throwable $e){ + Db::rollBack(); + Log::getInstance("DetectionService-bindDetectionTube")->error($e->getMessage()); + return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage()); + } + + $result['status'] = 1; + $result['message'] = "成功"; + $result['data'] = (string)$order_inquiry['order_inquiry_id']; + + return success($result); + } + + /** + * 取消未支付检测订单 + * @param string|int $order_no 订单编号 + * @param string|int $cancel_reason 取消订单原因(1:主动取消 2:客服取消 3:支付超时) + * @param string|int $cancel_remarks 取消备注 + * @return array + */ + public function cancelUnpayDetectionOrder(string|int $order_no, string|int $cancel_reason, string|int $cancel_remarks): array + { + $result = array(); + $result['status'] = 1; + $result['message'] = "成功"; + + // 获取检测订单数据 + $params = array(); + $params['detection_no'] = $order_no; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)){ + $result['status'] = 0; + $result['message'] = "取消未支付的检测订单失败:未查询到对应订单数据"; + return $result; + } + + // 检测订单状态 + if ($order_detection['detection_status'] == 5) { + // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + $result['status'] = 2; + $result['message'] = "取消未支付的检测订单:订单已取消"; + return $result; + } + + if ($order_detection['detection_status'] != 1) { + // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + $result['status'] = 0; + $result['message'] = "取消未支付的检测订单:订单状态为" . $order_detection['detection_status'] . "无法执行"; + return $result; + } + + // 检测订单退款状态 + if (!in_array($order_detection['detection_refund_status'], [0, 4, 5])) { + // 检测订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常) + $result['status'] = 0; + $result['message'] = "取消未支付的检测订单:订单正在退款中"; + return $result; + } + + // 检测订单支付状态 + if ($order_detection['detection_pay_status'] == 2) { + // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) + $result['status'] = 2; + $result['message'] = "取消未支付的检测订单:订单已支付"; + return $result; + } + + // 检测订单删除状态 + if ($order_detection['is_delete'] == 1) { + // 删除状态(0:否 1:是) + $result['status'] = 2; + $result['message'] = "取消未支付的检测订单:订单已被删除"; + return $result; + } + + // 取消检测订单 + $data = array(); + $data['detection_status'] = 5; // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + if ($cancel_reason == 3){ + $data['detection_pay_status'] = 5; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) + } + + $data['cancel_time'] = date("Y-m-d H:i:s", time()); + $data['cancel_reason'] = $cancel_reason; // 取消订单原因(1:主动取消 2:客服取消 3:支付超时) + $data['cancel_remarks'] = $cancel_remarks; // 取消订单备注 + $data['updated_at'] = date("Y-m-d H:i:s", time()); + + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + OrderDetection::editOrderDetection($params,$data); + + return $result; + } + + /** + * 检测订单退款接口 + */ + public function detectionRefund(string $order_detection_id, string $refund_reason) + { + // 获取订单数据 + $params = array(); + $params['order_detection_id'] = $order_detection_id; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)) { + throw new BusinessException("订单数据为空"); + } + + // 检测问诊订单状态 + if (!in_array($order_detection['detection_status'], [2, 5])) { + // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + throw new BusinessException("订单状态错误"); + } + + // 检测订单退款状态 + if (in_array($order_detection['detection_refund_status'], [2, 3, 5,6])) { + // 检测订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常) + throw new BusinessException("订单退款状态错误"); + } + + // 检测支付状态 + if ($order_detection['detection_pay_status'] != 2) { + // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) + throw new BusinessException("订单支付状态错误"); + } + + // 系统退款编号 + $generator = $this->container->get(IdGeneratorInterface::class); + $detection_refund_no = $generator->generate(); + + // 检测订单金额 + if ($order_detection['payment_amount_total'] > 0){ + // 发起退款 + $WechatPay = new WechatPay(1, 3); + + $options = array(); + $options['transaction_id'] = $order_detection['escrow_trade_no']; + $options['out_refund_no'] = (string)$detection_refund_no; + $options['reason'] = $refund_reason; + $options['amount'] = [ + 'refund' => (int)round($order_detection['payment_amount_total'] * 100), + 'total' => (int)round($order_detection['payment_amount_total'] * 100), + 'currency' => "CNY", + ]; + + $result = $WechatPay->refund($options); + + // 处理订单退款状态 + // 检测订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭) + $success_time = ""; + if ($result['status'] == "SUCCESS") { + // 退款成功 + $detection_refund_status = 3; + $success_time = $result['success_time']; + } elseif ($result['status'] == "CLOSED") { + // 退款关闭 + $detection_refund_status = 5; + } elseif ($result['status'] == "PROCESSING") { + // 退款处理中 + $detection_refund_status = 2; + } elseif ($result['status'] == "ABNORMAL") { + // 退款异常,此情况不处理,进行短信通知 + throw new BusinessException("订单退款状态异常"); + } else { + throw new BusinessException("订单退款状态错误"); + } + + $refund_id = $result['refund_id']; + }else{ + $detection_refund_status = 3; + $success_time = date('Y-m-d H:i:s',time()); + $refund_id = $generator->generate(); + } + + // 新增退款表 + $data = array(); + $data['patient_id'] = $order_detection['patient_id']; + $data['order_detection_id'] = $order_detection['order_detection_id']; + $data['detection_no'] = $order_detection['detection_no']; + $data['detection_refund_no'] = $detection_refund_no; + $data['refund_id'] = $refund_id; + $data['detection_refund_status'] = $detection_refund_status; + $data['refund_total'] = $order_detection['payment_amount_total']; + $data['refund_reason'] = $refund_reason; + + if ($detection_refund_status == 3 && !empty($success_time)) { + $data['success_time'] = date("Y-m-d H:i:s", strtotime($success_time)); // 退款成功时间 + } + + $order_detection_refund = OrderDetectionRefund::add($data); + if (empty($order_detection_refund)) { + throw new BusinessException("添加退款表失败"); + } + + // 修改问诊订单表状态 + $data = array(); + $data['detection_refund_status'] = $detection_refund_status; + + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + OrderDetection::editOrderDetection($params, $data); + } + + /** + * 获取患者某一状态下的检测订单数量 + * @param string $patient_id 患者id + * @param int $detection_status 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + * @return int + */ + public function getPatientDetectionWithStatus(string $patient_id,int $detection_status): int + { + $params = array(); + $params['patient_id'] = $patient_id; + $params['detection_status'] = $detection_status; + return OrderDetection::getCount($params); + } +} \ No newline at end of file diff --git a/app/Services/DoctorAuthService.php b/app/Services/DoctorAuthService.php index 3104839..990ab29 100644 --- a/app/Services/DoctorAuthService.php +++ b/app/Services/DoctorAuthService.php @@ -722,7 +722,7 @@ class DoctorAuthService extends BaseService } if (empty($doctor_info_data)) { - return success(); + return fail(HttpEnumCode::HTTP_ERROR,"请您修改后再提交"); } Db::beginTransaction(); diff --git a/app/Services/DoctorInquiryService.php b/app/Services/DoctorInquiryService.php index 41ac74a..a32bd0b 100644 --- a/app/Services/DoctorInquiryService.php +++ b/app/Services/DoctorInquiryService.php @@ -51,17 +51,7 @@ class DoctorInquiryService extends BaseService } // 接诊开关 - $result['info']['is_open'] = 0; - if ($inquiry_type == 1) { - // 专家 - $result['info']['is_open'] = $doctor['is_img_expert_reception']; - } elseif ($inquiry_type == 2) { - // 快速 - $result['info']['is_open'] = $doctor['is_img_quick_reception']; - } elseif ($inquiry_type == 3) { - // 公益 - $result['info']['is_open'] = $doctor['is_img_welfare_reception']; - } + $is_open = 0; // 接诊价格 $result['info']['inquiry_price'] = 0; @@ -102,8 +92,16 @@ class DoctorInquiryService extends BaseService } $result['info']['work_num_day'] = $doctor_inquiry_config['work_num_day'] ?: 0; + + // 接诊开关 + if ($doctor_inquiry_config['is_enable'] == 1){ + $is_open = 1; + } } + // 接诊开关 + $result['info']['is_open'] = $is_open; + // 每日最大接诊数量 $result['config']['max_work_num_day'] = $system_inquiry_config['max_work_num_day']; @@ -163,75 +161,62 @@ class DoctorInquiryService extends BaseService return fail(HttpEnumCode::HTTP_ERROR, "请先进行绑定结算银行卡"); } - // 医生接诊配置表 - $params = array(); - $params['doctor_id'] = $user_info['client_user_id']; - $params['inquiry_type'] = $inquiry_type; - $params['inquiry_mode'] = $inquiry_mode; - $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); - if (empty($doctor_inquiry_config)) { - if ($inquiry_type != 2) { - // 快速问诊可能会存在未创建的情况 - return fail(HttpEnumCode::HTTP_ERROR, "请先完善问诊配置"); - } - } - Db::beginTransaction(); + try { + // 医生接诊配置表 $params = array(); $params['doctor_id'] = $user_info['client_user_id']; + $params['inquiry_type'] = $inquiry_type; + $params['inquiry_mode'] = $inquiry_mode; + $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); + if (empty($doctor_inquiry_config)) { + // 无问诊配置,快速问诊创建问诊配置并打开问诊。其余类型直接返回错误 + if ($inquiry_type != 2){ + // 快速问诊可能会存在未创建的情况 + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "请先完善问诊配置"); + } - $data = array(); - if ($inquiry_type == 1) { - // 专家 - $data['is_img_expert_reception'] = $is_open; - $data['is_online'] = $is_open; - } elseif ($inquiry_type == 2) { - // 快速 - $data['is_img_quick_reception'] = $is_open; - } elseif ($inquiry_type == 3) { - // 公益 - $data['is_img_welfare_reception'] = $is_open; - } - - UserDoctor::editUserDoctor($params, $data); - - if ($inquiry_type == 2 && $is_open == 1) { + // 获取系统问诊配置表 $params = array(); - $params['doctor_id'] = $user_info['client_user_id']; $params['inquiry_type'] = $inquiry_type; $params['inquiry_mode'] = $inquiry_mode; - $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); - if (empty($doctor_inquiry_config)) { - // 系统问诊配置表 - $params = array(); - $params['inquiry_type'] = $inquiry_type; - $params['inquiry_mode'] = $inquiry_mode; - $system_inquiry_config = SystemInquiryConfig::getOne($params); - if (empty($system_inquiry_config)) { - Db::rollBack(); - return fail(HttpEnumCode::SERVER_ERROR); - } - - // 快速问诊,需创建 - $data = array(); - $data['doctor_id'] = $user_info['client_user_id']; - $data['system_inquiry_config_id'] = $system_inquiry_config['system_inquiry_config_id']; - $data['inquiry_type'] = $inquiry_type; - $data['inquiry_mode'] = $inquiry_mode; - $data['work_num_day'] = $system_inquiry_config['max_work_num_day'] ?: 0; - $data['inquiry_price'] = $system_inquiry_config['inquiry_price']; - - $doctor_inquiry_config = DoctorInquiryConfig::addInquiryConfig($data); - if (empty($doctor_inquiry_config)) { - Db::rollBack(); - return fail(HttpEnumCode::SERVER_ERROR); - } + $system_inquiry_config = SystemInquiryConfig::getOne($params); + if (empty($system_inquiry_config)) { + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR); } + + // 快速问诊,需创建 + $data = array(); + $data['doctor_id'] = $user_info['client_user_id']; + $data['system_inquiry_config_id'] = $system_inquiry_config['system_inquiry_config_id']; + $data['inquiry_type'] = $inquiry_type; + $data['inquiry_mode'] = $inquiry_mode; + $data['is_enable'] = 1; // 是否启用(0:否 1:是) + $data['last_enable_method'] = 1; // 最后开启方式(1:自己 2:后台) + $data['work_num_day'] = $system_inquiry_config['max_work_num_day'] ?: 0; + $data['inquiry_price'] = $system_inquiry_config['inquiry_price']; + + $doctor_inquiry_config = DoctorInquiryConfig::addInquiryConfig($data); + if (empty($doctor_inquiry_config)) { + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR); + } + }else{ + // 已存在问诊配置,进行修改 + $params = array(); + $params['inquiry_config_id'] = $doctor_inquiry_config["inquiry_config_id"]; + + $data = array(); + $data['is_enable'] = $is_open; + $data['last_enable_method'] = 1; + DoctorInquiryConfig::editInquiryConfig($params,$data); } Db::commit(); - } catch (\Exception $e) { + }catch (\Throwable $e){ Db::rollBack(); return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage()); } @@ -345,7 +330,7 @@ class DoctorInquiryService extends BaseService $params[] = ['inquiry_config_id', '=', $doctor_inquiry_config['inquiry_config_id']]; $params[] = ['created_at', '>', date('Y-m-01', time())]; $modify_month_count = DoctorInquiryPriceRecord::getCount($params); - if ($modify_month_count >= 5000) { + if ($modify_month_count >= 5) { // 每自然月仅限调整5次 Db::rollBack(); return fail(HttpEnumCode::HTTP_ERROR, "问诊价格每自然月仅限调整5次"); @@ -356,7 +341,7 @@ class DoctorInquiryService extends BaseService $params[] = ['inquiry_config_id', '=', $doctor_inquiry_config['inquiry_config_id']]; $params[] = ['created_at', '>', date('Y-m-d', time())]; $modify_month_count = DoctorInquiryPriceRecord::getCount($params); - if ($modify_month_count >= 100000) { + if ($modify_month_count >= 1) { // 问诊价格每日仅限调整1次 Db::rollBack(); return fail(HttpEnumCode::HTTP_ERROR, "问诊价格每日仅限调整1次"); diff --git a/app/Services/ImService.php b/app/Services/ImService.php index a60ec44..f7c4dc8 100644 --- a/app/Services/ImService.php +++ b/app/Services/ImService.php @@ -662,4 +662,117 @@ class ImService extends BaseService throw new BusinessException($e->getMessage()); } } + + /** + * 糖组检测报告 + * @param array $data + * @return void + */ + public function detectionTestReport(array $data): void + { + try { + // 发送消息 + $cloud_custom_data = array(); + $cloud_custom_data['order_inquiry_id'] = (string)$data['order_inquiry_id']; + $cloud_custom_data['is_system'] = 1; + $cloud_custom_data['inquiry_type'] = $data['inquiry_type']; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测) + $cloud_custom_data['message_rounds'] = 0; + $cloud_custom_data['order_no'] = $data['detection_no']; + $cloud_custom_data['patient_family_data']['patient_name'] = $data['patient_name']; + $cloud_custom_data['patient_family_data']['patient_sex'] = $data['patient_sex']; + $cloud_custom_data['patient_family_data']['patient_age'] = $data['patient_age']; + + // 消息内容 + $message_content_data = array(); + $message_content_data['message_type'] = 10; + $message_content_data['title'] = $data['detection_project_name']; + $message_content_data['desc'] = ""; + $message_content_data['data']['order_no'] = (string)$data['detection_no']; + $message_content_data['data']['disease_class_names'] = $data['disease_class_names']; + $message_content_data['data']['detection_link'] = addAliyunOssWebsite($data['detection_result_pdf']);// 检测结果链接(oss) + $message_content_data['data']['message_path'] = "/pages/checkOrderDetail/checkOrderDetail?order_detection_id=" . $data['detection_no']; // 跳转地址(小程序内页) + $message_content = [ + 'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE), + ]; + + $this->sendMessage($data['patient_user_id'],$data['doctor_user_id'], $message_content, "TIMCustomElem", $cloud_custom_data); + + } catch (\Throwable $e) { + throw new BusinessException($e->getMessage()); + } + } + + /** + * 糖组检测报告-文字 + * @param array|object $order_detection + * @param string $doctor_name 医生名称 + * @param string $detection_project_name 检测项目名称 + * @param string $doctor_user_id 医生user_id + * @param string $patient_user_id 患者user_id + * @param string|int $inquiry_type + * @return void + */ + public function detectionTestReportStr(array $data): void + { + try { + // 消息内容 + $cloud_custom_data = array(); + $cloud_custom_data['order_inquiry_id'] = (string)$data['order_inquiry_id']; + $cloud_custom_data['is_system'] = 1; + $cloud_custom_data['inquiry_type'] = $data['inquiry_type']; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测) + $cloud_custom_data['message_rounds'] = 0; + $cloud_custom_data['order_no'] = $data['detection_no']; + $cloud_custom_data['patient_family_data']['patient_name'] = $data['patient_name']; + $cloud_custom_data['patient_family_data']['patient_sex'] = $data['patient_sex']; + $cloud_custom_data['patient_family_data']['patient_age'] = $data['patient_age']; + + $message_content = [ + 'Text' => $data['doctor_name'] . "医生您好,您给我开具的【" . $data['detection_project_name'] . "】检测项目报告已经出来啦,请您抽空查看报告并做一下解读,谢谢。", + ]; + + $this->sendMessage($data['patient_user_id'],$data['doctor_user_id'], $message_content, "TIMTextElem", $cloud_custom_data); + + } catch (\Throwable $e) { + throw new BusinessException($e->getMessage()); + } + } + + /** + * 患者病例 + * @param array|object $order_inquiry + * @param string $doctor_user_id + * @param string $disease_desc + * @return void + */ + public function patientCase(array|object $order_inquiry, string $doctor_user_id,string|null $disease_desc = ""): void + { + try { + // 发送消息 + $cloud_custom_data = array(); + $cloud_custom_data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + $cloud_custom_data['is_system'] = 1; + $cloud_custom_data['inquiry_type'] = $order_inquiry['inquiry_type']; + $cloud_custom_data['message_rounds'] = 0; + $cloud_custom_data['patient_family_data']['patient_name'] = $order_inquiry['patient_name']; + $cloud_custom_data['patient_family_data']['patient_sex'] = $order_inquiry['patient_sex']; + $cloud_custom_data['patient_family_data']['patient_age'] = $order_inquiry['patient_age']; + + // 消息内容 + $message_content_data = array(); + $message_content_data['message_type'] = 11; + $message_content_data['title'] = "患者信息"; + $message_content_data['desc'] = ""; + $message_content_data['data']['order_no'] = $order_inquiry['inquiry_no']; + $message_content_data['data']['disease_desc'] = $disease_desc ?: ""; + $message_content_data['data']['message_path'] = "/Pages/yishi/case/index?order_inquiry_id=" . $order_inquiry['order_inquiry_id']; // 跳转地址(小程序内页) + $message_content = [ + 'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE), + ]; + + $this->sendMessage($doctor_user_id, $order_inquiry['user_id'], $message_content, "TIMCustomElem", $cloud_custom_data); + + } catch (\Throwable $e) { + throw new BusinessException($e->getMessage()); + } + } } \ No newline at end of file diff --git a/app/Services/IndexService.php b/app/Services/IndexService.php index b7cc9f3..da99fa0 100644 --- a/app/Services/IndexService.php +++ b/app/Services/IndexService.php @@ -20,6 +20,112 @@ use Hyperf\Utils\WaitGroup; */ class IndexService extends BaseService { +// /** +// * 医生端-首页 +// * @return array +// */ +// public function getDoctorIndex(): array +// { +// $user_info = $this->request->getAttribute("userInfo") ?? []; +// +// // 获取医生数据 +// $params = array(); +// $params['doctor_id'] = $user_info['client_user_id']; +// +// $fields = [ +// "doctor_id", +// "user_id", +// "user_name", +// "open_id", +// "status", +// "idcard_status", +// "iden_auth_status", +// "iden_auth_fail_reason", +// "multi_point_status", +// "is_bind_bank", +// "praise_rate", +// "avg_response_time", +// "number_of_fans", +// "avatar", +// "is_online", +// "is_img_expert_reception", +// "is_img_welfare_reception", +// "is_img_quick_reception", +// ]; +// +// $doctor = UserDoctorModel::getOne($params, $fields); +// if (empty($doctor)) { +// return fail(HttpEnumCode::USER_STATUS_ERROR); +// } +// +// if ($doctor['status'] == 0){ +// return fail(HttpEnumCode::USER_STATUS_DISABLE); +// } +// +// if ($doctor['status'] != 1){ +// return fail(HttpEnumCode::USER_STATUS_ERROR); +// } +// +// $InquiryService = new InquiryService(); +// $OrderPrescriptionService = new OrderPrescriptionService(); +// +// // 获取未接诊患者个数 +// $not_accepted_inquiry_num = $InquiryService->getDoctorNotAcceptedInquiryNum($doctor['doctor_id']); +// +// // 获取接诊中患者个数 +// $accepting_inquiry_num = $InquiryService->getDoctorAcceptingInquiryNum($doctor['doctor_id']); +// +// // 获取被驳回处方数据 +// $reject_prescription_number = $OrderPrescriptionService->getDoctorExistsAuditFail($doctor['doctor_id']); +// +// // 获取医生问诊价格 +// $params = array(); +// $params['doctor_id'] = $doctor['doctor_id']; +// $params['inquiry_type'] = 1;// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊) +// $params['inquiry_mode'] = 1;// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员) +// $doctor_inquiry_config = DoctorInquiryConfigModel::getOne($params); +// +// // 获取banner +// $params = array(); +// $params["app_type"] = 1; +// $params["client_type"] = 2; +// $params["banner_place"] = 1; +// $params["banner_status"] = 1; +// $banner = BannerModel::getList($params); +// if (!empty($banner)){ +// foreach ($banner as &$item){ +// $item['banner_path'] = addAliyunOssWebsite($item['banner_path']); +// } +// } +// +// // 处理返回数据 +// $info = array(); +// $info['doctor_id'] = $doctor['doctor_id']; +// $info['user_name'] = $doctor['user_name']; +// $info['status'] = $doctor['status']; +// $info['idcard_status'] = $doctor['idcard_status'];// 实名认证状态(0:未认证 1:认证通过 2:认证失败) +// $info['iden_auth_status'] = $doctor['iden_auth_status'];// 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) +// $info['multi_point_status'] = $doctor['multi_point_status'];// 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) +// $info['is_bind_bank'] = $doctor['is_bind_bank'];// 是否已绑定结算银行卡(0:否 1:是) +// $info['avatar'] = addAliyunOssWebsite($doctor['avatar']); +// $info['is_img_expert_reception'] = $doctor['is_img_expert_reception'];// 是否参加专家图文接诊(0:否 1:是) +// $info['is_img_welfare_reception'] = $doctor['is_img_welfare_reception'];// 是否参加公益图文问诊(0:否 1:是) +// $info['is_img_quick_reception'] = $doctor['is_img_quick_reception'];// 是否参加快速图文接诊(0:否 1:是) +// $info['praise_rate'] = $doctor['praise_rate'];// 好评率(百分制。回复质量占4、服务态度占3、回复速度占3。每周计算一次) +// $info['avg_response_time'] = (float)ceil($doctor['avg_response_time']);;// 平均响应时间(分钟制) +// $info['number_of_fans'] = $doctor['number_of_fans'];// 被关注数量 +// $info['inquiry_price'] = $doctor_inquiry_config['inquiry_price'] ?? "";// 在线问诊价格 +// $info['not_accepted_inquiry_num'] = $not_accepted_inquiry_num ?? 0;// 获取未接诊患者个数 +// $info['accepting_inquiry_num'] = $accepting_inquiry_num ?? 0;// 获取接诊中患者个数 +// $info['reject_prescription_number'] = $reject_prescription_number ?? 0;// 获取被驳回处方数据 +// +// $data = array(); +// $data['banner'] = $banner ?? [];// banner +// $data['info'] = $info;// 医生数据 +// +// return success($data); +// } + /** * 医生端-首页 * @return array @@ -47,10 +153,6 @@ class IndexService extends BaseService "avg_response_time", "number_of_fans", "avatar", - "is_online", - "is_img_expert_reception", - "is_img_welfare_reception", - "is_img_quick_reception", ]; $doctor = UserDoctorModel::getOne($params, $fields); @@ -78,12 +180,19 @@ class IndexService extends BaseService // 获取被驳回处方数据 $reject_prescription_number = $OrderPrescriptionService->getDoctorExistsAuditFail($doctor['doctor_id']); - // 获取医生问诊价格 + // 在线问诊价格 + $inquiry_price = ""; + + // 获取医生问诊配置 $params = array(); $params['doctor_id'] = $doctor['doctor_id']; - $params['inquiry_type'] = 1;// 接诊类型(1:专家问诊 2:快速问诊 3:公益问诊) - $params['inquiry_mode'] = 1;// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员) - $doctor_inquiry_config = DoctorInquiryConfigModel::getOne($params); + $doctor_inquiry_config = DoctorInquiryConfigModel::getInquiryConfigList($params); + foreach ($doctor_inquiry_config as $value){ + // 获取在线问诊设置的价格 + if ($value['inquiry_type'] == 1 && $value['inquiry_mode'] == 1){ + $inquiry_price = $value['inquiry_price']; + } + } // 获取banner $params = array(); @@ -98,6 +207,7 @@ class IndexService extends BaseService } } + // 处理返回数据 $info = array(); $info['doctor_id'] = $doctor['doctor_id']; $info['user_name'] = $doctor['user_name']; @@ -107,13 +217,10 @@ class IndexService extends BaseService $info['multi_point_status'] = $doctor['multi_point_status'];// 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) $info['is_bind_bank'] = $doctor['is_bind_bank'];// 是否已绑定结算银行卡(0:否 1:是) $info['avatar'] = addAliyunOssWebsite($doctor['avatar']); - $info['is_img_expert_reception'] = $doctor['is_img_expert_reception'];// 是否参加专家图文接诊(0:否 1:是) - $info['is_img_welfare_reception'] = $doctor['is_img_welfare_reception'];// 是否参加公益图文问诊(0:否 1:是) - $info['is_img_quick_reception'] = $doctor['is_img_quick_reception'];// 是否参加快速图文接诊(0:否 1:是) $info['praise_rate'] = $doctor['praise_rate'];// 好评率(百分制。回复质量占4、服务态度占3、回复速度占3。每周计算一次) - $info['avg_response_time'] = (float)ceil($doctor['avg_response_time'] * 10) / 10;;// 平均响应时间(分钟制) + $info['avg_response_time'] = (float)ceil($doctor['avg_response_time']);;// 平均响应时间(分钟制) $info['number_of_fans'] = $doctor['number_of_fans'];// 被关注数量 - $info['inquiry_price'] = $doctor_inquiry_config['inquiry_price'] ?? "";// 在线问诊价格 + $info['inquiry_price'] = $inquiry_price;// 在线问诊价格 $info['not_accepted_inquiry_num'] = $not_accepted_inquiry_num ?? 0;// 获取未接诊患者个数 $info['accepting_inquiry_num'] = $accepting_inquiry_num ?? 0;// 获取接诊中患者个数 $info['reject_prescription_number'] = $reject_prescription_number ?? 0;// 获取被驳回处方数据 @@ -121,6 +228,7 @@ class IndexService extends BaseService $data = array(); $data['banner'] = $banner ?? [];// banner $data['info'] = $info;// 医生数据 + $data['doctor_inquiry_config'] = $doctor_inquiry_config;// 医生问诊配置 return success($data); } diff --git a/app/Services/InquiryService.php b/app/Services/InquiryService.php index 91ea031..6a0e6e0 100644 --- a/app/Services/InquiryService.php +++ b/app/Services/InquiryService.php @@ -8,11 +8,13 @@ use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer; use App\Constants\DoctorTitleCode; use App\Constants\HttpEnumCode; use App\Exception\BusinessException; +use App\Model\DetectionProject; use App\Model\DiseaseClass; use App\Model\DoctorInquiryConfig; use App\Model\Hospital; use App\Model\InquiryCaseProduct; use App\Model\MessageIm; +use App\Model\OrderDetection; use App\Model\OrderEvaluation; use App\Model\OrderInquiry; use App\Model\OrderInquiryCase; @@ -79,7 +81,7 @@ class InquiryService extends BaseService // 检测是否存在同类型未完成的问诊订单 $PatientOrderService = new PatientOrderService(); - $order_inquiry_id = $PatientOrderService->getNotFinishedOrderInquiry($request_params['inquiry_type'],$user_info['client_user_id']); + $order_inquiry_id = $PatientOrderService->getNotFinishedOrderInquiry($request_params['inquiry_type'], $user_info['client_user_id']); if (!empty($order_inquiry_id)) { $result['status'] = 2; $result['message'] = "当前患者存在进行中的问诊订单"; @@ -93,7 +95,7 @@ class InquiryService extends BaseService } // 是否服用过禁忌药物,且无相关禁忌(0:否 1:是)问诊购药时存在 - if (isset($request_params['is_taboo'])){ + if (isset($request_params['is_taboo'])) { if ($request_params['is_taboo'] == 0) { return fail(HttpEnumCode::HTTP_ERROR, "无法为您开具药物"); } @@ -132,8 +134,8 @@ class InquiryService extends BaseService // 检测当前医生是否和患者存在未完成问诊订单 $InquiryService = new InquiryService(); - $order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($user_info['client_user_id'],$request_params['doctor_id']); - if (!empty($order_inquiry)){ + $order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($user_info['client_user_id'], $request_params['doctor_id']); + if (!empty($order_inquiry)) { $result['status'] = 2; $result['message'] = "您和当前医生存在问诊中订单,无法再次发起问诊"; $result['data']['order_inquiry_id'] = $order_inquiry_id; @@ -144,7 +146,7 @@ class InquiryService extends BaseService // 检测当前是否符合系统问诊时间 $inquiryService = new InquiryService(); $is_system_time_pass = $inquiryService->checkSystemInquiryTime($request_params['inquiry_type']); - if (!$is_system_time_pass && $request_params['inquiry_type'] == 4){ + if (!$is_system_time_pass && $request_params['inquiry_type'] == 4) { return fail(HttpEnumCode::HTTP_ERROR, "当前非医生接诊时间"); } @@ -152,7 +154,7 @@ class InquiryService extends BaseService $DoctorInquiryService = new DoctorInquiryService(); $inquiry_price = $DoctorInquiryService->getDoctorInquiryPrice($request_params['inquiry_type'], $request_params['inquiry_mode'], $request_params['doctor_id'] ?: ""); - if ($inquiry_price > 0){ + if ($inquiry_price > 0) { // 获取可用优惠卷 $CouponService = new CouponService(); $user_coupon = $CouponService->getUserUsableCouponOne($user_info['user_id'], $request_params['inquiry_type']); @@ -182,9 +184,9 @@ class InquiryService extends BaseService $data = array(); $data['user_id'] = $user_info['user_id']; $data['patient_id'] = $user_info['client_user_id']; - if (isset($request_params['doctor_id'])){ - if (!empty($request_params['doctor_id'])){ - $data['doctor_id'] = $request_params['doctor_id']; + if (isset($request_params['doctor_id'])) { + if (!empty($request_params['doctor_id'])) { + $data['doctor_id'] = $request_params['doctor_id']; } } @@ -231,25 +233,25 @@ class InquiryService extends BaseService $data['diagnosis_date'] = $request_params['diagnosis_date'] ?: null; // 确诊日期 $data['disease_desc'] = $request_params['disease_desc'] ?: null; // 病情描述(主诉) $data['diagnose_images'] = $diagnose_images ?? ""; // 复诊凭证(多个使用逗号分隔) - if (isset($request_params['is_allergy_history'])){ - if ($request_params['is_allergy_history'] !== null){ + if (isset($request_params['is_allergy_history'])) { + if ($request_params['is_allergy_history'] !== null) { $data['is_allergy_history'] = $request_params['is_allergy_history']; // 是否存在过敏史(0:否 1:是) } } $data['allergy_history'] = $request_params['allergy_history'] ?? null; // 过敏史描述 - if (isset($request_params['is_family_history'])){ - if ($request_params['is_family_history'] !== null){ + if (isset($request_params['is_family_history'])) { + if ($request_params['is_family_history'] !== null) { $data['is_family_history'] = $request_params['is_family_history']; // 是否存在家族病史(0:否 1:是) } } $data['family_history'] = $request_params['family_history'] ?? null; // 家族病史描述 - if (isset($request_params['is_pregnant'])){ - if ($request_params['is_pregnant'] !== null){ + if (isset($request_params['is_pregnant'])) { + if ($request_params['is_pregnant'] !== null) { $data['is_pregnant'] = $request_params['is_pregnant']; // 是否备孕、妊娠、哺乳期(0:否 1:是) } } - if (isset($request_params['is_taboo'])){ - if ($request_params['is_taboo'] !== null){ + if (isset($request_params['is_taboo'])) { + if ($request_params['is_taboo'] !== null) { $data['is_taboo'] = $request_params['is_taboo']; // 是否存在禁忌药物(0:否 1:是)问诊购药时存在 } } @@ -333,7 +335,7 @@ class InquiryService extends BaseService // 加入未接诊取消订单延迟队列 // 专家问诊-公益问诊 - if (!empty($request_params['doctor_id']) && ($request_params['inquiry_type'] == 1 || $request_params['inquiry_type'] == 3)){ + if (!empty($request_params['doctor_id']) && ($request_params['inquiry_type'] == 1 || $request_params['inquiry_type'] == 3)) { $data = array(); $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; $message = new CancelUnInquiryOrdersDelayDirectProducer($data); @@ -398,15 +400,28 @@ class InquiryService extends BaseService return fail(); } + $order_inquiry_case = $order_inquiry_case->toArray(); + // 获取患者家庭成员信息表-基本信息 $params = array(); $params['family_id'] = $order_inquiry_case['family_id']; $patient_family = PatientFamily::getOne($params); + // 民族 + $nation_name = ""; + if (isset($patient_family)){ + if (!empty($patient_family['nation_name'])){ + $nation_name = $patient_family['nation_name']; + }else{ + if (!empty($order_inquiry_case['nation_name'])){ + $nation_name = $order_inquiry_case['nation_name']; + } + } + } $order_inquiry_case['height'] = $order_inquiry_case['height'] ?: $patient_family['height'] ?: NULL; $order_inquiry_case['weight'] = $order_inquiry_case['weight'] ?: $patient_family['weight'] ?: NULL; $order_inquiry_case['job_name'] = $patient_family['job_name'] ?? ""; - $order_inquiry_case['nation_name'] = $patient_family['nation_name'] ?? ""; + $order_inquiry_case['nation_name'] = $nation_name; $order_inquiry_case['marital_status'] = $patient_family['marital_status'] ?? 0; $order_inquiry_case['id_number'] = $patient_family['id_number'] ?? ""; @@ -414,11 +429,11 @@ class InquiryService extends BaseService $params = array(); $params['family_id'] = $order_inquiry_case['family_id']; $patient_family_health = PatientFamilyHealth::getOne($params); - if (empty($patient_family_health)){ + if (empty($patient_family_health)) { $order_inquiry_case['diagnosis_hospital'] = ""; $order_inquiry_case['is_take_medicine'] = null; $order_inquiry_case['drugs_name'] = ""; - }else{ + } else { $order_inquiry_case['diagnosis_hospital'] = $patient_family_health['diagnosis_hospital']; $order_inquiry_case['is_take_medicine'] = $patient_family_health['is_take_medicine']; $order_inquiry_case['drugs_name'] = $patient_family_health['drugs_name']; @@ -428,14 +443,14 @@ class InquiryService extends BaseService $params = array(); $params['family_id'] = $order_inquiry_case['family_id']; $patient_family_personal = PatientFamilyPersonal::getOne($params); - if (empty($patient_family_personal)){ + if (empty($patient_family_personal)) { $order_inquiry_case['drink_wine_status'] = null; $order_inquiry_case['smoke_status'] = null; $order_inquiry_case['chemical_compound_status'] = null; $order_inquiry_case['chemical_compound_describe'] = ""; $order_inquiry_case['is_operation'] = null; $order_inquiry_case['operation'] = ""; - }else{ + } else { $order_inquiry_case['drink_wine_status'] = $patient_family_personal['drink_wine_status']; $order_inquiry_case['smoke_status'] = $patient_family_personal['smoke_status']; $order_inquiry_case['chemical_compound_status'] = $patient_family_personal['chemical_compound_status']; @@ -475,7 +490,27 @@ class InquiryService extends BaseService $order_inquiry_case['diagnose_images'] = $diagnose_images; } - return success($order_inquiry_case->toArray()); + // 检测项目 + $order_inquiry_case['detection_project'] = null; + if ($order_inquiry['inquiry_type'] == 5) { + // 获取检测订单 + $params = array(); + $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + $order_detection = OrderDetection::getOne($params); + if (!empty($order_detection)) { + // 获取检测项目 + $params = array(); + $params['detection_project_id'] = $order_detection['detection_project_id']; + $detection_project = DetectionProject::getOne($params); + if (!empty($detection_project)) { + $order_inquiry_case['detection_project']['detection_project_name'] = $detection_project['detection_project_name']; // 检测项目名称 + $order_inquiry_case['detection_project']['detection_time'] = $order_detection['detection_time']; // 检测时间 + $order_inquiry_case['detection_project']['detection_link'] = addAliyunOssWebsite($order_detection['detection_result_pdf']); // 检测结果链接 + } + } + } + + return success($order_inquiry_case); } /** @@ -581,7 +616,7 @@ class InquiryService extends BaseService $data['doctor_id'] = $doctor_id; $data['patient_id'] = $user_info['client_user_id']; $data['order_inquiry_id'] = $order_inquiry_id; - $data['name_mask'] = Mask::maskNameStr($order_inquiry['patient_name'],2); + $data['name_mask'] = Mask::maskNameStr($order_inquiry['patient_name'], 2); $data['reply_quality'] = $reply_quality; $data['service_attitude'] = $service_attitude; $data['reply_progress'] = $reply_progress; @@ -697,7 +732,7 @@ class InquiryService extends BaseService $result['quick_inquiry_price'] = $quick_inquiry_price; $result['medicine_inquiry_price'] = $medicine_inquiry_price; $result['expert_inquiry_price'] = $expert_inquiry_price ?: 0; - $result['welfare_inquiry_price'] = $welfare_inquiry_price ?: 0 ; + $result['welfare_inquiry_price'] = $welfare_inquiry_price ?: 0; return success($result); } @@ -715,17 +750,17 @@ class InquiryService extends BaseService $params['order_inquiry_id'] = $order_inquiry_id; $order_inquiry = OrderInquiry::getOne($params); if (empty($order_inquiry)) { - return fail(HttpEnumCode::HTTP_ERROR,"订单错误"); + return fail(HttpEnumCode::HTTP_ERROR, "订单错误"); } - if ($user_info['user_type'] == 1){ - if ($order_inquiry['patient_id'] != $user_info['client_user_id']){ + if ($user_info['user_type'] == 1) { + if ($order_inquiry['patient_id'] != $user_info['client_user_id']) { return fail(HttpEnumCode::SERVER_ERROR); } } - if ($user_info['user_type'] == 2){ - if ($order_inquiry['doctor_id'] != $user_info['client_user_id']){ + if ($user_info['user_type'] == 2) { + if ($order_inquiry['doctor_id'] != $user_info['client_user_id']) { return fail(HttpEnumCode::SERVER_ERROR); } } @@ -742,18 +777,31 @@ class InquiryService extends BaseService $follow = false; // 关注状态 $is_evaluation = false; // 评价状态 - if ($user_info['user_type'] == 1){ + // 沟通次数,沟通时长 + $params = array(); + $params['inquiry_type'] = $order_inquiry['inquiry_type']; + $params['inquiry_mode'] = $order_inquiry['inquiry_mode']; + $system_inquiry_config = SystemInquiryConfig::getOne($params); + if (!empty($system_inquiry_config)) { + $times_number = $system_inquiry_config['times_number']; + $duration = $system_inquiry_config['duration']; + } - // 沟通次数,沟通时长 - $params = array(); - $params['inquiry_type'] = $order_inquiry['inquiry_type']; - $params['inquiry_mode'] = $order_inquiry['inquiry_mode']; - $system_inquiry_config = SystemInquiryConfig::getOne($params); - if (!empty($system_inquiry_config)){ - $times_number = $system_inquiry_config['times_number']; - $duration = $system_inquiry_config['duration']; + // 获取医生问诊配置-问诊购药 + $multi_point_enable = 0; + + $params = array(); + $params['doctor_id'] = $user_doctor['doctor_id']; + $params['inquiry_type'] = 4; + $params['inquiry_mode'] = 1; + $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); + if (!empty($doctor_inquiry_config)) { + if ($doctor_inquiry_config['is_enable'] == 1){ + $multi_point_enable = 1;// 是否开启问诊购药 } + } + if ($user_info['user_type'] == 1) { // 关注状态 $params = array(); $params['patient_id'] = $user_info['client_user_id']; @@ -768,12 +816,11 @@ class InquiryService extends BaseService $is_evaluation = OrderEvaluation::getExists($params); } - - $result = array(); $result['doctor_user_id'] = $user_doctor['user_id']; $result['patient_user_id'] = $order_inquiry['user_id']; $result['doctor_id'] = $order_inquiry['doctor_id']; + $result['patient_id'] = $order_inquiry['patient_id']; $result['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; $result['patient_family_name'] = $order_inquiry['patient_name']; $result['patient_family_sex'] = $order_inquiry['patient_sex']; @@ -786,6 +833,7 @@ class InquiryService extends BaseService $result['is_evaluation'] = $is_evaluation; $result['reception_time'] = $order_inquiry['reception_time'] ?: null; // 接诊时间 $result['multi_point_status'] = $user_doctor['multi_point_status'] ?: null;// 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) + $result['multi_point_enable'] = $multi_point_enable;// 医生问诊购药是否开启 return success($result); } @@ -801,41 +849,55 @@ class InquiryService extends BaseService $page = $this->request->input('page', 1); $per_page = $this->request->input('per_page', 10); + // 获取该医生下问诊过的用户id和家庭成员id + $params = array(); $params['doctor_id'] = $user_info['client_user_id']; + $result = OrderInquiry::getInquiryEndPage($params, $page, $per_page); - $inquiry_status_params = ["5","6"]; - - $fields = [ - 'order_inquiry_id', - 'user_id', - 'patient_id', - 'doctor_id', - 'family_id', - 'inquiry_type', - 'inquiry_mode', - 'inquiry_status', - 'inquiry_no', - 'reception_time', - 'complete_time', - 'finish_time', - 'cancel_time', - 'cancel_reason', - 'cancel_remarks', - 'patient_name', - 'patient_sex', - 'patient_age', - 'created_at', - ]; - - $result = OrderInquiry::getInquiryStatusWithDoctorPage($params,$inquiry_status_params,$fields,$page,$per_page); - - if (!empty($result['data'])){ - foreach ($result['data'] as &$item){ + if (empty($result['data'])) { + foreach ($result['data'] as &$item) { $params = array(); - $params['message_send_result'] = 1; - $params['order_inquiry_id'] = $item['order_inquiry_id']; - $item['message_im'] = MessageIm::getOne($params); + $params['doctor_id'] = $user_info['client_user_id']; + $params['user_id'] = $item['user_id']; + $params['family_id'] = $item['family_id']; + + $inquiry_status_params = [5,6]; + + $fields = [ + 'order_inquiry_id', + 'user_id', + 'patient_id', + 'doctor_id', + 'family_id', + 'inquiry_type', + 'inquiry_mode', + 'inquiry_status', + 'inquiry_no', + 'reception_time', + 'complete_time', + 'finish_time', + 'cancel_time', + 'cancel_reason', + 'cancel_remarks', + 'patient_name', + 'patient_sex', + 'patient_age', + 'created_at', + ]; + + $order_inquiry = OrderInquiry::getInquiryStatusLastOne($params,$inquiry_status_params,$fields); + + unset($item['user_id']); + unset($item['family_id']); + if (!empty($order_inquiry)){ + $item = $order_inquiry->toArray(); + + $params = array(); + $params['message_send_result'] = 1; + $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + $item['message_im'] = MessageIm::getOne($params); + } } } return success($result); @@ -852,9 +914,10 @@ class InquiryService extends BaseService $order_inquiry_id = $this->request->route('order_inquiry_id'); - if (empty($user_info)){ + if (empty($user_info)) { return fail(HttpEnumCode::HTTP_ERROR, "操作失败"); } + // 获取问诊订单数据 $params = array(); $params['order_inquiry_id'] = $order_inquiry_id; @@ -865,7 +928,7 @@ class InquiryService extends BaseService $order_inquiry = $order_inquiry->toArray(); - if ($order_inquiry['doctor_id'] != $user_info['client_user_id'] && $order_inquiry['patient_id'] != $user_info['client_user_id']){ + if ($order_inquiry['doctor_id'] != $user_info['client_user_id'] && $order_inquiry['patient_id'] != $user_info['client_user_id']) { return fail(HttpEnumCode::HTTP_ERROR, "操作失败"); } @@ -875,13 +938,13 @@ class InquiryService extends BaseService } // 订单退款状态 - if (!in_array($order_inquiry['inquiry_refund_status'],[0,4,5])){ + if (!in_array($order_inquiry['inquiry_refund_status'], [0, 4, 5])) { // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常) return fail(HttpEnumCode::HTTP_ERROR, "订单正在退款,无法结束"); } // 订单支付状态 - if ($order_inquiry['inquiry_pay_status'] != 2){ + if ($order_inquiry['inquiry_pay_status'] != 2) { return fail(HttpEnumCode::HTTP_ERROR, "订单未支付,无法结束"); } @@ -889,7 +952,7 @@ class InquiryService extends BaseService $params = array(); $params['doctor_id'] = $order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ + if (empty($user_doctor)) { return fail(HttpEnumCode::HTTP_ERROR, "操作失败"); } @@ -899,24 +962,24 @@ class InquiryService extends BaseService // 修改问诊订单表 $data = array(); $data['inquiry_status'] = 5;// 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消) - $data['complete_time'] = date('Y-m-d H:i:s',time());// 订单完成时间(问诊完成时间) + $data['complete_time'] = date('Y-m-d H:i:s', time());// 订单完成时间(问诊完成时间) $params = array(); $params['order_inquiry_id'] = $order_inquiry_id; - OrderInquiry::edit($params,$data); + OrderInquiry::edit($params, $data); // 新增患者历史问诊表-问诊完成后添加 $data = array(); $data['patient_id'] = $order_inquiry['patient_id']; $data['doctor_id'] = $order_inquiry['doctor_id']; - if (!empty($order_inquiry['pharmacist_id'])){ + if (!empty($order_inquiry['pharmacist_id'])) { $data['pharmacist_id'] = $order_inquiry['pharmacist_id']; } $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; $data['history_status'] = 1; $patient_history_inquiry = PatientHistoryInquiry::addPatientHistoryInquiry($data); - if (empty($patient_history_inquiry)){ + if (empty($patient_history_inquiry)) { Db::rollBack(); return fail(HttpEnumCode::SERVER_ERROR, "添加患者历史问诊表失败"); } @@ -943,25 +1006,54 @@ class InquiryService extends BaseService try { // 发送IM消息-问诊已完成 $imService = new ImService(); - $imService->inquiryComplete($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']); + $imService->inquiryComplete($order_inquiry, $user_doctor['user_id'], $order_inquiry['user_id']); // 发送IM消息-问诊结束评价通知 - $imService->inquiryEndEvaluation($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']); + $imService->inquiryEndEvaluation($order_inquiry, $user_doctor['user_id'], $order_inquiry['user_id']); // 医生-发送通知消息-问诊结束 - $MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']); + $MessagePush = new MessagePush($user_doctor['user_id'], $order_inquiry['order_inquiry_id']); $MessagePush->finishInquiryToDoctor(); // 患者-发送通知消息-患者的问诊服务结束 - $MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']); + $MessagePush = new MessagePush($order_inquiry['user_id'], $order_inquiry['order_inquiry_id']); $MessagePush->patientInquiryFinish(); - }catch(\Exception $e){ - return success([],HttpEnumCode::HTTP_SUCCESS,"消息发送失败"); + } catch (\Exception $e) { + return success([], HttpEnumCode::HTTP_SUCCESS, "消息发送失败"); } return success(); } + /** + * 获取患者最后一条问诊订单id + * @return array + */ + public function getPatientLastInquiryId(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $patient_id = $this->request->input('patient_id'); + $doctor_id = $this->request->input('doctor_id'); + + if (empty($user_info)) { + return fail(HttpEnumCode::HTTP_ERROR, "操作失败"); + } + + // 获取问诊订单数据 + $params = array(); + $params['patient_id'] = $patient_id; + $params['doctor_id'] = $doctor_id; + + $inquiry_status_params = [3,4,5,6,7]; + $order_inquiry = OrderInquiry::getInquiryStatusLastOne($params,$inquiry_status_params); + if (empty($order_inquiry)) { + return success(""); + } + + return success($order_inquiry['order_inquiry_id']); + } + /** * 获取医生未接诊订单数量 * @param string $doctor_id 医生id @@ -1058,7 +1150,7 @@ class InquiryService extends BaseService $params['inquiry_status'] = 6; // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消) $order_inquiry = OrderInquiry::getList($params); - if (empty($order_inquiry)){ + if (empty($order_inquiry)) { return []; } @@ -1120,7 +1212,7 @@ class InquiryService extends BaseService $inquiry_refund_no = $generator->generate(); // 检测订单金额 - if ($order_inquiry['payment_amount_total'] > 0){ + if ($order_inquiry['payment_amount_total'] > 0) { // 发起退款 $WechatPay = new WechatPay(1, 1); @@ -1158,7 +1250,7 @@ class InquiryService extends BaseService $refund_id = $result['refund_id']; - }else{ + } else { // 模拟退款 $inquiry_refund_status = 3; $refund_id = "模拟退款:" . $generator->generate(); @@ -1265,7 +1357,7 @@ class InquiryService extends BaseService // 取消问诊订单 $data = array(); $data['inquiry_status'] = 7; - if ($cancel_reason == 5){ + if ($cancel_reason == 5) { $data['inquiry_pay_status'] = 5; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款) } @@ -1287,7 +1379,7 @@ class InquiryService extends BaseService $params = array(); $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; $order_inquiry_coupon = OrderInquiryCoupon::getOne($params); - if (!empty($order_inquiry_coupon)){ + if (!empty($order_inquiry_coupon)) { // 发送站内消息-优惠卷退还 $MessagePush = new MessagePush($order_inquiry['user_id'], $order_inquiry['order_inquiry_id']); $MessagePush->patientRefundCoupon($order_inquiry_coupon['coupon_name']); @@ -1298,7 +1390,7 @@ class InquiryService extends BaseService } /** - * 检测当前医生是否和患者存在未完成问诊订单 + * 检测当前医生是否和患者进行中的问诊订单 * @param string $patient_id * @param string $doctor_id * @return array @@ -1310,10 +1402,6 @@ class InquiryService extends BaseService $params[] = ['patient_id', '=', $patient_id]; } - if (!empty($family_id)) { - $params[] = ['family_id', '=', $family_id]; - } - $params = array(); $params[] = ['patient_id', '=', $patient_id]; $params[] = ['doctor_id', '=', $doctor_id]; @@ -1341,8 +1429,8 @@ class InquiryService extends BaseService $redis_key = "inquiryRefund" . $order_inquiry_id; $redis_value = $redis->get($redis_key); - if(empty($redis_value)){ - $redis->set($redis_key, 1,60 * 60 * 24 * 5); + if (empty($redis_value)) { + $redis->set($redis_key, 1, 60 * 60 * 24 * 5); return true; } @@ -1370,14 +1458,14 @@ class InquiryService extends BaseService * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function returnInquiryCoupon(string $order_inquiry_id,string $patient_user_id): bool + public function returnInquiryCoupon(string $order_inquiry_id, string $patient_user_id): bool { try { // 获取用户优惠卷信息 $params = array(); $params['order_inquiry_id'] = $order_inquiry_id; $order_inquiry_coupon = OrderInquiryCoupon::getOne($params); - if (empty($order_inquiry_coupon)){ + if (empty($order_inquiry_coupon)) { // 订单未使用优惠卷,无需退还 return true; } @@ -1386,7 +1474,7 @@ class InquiryService extends BaseService $params = array(); $params['user_coupon_id'] = $order_inquiry_coupon['user_coupon_id']; $user_coupon = UserCoupon::getOne($params); - if (empty($user_coupon)){ + if (empty($user_coupon)) { // 无该优惠卷数据,无需处理 return true; } @@ -1395,10 +1483,10 @@ class InquiryService extends BaseService $data = array(); // 检测优惠卷过期时间。判断是否需要退还 - if (strtotime($user_coupon['valid_end_time']) <= time()){ + if (strtotime($user_coupon['valid_end_time']) <= time()) { // 超出过期时间,置为已过期 $data['user_coupon_status'] = 3; - }else{ + } else { $data['user_coupon_status'] = 0; $data['coupon_use_date'] = null; } @@ -1408,7 +1496,7 @@ class InquiryService extends BaseService UserCoupon::edit($params, $data); return true; - } catch(\Exception $e){ + } catch (\Exception $e) { Log::getInstance()->error("退还用户优惠卷失败" . $e->getMessage()); return false; } @@ -1426,7 +1514,7 @@ class InquiryService extends BaseService $params['inquiry_type'] = $inquiry_type; $params['inquiry_mode'] = 1; $system_inquiry_config = SystemInquiryConfig::getOne($params); - if (empty($system_inquiry_config)){ + if (empty($system_inquiry_config)) { throw new BusinessException("系统问诊配置错误"); } @@ -1434,16 +1522,16 @@ class InquiryService extends BaseService $params = array(); $params['system_inquiry_config_id'] = $system_inquiry_config['system_inquiry_config_id']; $system_inquiry_time = SystemInquiryTime::getList($params); - if (empty($system_inquiry_time)){ + if (empty($system_inquiry_time)) { throw new BusinessException("系统问诊时间配置错误"); } // 检测当前是否坐班时间 $is_time_pass = false; // 非坐班时间 - foreach ($system_inquiry_time as $item){ - $now_time = date('H',time()) . date('i',time()); - if ($item['start_time'] < $now_time && $item['end_time'] > $now_time){ + foreach ($system_inquiry_time as $item) { + $now_time = date('H', time()) . date('i', time()); + if ($item['start_time'] < $now_time && $item['end_time'] > $now_time) { // 符合当前时间区间 $is_time_pass = true; } @@ -1451,4 +1539,91 @@ class InquiryService extends BaseService return $is_time_pass; } + + /** + * 获取现在时间距离订单结束时间的时间差 + * @param array|object $order_inquiry + * @return float|int + */ + public function getInquiryFinishTimeDiff(array|object $order_inquiry): float|int + { + if (!in_array($order_inquiry['inquiry_status'], [1, 2, 3, 4])) { + throw new BusinessException("问诊订单状态错误"); + } + + // 随机初始时间 + $time = mt_rand(60,600); + $wait_pay_time = 60 * 30;// 待支付时间 + $wait_assign_time = 60 * 5;// 待分配时间 + $wait_inquiry_time = 0; // 待接诊时间 + $wait_finish_time = 0;// 待结束时间 + + if ($order_inquiry['inquiry_type'] == 1) { + // 专家问诊 + $wait_assign_time = 0; + $wait_inquiry_time = 60 * 60 * 24; + $wait_finish_time = 60 * 60 * 24; + } elseif ($order_inquiry['inquiry_type'] == 2) { + // 快速问诊 + $wait_assign_time = 60 * 5; + $wait_inquiry_time = 60 * 10; + $wait_finish_time = 60 * 60; + } elseif ($order_inquiry['inquiry_type'] == 3) { + // 公益问诊 + $wait_assign_time = 0; + $wait_inquiry_time = 60 * 60 * 24; + $wait_finish_time = 60 * 60 * 24; + } elseif ($order_inquiry['inquiry_type'] == 4) { + // 问诊购药 + $wait_assign_time = 60 * 5; + $wait_inquiry_time = 60 * 10; + $wait_finish_time = 60 * 30; + } elseif ($order_inquiry['inquiry_type'] == 5) { + // 检测订单 + $wait_finish_time = 60 * 60 * 24 * 3; + } + + switch ($order_inquiry['inquiry_status']) { + case '1': + // 待支付 + $wait_pay_time = $wait_pay_time - (time() - strtotime($order_inquiry['created_at'])); + if ($wait_pay_time < 0 ){ + $wait_pay_time = 0; + } + + $time = $time + $wait_pay_time + $wait_assign_time + $wait_inquiry_time + $wait_finish_time; + break; + case '2': + // 待分配 + $time = $time + $wait_assign_time + $wait_inquiry_time + $wait_finish_time; + break; + case '3': + // 待接诊 + $wait_inquiry_time = $wait_inquiry_time - (time() - strtotime($order_inquiry['pay_time'])); + if ($wait_inquiry_time < 0 ){ + $wait_inquiry_time = 0; + } + + $time = $time + $wait_inquiry_time + $wait_finish_time; + break; + case '4': + // 已接诊 + $wait_finish_time = $wait_finish_time - (time() - strtotime($order_inquiry['reception_time'])); + if ($wait_finish_time < 0 ){ + $wait_finish_time = 0; + } + + $time = $time + $wait_finish_time; + break; + default: + break; + } + + if ($time < 0){ + $time = 0; + } + + return $time; + } + } \ No newline at end of file diff --git a/app/Services/LoginService.php b/app/Services/LoginService.php index 7f51a52..c733fa6 100644 --- a/app/Services/LoginService.php +++ b/app/Services/LoginService.php @@ -8,6 +8,7 @@ use App\Model\User as UserModel; use App\Model\UserDoctor as UserDoctorModel; use App\Model\UserPatient as UserPatientModel; use App\Model\UserPharmacist as UserPharmacistModel; +use App\Model\UserSystem; use App\Utils\Http; use App\Utils\Jwt; use App\Utils\Log; @@ -42,7 +43,7 @@ class LoginService extends BaseService // 获取手机号 $phone_info = $weChat->getPhone($phone_code); - if (empty($phone_info) || empty($phone_info['phone_info']) || empty($phone_info['phone_info']['purePhoneNumber'])){ + if (empty($phone_info) || empty($phone_info['phone_info']) || empty($phone_info['phone_info']['purePhoneNumber'])) { return fail(HttpEnumCode::GET_WX_ERROR); } @@ -63,7 +64,7 @@ class LoginService extends BaseService // 处理药师特殊情况,后台添加,前台不允许注册 if ($user_type == 3) { Db::rollBack(); - return fail(HttpEnumCode::HTTP_ERROR,"账号不存在,请联系客服"); + return fail(HttpEnumCode::HTTP_ERROR, "账号不存在,请联系客服"); } // 获取用户默认头像oss地址 @@ -72,7 +73,7 @@ class LoginService extends BaseService // 新增用户表 $data = array(); - $data['user_name'] = 'gdxz' . substr($phone_info['phone_info']['purePhoneNumber'],-4) . mt_rand(10000,99999); + $data['user_name'] = 'gdxz' . substr($phone_info['phone_info']['purePhoneNumber'], -4) . mt_rand(10000, 99999); $data['mobile'] = $phone_info['phone_info']['purePhoneNumber']; $data['wx_mobile'] = $phone_info['phone_info']['purePhoneNumber']; $data['user_type'] = $user_type; @@ -115,17 +116,40 @@ class LoginService extends BaseService $client_user_id = $user_doctor['doctor_id']; } + // 新增用户配置表 + $params = array(); + $params['user_id'] = $user['user_id']; + $user_system = UserSystem::getOne($params); + if (empty($user_system)) { + $data = array(); + $data['user_id'] = $user['user_id']; + $data['is_accept_im_message_push'] = 1; // 默认新增一下配置表 + $user_system = UserSystem::addUserSystem($data); + if (empty($user_system)) { + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR); + } + } + + // 修改用户表创建者id + $params = array(); + $params['user_id'] = $user['user_id']; + + $data = array(); + $data['created_by'] = $user['user_id']; + UserModel::editUser($params,$data); + // 创建im账号 $account = new Account(); // 创建单个账号 - $account->createAccount($user->user_id,$user->user_name,addAliyunOssWebsite($avatar)); + $account->createAccount($user->user_id, $user->user_name, addAliyunOssWebsite($avatar)); - if ($user['user_type'] == 1){ + if ($user['user_type'] == 1) { // 发放用户优惠卷 $CouponService = new CouponService(); - $res = $CouponService->DistributeCoupon(1,(string)$user->user_id,$user_patient['patient_id']); - if (!$res){ + $res = $CouponService->DistributeCoupon(1, (string)$user->user_id, $user_patient['patient_id']); + if (!$res) { Db::rollBack(); return fail(HttpEnumCode::SERVER_ERROR); } @@ -144,17 +168,17 @@ class LoginService extends BaseService $params['user_id'] = $user->user_id; if ($user['user_type'] == 1) { $result = UserPatientModel::getOne($params); - if (!empty($result)){ + if (!empty($result)) { $client_user_id = $result['patient_id']; } } elseif ($user['user_type'] == 2) { $result = UserDoctorModel::getOne($params); - if (!empty($result)){ + if (!empty($result)) { $client_user_id = $result['doctor_id']; } } elseif ($user['user_type'] == 3) { $result = UserPharmacistModel::getOne($params); - if (!empty($result)){ + if (!empty($result)) { $client_user_id = $result['pharmacist_id']; } } @@ -210,7 +234,7 @@ class LoginService extends BaseService // 创建单个账号 $account->createAccount($user['user_id'], $user['user_name'], $avatar); } - }catch(\Exception $e){ + } catch (\Throwable $e) { Log::getInstance()->error("IM账号倒入失败"); } } @@ -224,8 +248,7 @@ class LoginService extends BaseService $data = array(); $data['login_ip'] = $login_ip ?? ""; $data['last_login_at'] = date('Y-m-d H:i:s', time()); - - UserModel::editUser($params,$data); + UserModel::editUser($params, $data); // 组合生成token的数据 $token_user_data = array(); @@ -266,16 +289,16 @@ class LoginService extends BaseService $user_type = $this->request->input('user_type'); $wx_code = $this->request->input('wx_code'); - $app_env = config('app_env','dev'); - if ($app_env != 'dev'){ + $app_env = config('app_env', 'dev'); + if ($app_env != 'dev') { $redis = $this->container->get(Redis::class); // 验证验证码 $sms_code = $redis->get("login_code" . $phone); - if (empty($sms_code)){ + if (empty($sms_code)) { return fail(HttpEnumCode::CODE_EXPIRED); } - if ($sms_code != $code){ + if ($sms_code != $code) { return fail(HttpEnumCode::CODE_ERROR); } } @@ -303,7 +326,7 @@ class LoginService extends BaseService // 处理药师特殊情况,后台添加,前台不允许注册 if ($user_type == 3) { Db::rollBack(); - return fail(HttpEnumCode::HTTP_ERROR,"账号不存在,请联系客服"); + return fail(HttpEnumCode::HTTP_ERROR, "账号不存在,请联系客服"); } // 获取用户默认头像oss地址 @@ -312,7 +335,7 @@ class LoginService extends BaseService // 新增用户表 $data = array(); - $data['user_name'] = 'gdxz' . substr($phone,-4) . mt_rand(10000,99999);; + $data['user_name'] = 'gdxz' . substr($phone, -4) . mt_rand(10000, 99999);; $data['mobile'] = $phone; $data['wx_mobile'] = $phone; $data['user_type'] = $user_type; @@ -351,25 +374,48 @@ class LoginService extends BaseService return fail(HttpEnumCode::SERVER_ERROR); } $client_user_id = $user_doctor['doctor_id']; - }elseif($user['user_type'] == 3){ + } elseif ($user['user_type'] == 3) { Db::rollBack(); return fail(HttpEnumCode::SERVER_ERROR); - }else{ + } else { Db::rollBack(); return fail(HttpEnumCode::SERVER_ERROR); } + // 新增用户配置表 + $params = array(); + $params['user_id'] = $user['user_id']; + $user_system = UserSystem::getOne($params); + if (empty($user_system)) { + $data = array(); + $data['user_id'] = $user['user_id']; + $data['is_accept_im_message_push'] = 1; // 默认新增一下配置表 + $user_system = UserSystem::addUserSystem($data); + if (empty($user_system)) { + Db::rollBack(); + return fail(HttpEnumCode::SERVER_ERROR); + } + } + + // 修改用户表创建者id + $params = array(); + $params['user_id'] = $user['user_id']; + + $data = array(); + $data['created_by'] = $user['user_id']; + UserModel::editUser($params,$data); + // 创建im账号 $account = new Account(); // 创建单个账号 - $account->createAccount($user->user_id,$user->user_name,addAliyunOssWebsite($avatar)); + $account->createAccount($user->user_id, $user->user_name, addAliyunOssWebsite($avatar)); - if ($user['user_type'] == 1){ + if ($user['user_type'] == 1) { // 发放用户优惠卷 $CouponService = new CouponService(); - $res = $CouponService->DistributeCoupon(1,(string)$user->user_id,$user_patient['patient_id']); - if (!$res){ + $res = $CouponService->DistributeCoupon(1, (string)$user->user_id, $user_patient['patient_id']); + if (!$res) { Db::rollBack(); return fail(HttpEnumCode::SERVER_ERROR); } @@ -386,20 +432,20 @@ class LoginService extends BaseService $params['user_id'] = $user->user_id; if ($user['user_type'] == 1) { $result = UserPatientModel::getOne($params); - if (!empty($result)){ + if (!empty($result)) { $client_user_id = $result['patient_id']; } } elseif ($user['user_type'] == 2) { $result = UserDoctorModel::getOne($params); - if (!empty($result)){ + if (!empty($result)) { $client_user_id = $result['doctor_id']; } } elseif ($user['user_type'] == 3) { $result = UserPharmacistModel::getOne($params); - if (!empty($result)){ + if (!empty($result)) { $client_user_id = $result['pharmacist_id']; } - }else{ + } else { Db::rollBack(); return fail(HttpEnumCode::SERVER_ERROR); } @@ -438,6 +484,9 @@ class LoginService extends BaseService } elseif ($user['user_type'] == 3) { $params['pharmacist_id'] = $result['pharmacist_id']; $res = UserPharmacistModel::editUserPharmacist($params, $data); + } else { + Db::rollBack(); + return fail(HttpEnumCode::USER_STATUS_ERROR); } if (!$res) { @@ -455,7 +504,7 @@ class LoginService extends BaseService // 创建单个账号 $account->createAccount($user['user_id'], $user['user_name'], $avatar); } - }catch(\Exception $e){ + } catch (\Throwable $e) { Log::getInstance()->error("IM账号倒入失败"); } } @@ -469,7 +518,7 @@ class LoginService extends BaseService $data = array(); $data['login_ip'] = $login_ip ?? ""; $data['last_login_at'] = date('Y-m-d H:i:s', time()); - UserModel::editUser($params,$data); + UserModel::editUser($params, $data); // 组合生成token的数据 $token_user_data = array(); @@ -483,7 +532,9 @@ class LoginService extends BaseService $token = $Jwt->encode($token_user_data); // 登录成功,删除验证码 -// $redis->del("login_code" . $phone); + if ($app_env != 'dev') { + $redis->del("login_code" . $phone); + } // 组合返回数据 $data = array(); @@ -516,7 +567,7 @@ class LoginService extends BaseService $user_info = $this->request->getAttribute("userInfo") ?? []; $wx_code = $this->request->input('wx_code'); - if (empty($user_info)){ + if (empty($user_info)) { return fail(HttpEnumCode::GET_WX_ERROR); } @@ -524,7 +575,7 @@ class LoginService extends BaseService $params = array(); $params['user_id'] = $user_info['user_id']; $user = UserModel::getOne($params); - if (empty($user)){ + if (empty($user)) { return fail(); } @@ -567,7 +618,7 @@ class LoginService extends BaseService $data['open_id'] = $wx_info_data['openid']; } - if (!empty($data)){ + if (!empty($data)) { $data['updated_at'] = date('Y-m-d H:i:s', time()); $params = array(); @@ -580,7 +631,7 @@ class LoginService extends BaseService } elseif ($user['user_type'] == 3) { $params['pharmacist_id'] = $result['pharmacist_id']; $res = UserPharmacistModel::editUserPharmacist($params, $data); - }else{ + } else { $res = false; } @@ -588,9 +639,9 @@ class LoginService extends BaseService return fail(HttpEnumCode::SERVER_ERROR); } } - } catch (\Exception $e) { + } catch (\Throwable $e) { // 此处不进行处理 - return fail(HttpEnumCode::GET_WX_ERROR,$e->getMessage()); + return fail(HttpEnumCode::GET_WX_ERROR, $e->getMessage()); } return success(); diff --git a/app/Services/MessagePush.php b/app/Services/MessagePush.php index 21a0190..ccde9f2 100644 --- a/app/Services/MessagePush.php +++ b/app/Services/MessagePush.php @@ -7,7 +7,10 @@ use App\Amqp\Producer\SendStationMessageProducer; use App\Amqp\Producer\SendSubMessageProducer; use App\Constants\HttpEnumCode; use App\Exception\BusinessException; +use App\Model\BasicDetectionOrgan; +use App\Model\DetectionProject; use App\Model\DoctorWithdrawal; +use App\Model\OrderDetection; use App\Model\OrderInquiry; use App\Model\OrderInquiryCase; use App\Model\OrderInquiryCoupon; @@ -20,10 +23,10 @@ use App\Model\User; use App\Model\UserDoctor; use App\Utils\Log; use Hyperf\Amqp\Producer; -use Hyperf\Utils\ApplicationContext; +//use Hyperf\Utils\ApplicationContext; +use Hyperf\Context\ApplicationContext; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; -use function _PHPStan_503e82092\RingCentral\Psr7\str; /** * 消息推送业务类 @@ -139,7 +142,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:" . $e->getMessage()); } } @@ -184,7 +187,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:" . $e->getMessage()); } } @@ -221,7 +224,7 @@ class MessagePush extends BaseService throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } - } catch (\Exception $e) { + } catch (\Throwable $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); } @@ -232,8 +235,6 @@ class MessagePush extends BaseService * 患者-通知患者医生已接诊 * 站内、订阅、短信 * @return void - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface */ public function patientAcceptedInquiry(): void { @@ -353,7 +354,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -362,8 +363,6 @@ class MessagePush extends BaseService * 患者的问诊服务结束 * 站内、订阅 * @return void - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface */ public function patientInquiryFinish(): void { @@ -418,11 +417,12 @@ class MessagePush extends BaseService } // 问诊内容 - $disease_desc = $order_inquiry_case['disease_desc']; - if (!empty($disease_desc)) { - $disease_desc = substr($disease_desc, 0, 15); - if ($disease_desc) { - $disease_desc = $disease_desc . "..."; + if (empty($order_inquiry_case['disease_desc'])){ + $disease_desc = $inquiry_type_string; + }else{ + $disease_desc = $order_inquiry_case['disease_desc']; + if (mb_strlen($disease_desc) > 15) { + $disease_desc = mb_substr($disease_desc, 0, 15, 'UTF-8') . '...'; } } @@ -447,7 +447,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -524,7 +524,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -565,7 +565,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -597,7 +597,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -629,7 +629,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -661,7 +661,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -751,7 +751,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -881,7 +881,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -922,7 +922,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -988,13 +988,9 @@ class MessagePush extends BaseService $sub_data['params']['page'] = "pages/medinceOrderDetail/medinceOrderDetail?order_product_id={$order_product_id}"; $sub_data['params']['data'] = [ "character_string9" => (string)$order_product['order_product_no'],// 快递单号 - "time7" => $order_product['delivery_time'],// 发货时间 - "thing3" => $order_product['province'] . $order_product['city'] . $order_product['county'],// 收货地址 - "thing6" => (string)$order_product['consignee_name'],// 收货人 - "thing5" => "您的药品已发货,点击可以查看订单详情",// 备注 ]; @@ -1020,7 +1016,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -1037,7 +1033,7 @@ class MessagePush extends BaseService { try { - } catch (\Exception $e) { + } catch (\Throwable $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); } @@ -1118,22 +1114,16 @@ class MessagePush extends BaseService $thing6 = "5分钟内未接诊,平台将自动取消问诊"; } - $sub_data = array(); $sub_data['push_user_id'] = $this->user['user_id']; $sub_data['wx_template_id'] = "G1RIs0RYqsTQ2CuPQWalIMyb6_deuEEbJfajfhGvNzc";//咨询提醒 $sub_data['params']['page'] = "Pages/yishi/wenzhen_v2/wenzhen"; $sub_data['params']['data'] = [ "thing1" => "您有一个新的问诊服务等待接诊",// 提醒内容 - "name2" => (string)$this->order_inquiry['patient_name'],// 患者姓名 - "thing4" => (string)$disease_desc,// 病情描述 - "thing6" => $thing6,// 提示说明 - "thing5" => "",// 咨询内容 - ]; // 短信 @@ -1157,7 +1147,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入订阅推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -1166,8 +1156,6 @@ class MessagePush extends BaseService * 医生xx时间后还未接诊 * 站内、订阅失败发送短信 * @return bool - * @throws ContainerExceptionInterface - * @throws NotFoundExceptionInterface */ public function doctorNotYetInquiry(): bool { @@ -1180,78 +1168,69 @@ class MessagePush extends BaseService throw new BusinessException("加入推送队列失败:问诊病例为空"); } - if ($this->push_type == 1) { - // 站内 - $data = array(); - $data['user_id'] = $this->user['user_id']; - $data['notice_type'] = 1; - $data['inquiry_type'] = $this->order_inquiry['inquiry_type']; // 问诊类型(医生端服务通知存在 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) - $data['from_name'] = "肝胆小秘书"; - $data['notice_brief_title'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。"; - $data['notice_title'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。"; - $data['notice_content'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。"; - $data['link_type'] = 1; // 聊天详情页 + // 站内 + $data = array(); + $data['user_id'] = $this->user['user_id']; + $data['notice_type'] = 1; + $data['inquiry_type'] = $this->order_inquiry['inquiry_type']; // 问诊类型(医生端服务通知存在 1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) + $data['from_name'] = "肝胆小秘书"; + $data['notice_brief_title'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。"; + $data['notice_title'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。"; + $data['notice_content'] = "{$this->order_inquiry['patient_name']}患者的问诊您还未接诊,请注意查看。"; + $data['link_type'] = 1; // 聊天详情页 - $link_params = array(); - $link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; - $link_params['inquiry_type'] = $this->order_inquiry['inquiry_type']; - $link_params['doctor_user_id'] = $this->user['user_id']; - $link_params['patient_user_id'] = $this->order_inquiry['user_id']; - $data['link_params'] = json_encode($link_params, JSON_UNESCAPED_UNICODE);// 跳转参数 - - $message = new SendStationMessageProducer($data); - $producer = ApplicationContext::getContainer()->get(Producer::class); - $result = $producer->produce($message); - if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); - } - } elseif ($this->push_type == 2) { - // 订阅 - $inquiry_type = inquiryTypeToString($this->order_inquiry['inquiry_type']); - - $sub_data = array(); - $sub_data['push_user_id'] = $this->user['user_id']; - $sub_data['wx_template_id'] = "G1RIs0RYqsTQ2CuPQWalIMyb6_deuEEbJfajfhGvNzc"; // 咨询提醒 - $sub_data['params']['page'] = "Pages/yishi/wenzhen_v2/wenzhen"; - $sub_data['params']['data'] = [ - "thing1" => "您好医生,{$this->order_inquiry['patient_name']}患者的({$inquiry_type})服务您还未接诊;",// 提醒内容 - - "name2" => $this->order_inquiry['patient_name'],// 患者姓名 - - "thing4" => mb_substr($order_inquiry_case['disease_desc'], 0, 18),// 病情描述 - - "thing6" => "24小时内未接诊,平台将自动取消问诊。",// 提示说明 - - "thing5" => "",// 咨询内容 - - ]; - - // 短信 - $sms_data = array(); - $sms_data['template_code'] = "SMS_271905266"; - $sms_data['scene_desc'] = "医生xx时间后还未接诊"; - $sms_data['phone'] = $this->user['mobile']; - $sms_data['user_id'] = $this->user['user_id']; - - $template_param = array(); - $template_param['type'] = inquiryTypeToString($this->order_inquiry['inquiry_type']); - $template_param['name'] = $this->order_inquiry['patient_name']; - $sms_data['template_param'] = $template_param; - - $data = array(); - $data['sub_data'] = $sub_data; - $data['sms_data'] = $sms_data; - - $message = new SendSubMessageProducer($data); - $producer = ApplicationContext::getContainer()->get(Producer::class); - $result = $producer->produce($message); - if (!$result) { - throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); - } + $link_params = array(); + $link_params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; + $link_params['inquiry_type'] = $this->order_inquiry['inquiry_type']; + $link_params['doctor_user_id'] = $this->user['user_id']; + $link_params['patient_user_id'] = $this->order_inquiry['user_id']; + $data['link_params'] = json_encode($link_params, JSON_UNESCAPED_UNICODE);// 跳转参数 + $message = new SendStationMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { - throw new BusinessException("加入推送队列失败" . $e->getMessage()); + + $inquiry_type = inquiryTypeToString($this->order_inquiry['inquiry_type']); + + // 订阅 + $sub_data = array(); + $sub_data['push_user_id'] = $this->user['user_id']; + $sub_data['wx_template_id'] = "G1RIs0RYqsTQ2CuPQWalIMyb6_deuEEbJfajfhGvNzc"; // 咨询提醒 + $sub_data['params']['page'] = "Pages/yishi/wenzhen_v2/wenzhen"; + $sub_data['params']['data'] = [ + "thing1" => "您好医生,{$this->order_inquiry['patient_name']}患者的({$inquiry_type})服务您还未接诊;",// 提醒内容 + "name2" => $this->order_inquiry['patient_name'],// 患者姓名 + "thing4" => mb_substr($order_inquiry_case['disease_desc'], 0, 18),// 病情描述 + "thing6" => "24小时内未接诊,平台将自动取消问诊。",// 提示说明 + "thing5" => "",// 咨询内容 + ]; + + $sms_data = array(); + $sms_data['template_code'] = "SMS_271905266"; + $sms_data['scene_desc'] = "医生xx时间后还未接诊"; + $sms_data['phone'] = $this->user['mobile']; + $sms_data['user_id'] = $this->user['user_id']; + + $template_param = array(); + $template_param['type'] = inquiryTypeToString($this->order_inquiry['inquiry_type']); + $template_param['name'] = $this->order_inquiry['patient_name']; + $sms_data['template_param'] = $template_param; + + $data = array(); + $data['sub_data'] = $sub_data; + $data['sms_data'] = $sms_data; + + $message = new SendSubMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); + } + } catch (\Throwable $e) { + Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" .$e->getMessage()); } return true; @@ -1301,7 +1280,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -1356,7 +1335,7 @@ class MessagePush extends BaseService $sub_data = array(); $sub_data['push_user_id'] = $this->user['user_id']; $sub_data['wx_template_id'] = "kUy70xHlr7ADo4aIHiictM4Te7MSec3E5kHsYvFQu40"; // 处方审核结果通知 - $sub_data['params']['page'] = "Pages/yishi/chufangsetup/index"; + $sub_data['params']['page'] = "Pages/yishi/chufangsetup/index?status=1"; $sub_data['params']['data'] = [ "phrase1" => "审方通过",// 审核结果 "thing2" => "审核通过",// 原因 @@ -1385,7 +1364,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } @@ -1398,7 +1377,7 @@ class MessagePush extends BaseService * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function prescriptionVerifyFail(string $order_prescription_id): void + public function prescriptionVerifyFail(string $order_prescription_id = ""): void { try { // 获取问诊订单处方数据 @@ -1414,7 +1393,7 @@ class MessagePush extends BaseService $sub_data = array(); $sub_data['push_user_id'] = $this->user['user_id']; $sub_data['wx_template_id'] = "kUy70xHlr7ADo4aIHiictM4Te7MSec3E5kHsYvFQu40"; // 处方审核结果通知 - $sub_data['params']['page'] = "Pages/yishi/chufangsetup/index"; + $sub_data['params']['page'] = "Pages/yishi/chufangsetup/index?status=2"; $sub_data['params']['data'] = [ "phrase1" => "审方不通过",// 审核结果 "thing2" => (string)$order_prescription['pharmacist_fail_reason'],// 原因 @@ -1425,7 +1404,7 @@ class MessagePush extends BaseService // 短信 $sms_data = array(); $sms_data['template_code'] = "SMS_271905264"; - $sms_data['scene_desc'] = "您为{$this->order_inquiry['patient_name']}患者开具的电子处方药师审核不通过,请尽快前往微信小程序“处方管理”中查看原因,并重开处方。模版code:SMS_271905264"; + $sms_data['scene_desc'] = "您为{$this->order_inquiry['patient_name']}患者开具的电子处方药师审核不通过,请尽快前往微信小程序“处方管理”中查看原因,并重开处方。"; $sms_data['phone'] = $this->user['mobile']; $sms_data['user_id'] = $this->user['user_id']; @@ -1443,7 +1422,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . $e->getMessage()); } } @@ -1477,7 +1456,7 @@ class MessagePush extends BaseService throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } - } catch (\Exception $e) { + } catch (\Throwable $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); } @@ -1513,7 +1492,7 @@ class MessagePush extends BaseService throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } - } catch (\Exception $e) { + } catch (\Throwable $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); } @@ -1592,7 +1571,7 @@ class MessagePush extends BaseService throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } - } catch (\Exception $e) { + } catch (\Throwable $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); } @@ -1668,7 +1647,7 @@ class MessagePush extends BaseService throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } - } catch (\Exception $e) { + } catch (\Throwable $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); } @@ -1746,7 +1725,7 @@ class MessagePush extends BaseService throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } - } catch (\Exception $e) { + } catch (\Throwable $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); } @@ -1821,7 +1800,7 @@ class MessagePush extends BaseService throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } - } catch (\Exception $e) { + } catch (\Throwable $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); } @@ -1901,7 +1880,7 @@ class MessagePush extends BaseService Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } @@ -1980,7 +1959,7 @@ class MessagePush extends BaseService throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } - } catch (\Exception $e) { + } catch (\Throwable $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); } @@ -2019,7 +1998,7 @@ class MessagePush extends BaseService throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } - } catch (\Exception $e) { + } catch (\Throwable $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); } @@ -2057,7 +2036,7 @@ class MessagePush extends BaseService throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } } - } catch (\Exception $e) { + } catch (\Throwable $e) { throw new BusinessException("加入推送队列失败" . $e->getMessage()); } @@ -2080,6 +2059,7 @@ class MessagePush extends BaseService $user_doctor = UserDoctor::getOne($params); if (empty($user_doctor)) { Log::getInstance("MessagePush")->error("错误:医生数据为空"); + return; } // 获取问诊订单关联病例 @@ -2114,6 +2094,7 @@ class MessagePush extends BaseService $result = $producer->produce($message); if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); + return; } // 问诊内容-病情主诉 @@ -2133,15 +2114,10 @@ class MessagePush extends BaseService $sub_data['params']['page'] = "Pages/yishi/wenzhen_v2/wenzhen"; $sub_data['params']['data'] = [ "thing1" => "问诊咨询已取消",// 提醒内容 - "name2" => (string)$this->order_inquiry['patient_name'],// 患者姓名 - "thing4" => (string)$disease_desc,// 病情描述 - "thing6" => "您可以选择其他患者的问诊咨询进行接诊",// 提示说明 - "thing5" => "",// 咨询内容 - ]; $data = array(); @@ -2154,7 +2130,7 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } @@ -2228,8 +2204,333 @@ class MessagePush extends BaseService if (!$result) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); } - } catch (\Exception $e) { + } catch (\Throwable $e) { Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); } } + + /** + * 患者-检测订单取消成功通知 + * 订阅 + * @param string $order_detection_id + * @return void + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function patientCancelDetectionOrderSuccess(string $order_detection_id): void + { + try { + // 获取检测订单 + $params = array(); + $params['order_detection_id'] = $order_detection_id; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)) { + Log::getInstance("MessagePush")->error("错误:加入推送队列失败,无检测订单数据"); + return; + } + + // 获取检测项目 + $params = array(); + $params['detection_project_id'] = $order_detection['detection_project_id']; + $detection_project = DetectionProject::getOne($params); + if (empty($detection_project)) { + Log::getInstance("MessagePush")->error("错误:加入推送队列失败,检测项目错误"); + return; + } + + $sub_data = array(); + $sub_data['push_user_id'] = $this->user['user_id']; + $sub_data['wx_template_id'] = "5aJSrO8SU5rxqdB99zzl4rMVgcOTjt5mQh56cpZI1Hg";//咨询提醒 + $sub_data['params']['page'] = "/pages/checkOrderDetail/checkOrderDetail?order_detection_id=" . $order_detection['detection_no']; + $sub_data['params']['data'] = [ + "thing1" => $order_detection['patient_name'],// 就诊人 + "thing7" => (string)$detection_project['detection_project_name'],// 服务项目 + "time6" => date('Y年m月d日 H:i'),// 取消时间 + "amount8" => $order_detection['payment_amount_total'],// 退款金额 + "thing5" => "订单取消成功,支付金额将立即原路退回。",// 温馨提示 + ]; + + $data = array(); + $data['sub_data'] = $sub_data; + $data['sms_data'] = []; + + $message = new SendSubMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); + } + } catch (\Throwable $e) { + Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage()); + } + } + + /** + * 患者-新报告生成通知 + * 订阅发送失败发送短信 + * @param string $order_detection_id + * @return void + */ + public function patientDetectionResultNotice(string $order_detection_id): void + { + try { + // 获取检测订单 + $params = array(); + $params['order_detection_id'] = $order_detection_id; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)) { + Log::getInstance("MessagePush-patientDetectionResultNotice")->error("无检测订单数据"); + return; + } + + // 获取检测项目 + $params = array(); + $params['detection_project_id'] = $order_detection['detection_project_id']; + $detection_project = DetectionProject::getOne($params); + if (empty($detection_project)) { + Log::getInstance("MessagePush-patientDetectionResultNotice")->error("检测项目错误"); + return; + } + + // 获取检测机构名称 + $params = array(); + $params['detection_organ_id'] = $order_detection['detection_organ_id']; + $basic_detection_organ = BasicDetectionOrgan::getOne($params); + if (empty($basic_detection_organ)){ + Log::getInstance("MessagePush-patientDetectionResultNotice")->error("检测机构错误"); + return; + } + + // 订阅 + $sub_data = array(); + $sub_data['push_user_id'] = $this->user['user_id']; + $sub_data['wx_template_id'] = "dNj3azLupP_w3j649v6lqz7je_ScqwgwFsnug6pKvyI"; // 处方审核结果通知 + $sub_data['params']['page'] = "/pages/checkOrderDetail/checkOrderDetail?order_detection_id=" . $order_detection['detection_no']; + $sub_data['params']['data'] = [ + "thing1" => "【" . $detection_project['detection_project_name'] . "】报告已出",// 报告名称 + "time3" => date('Y年m月d日 H:i'),// 生成时间 + "thing9" => $order_detection['patient_name'],// 就诊人 + "thing4" => $basic_detection_organ['detection_organ_name'],// 单位名称-检测所名称 + "thing8" => "请联系医生做报告解读,您有5个沟通回合。",// 测评结果 + ]; + + // 短信 + $sms_data = array(); + $sms_data['template_code'] = "SMS_462035956"; + $sms_data['scene_desc'] = "新报告生成通知"; + $sms_data['phone'] = $this->user['mobile']; + $sms_data['user_id'] = $this->user['user_id']; + + $template_param = array(); + $template_param['report'] = $detection_project['detection_project_name']; + $sms_data['template_param'] = $template_param; + + $data = array(); + $data['sub_data'] = $sub_data; + $data['sms_data'] = $sms_data; + + $message = new SendSubMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + Log::getInstance("MessagePush-patientDetectionResultNotice")->error(json_encode($data, JSON_UNESCAPED_UNICODE)); + } + } catch (\Throwable $e) { + Log::getInstance("MessagePush-patientDetectionResultNotice")->error($e->getMessage()); + } + } + + /** + * 医生-通知医生患者检测报告已生成 + * 短信 + * @param string $order_detection_id + * @return void + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function doctorDetectionResultNotice(string $order_detection_id): void + { + // 获取检测订单 + $params = array(); + $params['order_detection_id'] = $order_detection_id; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)) { + Log::getInstance("MessagePush-patientDetectionResultNotice")->error("无检测订单数据"); + return; + } + + // 获取检测项目 + $params = array(); + $params['detection_project_id'] = $order_detection['detection_project_id']; + $detection_project = DetectionProject::getOne($params); + if (empty($detection_project)) { + Log::getInstance("MessagePush-patientDetectionResultNotice")->error("检测项目错误"); + return; + } + + // 获取系统接诊配置 + $data = array(); + $data['template_code'] = "SMS_461980700"; + $data['scene_desc'] = "通知医生患者检测报告已生成"; + $data['phone'] = $this->user['mobile']; + $data['user_id'] = $this->user['user_id']; + + $template_param = array(); + $template_param['name'] = $order_detection['patient_name']; + $template_param['report'] = $detection_project['detection_project_name']; + $data['template_param'] = $template_param; + + $message = new SendSmsMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); + } + } + + /** + * 客服-通知客服 + * 短信 + * @param string $order_no + * @param string $mobile + * @return void + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function noticeReport(string $order_no,string $mobile): void + { + // 获取系统接诊配置 + $data = array(); + $data['template_code'] = "SMS_463525093"; + $data['scene_desc'] = "通知客服"; + $data['phone'] = $mobile; + + $template_param = array(); + $template_param['code'] = $order_no; + $data['template_param'] = $template_param; + + $message = new SendSmsMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + throw new BusinessException("加入推送队列失败" . json_encode($data, JSON_UNESCAPED_UNICODE)); + } + } + + /** + * 患者-im消息通知 + * 订阅 + * @param string $data 消息内容 + * @return void + */ + public function patientImMessageNotice(string $msg): void + { + try { + // 获取医生数据 + $params = array(); + $params['doctor_id'] = $this->order_inquiry['doctor_id']; + $user_doctor = UserDoctor::getOne($params); + if (empty($user_doctor)) { + Log::getInstance("MessagePush")->error("错误:医生数据为空"); + return; + } + + // im内容 + if (strlen($msg) > 15) { + $msg = mb_substr($msg, 0, 15); + if ($msg) { + $msg = $msg . "..."; + } + } + + // 订阅 + $sub_data = array(); + $sub_data['push_user_id'] = $this->user['user_id']; + $sub_data['wx_template_id'] = "9v6dZhjg09CttLd3W9nEUV_-eshNc4BYYNy59jglvZE";// 问诊提醒 + $sub_data['params']['page'] = "pages/message/message"; + $sub_data['params']['data'] = [ + "thing1" => (string)"医生回复了您的消息,点击查看详情",// 问诊内容 + "thing2" => (string)$msg,// 提醒内容 + "name3" => (string)$user_doctor['user_name'],// 问诊医生 + "thing4" => "如有困扰,前往个人中心的设置中关闭",// 提示说明 + ]; + + $data = array(); + $data['sub_data'] = $sub_data; + $data['sms_data'] = array();; + + $message = new SendSubMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + Log::getInstance("MessagePush-patientImMessageNotice")->error(json_encode($data, JSON_UNESCAPED_UNICODE)); + } + } catch (\Throwable $e) { + Log::getInstance("MessagePush-patientImMessageNotice")->error($e->getMessage()); + } + } + + /** + * 医生-im消息通知 + * 订阅 + * @param string $im_data + * @return void + */ + public function doctorImMessageNotice(string $msg): void + { + try { + // 获取问诊订单关联病例 + $params = array(); + $params['order_inquiry_id'] = $this->order_inquiry['order_inquiry_id']; + $order_inquiry_case = OrderInquiryCase::getOne($params); + if (empty($order_inquiry_case)) { + Log::getInstance("MessagePush")->error("错误:病例数据为空"); + return; + } + + // im内容 + if (strlen($msg) > 15) { + $msg = mb_substr($msg, 0, 15); + if ($msg) { + $msg = $msg . "..."; + } + } + + // 问诊内容-病情主诉 + $disease_desc = $order_inquiry_case['disease_desc']; + if (!empty($disease_desc)) { + if (strlen($disease_desc) > 15) { + $disease_desc = mb_substr($disease_desc, 0, 15); + if ($disease_desc) { + $disease_desc = $disease_desc . "..."; + } + } + } + + // 订阅 + $sub_data = array(); + $sub_data['push_user_id'] = $this->user['user_id']; + $sub_data['wx_template_id'] = "G1RIs0RYqsTQ2CuPQWalIMyb6_deuEEbJfajfhGvNzc";// 问诊提醒 + $sub_data['params']['page'] = "Pages/yishi/wenzhen_v2/wenzhen"; + $sub_data['params']['data'] = [ + "thing1" => $msg,// 提醒内容 + "name2" => (string)$this->order_inquiry['patient_name'],// 患者姓名 + "thing4" => (string)$disease_desc,// 病情描述 + "thing6" => "患者发来了最新消息,点击查看详情",// 提示说明 + ]; + + $data = array(); + $data['sub_data'] = $sub_data; + $data['sms_data'] = array();; + + $message = new SendSubMessageProducer($data); + $producer = ApplicationContext::getContainer()->get(Producer::class); + $result = $producer->produce($message); + if (!$result) { + Log::getInstance("MessagePush-patientImMessageNotice")->error(json_encode($data, JSON_UNESCAPED_UNICODE)); + } + } catch (\Throwable $e) { + Log::getInstance("MessagePush-patientImMessageNotice")->error($e->getMessage()); + } + } } \ No newline at end of file diff --git a/app/Services/OrderPrescriptionService.php b/app/Services/OrderPrescriptionService.php index aae18bc..6c29f4c 100644 --- a/app/Services/OrderPrescriptionService.php +++ b/app/Services/OrderPrescriptionService.php @@ -130,23 +130,12 @@ class OrderPrescriptionService extends BaseService * 药师-先开具药师处方,再开具医院签章 * @param string $order_prescription_id 处方id * @param string $user_id 用户id + * @param int $type 类型 1:医院 2:医生 3:药师 * @return array */ - public function openPrescription(string $order_prescription_id, string $user_id): array + public function openPrescription(string $order_prescription_id,int $type,string $user_id = ""): array { try { - // 获取用户数据 - $params = array(); - $params['user_id'] = $user_id; - $user = User::getOne($params); - if (empty($user)) { - throw new BusinessException("用户数据错误"); - } - - if ($user['user_type'] != 2 && $user['user_type'] != 3) { - throw new BusinessException("用户类型错误"); - } - // 获取处方数据 $params = array(); $params['order_prescription_id'] = $order_prescription_id; @@ -159,40 +148,20 @@ class OrderPrescriptionService extends BaseService throw new BusinessException("医生开方日期错误"); } - $CaService = new CaService($order_prescription,$user); + $CaService = new CaService($order_prescription,$type,$user_id); // 获取云证书签名+验证云证书签名 - $CaService->getVerifyCertSign($order_prescription,1); - - // 医生 - if ($user['user_type'] == 2) { + $CaService->getVerifyCertSign($order_prescription); + if ($type == 2) { // 生成处方图片+处方图片生成pdf $prescription_img_oss_path = $CaService->createPrescriptionImgPdf($order_prescription); - } - - // 药师-医院签章 - if ($user['user_type'] == 3) { - // 获取医院云证书签名+验证云证书签名 - $CaService->getVerifyCertSign($order_prescription,2); - - // 下载医生开具的处方pdf至本地,文件存在时不进行下载 + }else{ + // 下载已经开具的处方pdf至本地 $CaService->downOssPdfToLocal(); } // 进行处方pdf签章 - $file_id = $CaService->addSignPdf($user['user_type']); - - // 药师-医院签章 - if ($user['user_type'] == 3) { - // 药师端时,需要进行系统签章 - // 把药师签章的pdf存储至本地文件 - // 下载药师签章pdf图片 - $CaService->downCaPdfToLocal($file_id,1); - - // 进行处方pdf签章 - $file_id = $CaService->addSignPdf($user['user_type']); - } - + $file_id = $CaService->addSignPdf($type); $result = array(); $result['prescription_img_oss_path'] = $prescription_img_oss_path ?? ""; $result['file_id'] = $file_id; diff --git a/app/Services/OrderPrescriptionService_1.php b/app/Services/OrderPrescriptionService_1.php deleted file mode 100644 index b3a03e9..0000000 --- a/app/Services/OrderPrescriptionService_1.php +++ /dev/null @@ -1,911 +0,0 @@ -add(4); - - // 获取处方关联疾病名称 - $icd_name = ""; - co(function () use ($wg,$channel,&$icd_name,$order_prescription_id) { - defer(function() use ($wg) { - $wg->done(); - }); - - $params = array(); - $params['order_prescription_id'] = $order_prescription_id; - $order_prescription_icd = OrderPrescriptionIcd::getList($params); - if (empty($order_prescription_icd)) { - $channel->push('处方疾病数据错误'); - return; - } - - $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]; - } - } - }); - - // 获取处方关联商品数据 - $order_prescription_product = []; - co(function () use ($wg,$channel,&$order_prescription_product,$order_prescription_id) { - defer(function() use ($wg) { - $wg->done(); - }); - - $params = array(); - $params['order_prescription_id'] = $order_prescription_id; - $order_prescription_product = OrderPrescriptionProduct::getList($params); - if (empty($order_prescription_product)) { - $channel->push('处方药品数据错误'); - return; - } - }); - - // 获取医生自定义科室数据 - $hospital_department_custom = []; - $doctor_id = $order_prescription['doctor_id']; - co(function () use ($wg,$channel,&$hospital_department_custom,$doctor_id) { - defer(function() use ($wg) { - $wg->done(); - }); - - // 获取医生数据 - $params = array(); - $params['doctor_id'] = $doctor_id; - $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)) { - $channel->push('医生数据错误'); - return; - } - - // 获取医生自定义科室数据 - $params = array(); - $params['department_custom_id'] = $user_doctor['department_custom_id']; - $hospital_department_custom = HospitalDepartmentCustom::getOne($params); - if (empty($hospital_department_custom)) { - $channel->push('医生自定义数据错误'); - return; - } - }); - - // 获取处方关联病例数据 - $order_inquiry_case = []; - $order_inquiry_id = $order_prescription['order_inquiry_id']; - co(function () use ($wg,$channel,&$order_inquiry_case,$order_inquiry_id) { - defer(function() use ($wg) { - $wg->done(); - }); - - $params = array(); - $params['order_inquiry_id'] = $order_inquiry_id; - $order_inquiry_case = OrderInquiryCase::getOne($params); - if (empty($order_inquiry_case)) { - $channel->push('处方病例数据错误'); - return; - } - }); - - // 结束 - $wg->wait(); - - // 判断通道是否存在异常数据 - $res = $channel->isEmpty(); - if ($res){ - // 读取通道数据 - $data = $channel->pop(); - - // 关闭channel通道 - $channel->close(); - - throw new BusinessException($data); - }else{ - // 关闭channel通道 - $channel->close(); - } - - $CaOnline = new CaOnline(); - - // 获取云证书签名 - $data = array(); - $data['created_at'] = $order_prescription['doctor_created_time']; - $data['department_custom_name'] = $hospital_department_custom['department_name'] ?: ""; - $data['user_name'] = $order_prescription['patient_name']; - $data['sex'] = sexToStringSex($order_prescription['patient_sex']); - $data['age'] = $order_prescription['patient_age']; - $data['allergy_history'] = $order_inquiry_case['allergy_history'] ?: "无"; - $data['icd_name'] = $icd_name; - $data['doctor_advice'] = $order_prescription['doctor_advice'] ?: "无"; - - // 商品数据 - $data['product'] = array(); - foreach ($order_prescription_product as $item) { - $product = array(); - $product['product_name'] = $item['product_name'] . "(" . $item['product_spec'] . ")"; // 商品名称+商品规格 - $product['single_unit'] = $item['single_unit'] ?: ""; // 单次剂量(例:1次1包) - $product['frequency_use'] = $item['frequency_use'] ?: ""; // 使用频率(例:1天3次) - $product['single_use'] = $item['single_use'] ?: ""; // 单次用法(例:口服) - $product['prescription_product_num'] = $item['prescription_product_num'] . $item['packaging_unit']; // 商品数量 + 基本包装单位(例:盒/瓶) - $data['product'][] = $product; - } - - dump("获取用户云证书签名"); - $cert_sign_result = $CaOnline->getCertSign($user_entity_id, $user_entity_id, $data); - dump("获取用户云证书签名成功"); - - // 验证云证书签名-验证无需处理,只要不返回错误即可 - dump("验证用户云证书签名"); - $CaOnline->verifyPkcs7($cert_sign_result['signP7'], $data); - dump("验证用户云证书签名成功"); - - if ($user['user_type'] == 3) { - dump("获取医院云证书签名"); - unset($cert_sign_result); - $cert_sign_result = $CaOnline->getCertSign($hospital_entity_id, $hospital_entity_id, $data); - dump("获取医院云证书签名成功"); - - // 验证云证书签名-验证无需处理,只要不返回错误即可 - dump("验证医院云证书签名"); - $CaOnline->verifyPkcs7($cert_sign_result['signP7'], $data); - dump("验证医院云证书签名成功"); - } - - $oss = new Oss(); - // 医生 - if ($user['user_type'] == 2) { - // 下载基础处方图片 - $prescription_basic_filename = "basic/file/prescription.jpg"; - $prescription_image = $oss->getObjectToRAM($prescription_basic_filename); - - dump("下载基础处方图片成功"); - - $manager = new ImageManager(); - - $image = $manager->make($prescription_image); - - $fontPath = './extend/Ca/msyh.ttf'; - - // 处方号 - $image->text($order_prescription['prescription_code'], 1480, 540, function ($font) use ($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 日期 - $image->text(date('Y-m-d', strtotime($order_prescription['doctor_created_time'])), 354, 675, function ($font) use ($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 科室 - $image->text($hospital_department_custom['department_name'] ?: "", 1385, 675, function ($font) use ($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 姓名 - $image->text($order_prescription['patient_name'], 354, 795, function ($font) use ($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 性别 - $image->text(sexToStringSex($order_prescription['patient_sex']), 1385, 790, function ($font) use ($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 年龄 - $image->text($order_prescription['patient_age'], 354, 900, function ($font) use ($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 过敏史 - $image->text($order_inquiry_case['allergy_history'] ?: "无", 405, 1030, function ($font) use ($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 初步诊断 - $image->text($icd_name, 445, 1145, function ($font) use ($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 医生建议 - $image->text($order_prescription['doctor_advice'] ?: "无", 445, 1252, function ($font) use ($fontPath) { - $font->file($fontPath); - $font->size(60); - $font->align('left'); - }); - - // 商品数据 - foreach ($order_prescription_product as $key => $item) { - $x_axis = 229; - $y_axis = 1600 + $key * 250; - $x_axis_num = 1900;// 数量使用 - - // 商品名称 - $image->text($item['product_name'], $x_axis, $y_axis, function ($font) use ($fontPath) { - $font->file($fontPath); - $font->size(50); - $font->align('left'); - }); - - $image->text("X" . $item['prescription_product_num'] . $item['packaging_unit'], $x_axis_num, $y_axis, function ($font) use ($fontPath) { - $font->file($fontPath); - $font->size(50); - $font->align('left'); - }); - - // 用量 - $image->text("用量:" . $item['single_unit'] . " " . $item['frequency_use'], $x_axis, $y_axis + 70, function ($font) use ($fontPath) { - $font->file($fontPath); - $font->size(50); - $font->align('left'); - }); - - // 用法 - $image->text("用法:" . $item['single_use'], $x_axis, $y_axis + 140, function ($font) use ($fontPath) { - $font->file($fontPath); - $font->size(50); - $font->align('left'); - }); - } - - // 生成图片 - $img_result = (string)$image->encode('png', 75); - dump("处方图片生成成功"); - - // 上传处方图片至oss - $prescription_img_oss_filename = "applet/prescription/" . $order_prescription['order_prescription_id'] . '.' . 'jpg'; - $prescription_img_url = $oss->putObject($prescription_img_oss_filename, $img_result); - $prescription_img_url = '/' . $prescription_img_url; - dump("处方图片上传oss成功"); - - // 图片生成pdf - $pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8', false); - - $pdf->AddPage(); - $pdf->Image('@' . $img_result, 10, 10, 0, 0, '', '', '', false, 300, '', false, false, 0, false, false, false); - - $prescription_pdf_local_filename = $order_prescription['order_prescription_id'] . '.' . 'pdf'; - - // 图片生成的处方pdf存储为本地文件 - $pdf->Output(dirname(__DIR__, 2) . "/" . $prescription_pdf_local_filename, "F"); - - dump("处方图片生成pdf成功"); - } - - // 药师 - if ($user['user_type'] == 3) { - // 下载医生开具的处方pdf - // 去除第一个/ oss不识别 - $prescription_pdf_path = substr($order_prescription['prescription_pdf'], 1, strlen($order_prescription['prescription_pdf']) - 1); - - $local = "./runtime/" . $order_prescription['order_prescription_id'] . '.' . 'pdf'; - - $oss->getObjectToLocal($prescription_pdf_path, $local); - dump("下载医生开具的处方pdf成功"); - } - - // 下载签名图片 - $style = "image/resize,m_lfit,w_100,h_350"; - $sign_image = $oss->getCusTomObjectToRAM($sign_image_path, $style); - $sign_image = base64_encode($sign_image); - if (!$sign_image) { - throw new BusinessException("签名图片下载失败"); - } - - dump("下载签名图片成功"); - - if ($user['user_type'] == 2) { - $sign_param = [ - [ // 医生端 - "llx" => "120", // 左边底部X坐标 - "lly" => "190", // 左边底部Y坐标 - "urx" => "190", // 右边上部x坐标 - "ury" => "140", // 右边上部y坐标 - "pageList" => [1], - "sealImg" => $sign_image - ], - ]; - } else { - $sign_param = [ - [ // 药师端 - "llx" => "350", // 左边底部X坐标 - "lly" => "190", // 左边底部Y坐标 - "urx" => "440", // 右边上部x坐标 - "ury" => "140", // 右边上部y坐标 - "pageList" => [1], - "sealImg" => $sign_image - ] - ]; - } - - // 打开处方pdf文件 - $pdf_file = fopen("./runtime/" . $order_prescription['order_prescription_id'] . ".pdf", 'r'); - if (!$pdf_file) { - throw new BusinessException("处方图片打开失败"); - } - - - // 处方pdf进行签章 - $data = array(); - $data['sign_param'] = json_encode($sign_param); - $data['pdf_file'] = $pdf_file; - $sign_pdf_result = $CaOnline->addSignPdf($user_entity_id, $data); - if (empty($sign_pdf_result[0]['fileId'])) { - throw new BusinessException("处方签章失败"); - } - - dump("处方pdf进行签章成功"); - - // 下载处方签章文件 - $file_id = $sign_pdf_result[0]['fileId']; - $prescription_pdf_result = $CaOnline->getSignedFile($user_entity_id, $file_id); - - 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); - dump("处方pdf上传pss成功"); - - if ($user['user_type'] == 3) { - // 药师端时,需要进行系统签章 - // 把药师签章的pdf存储至本地文件 - $file = fopen("./runtime/" . $order_prescription['order_prescription_id'] . '.' . 'pdf', "w"); - fwrite($file, $prescription_pdf_result); - fclose($file); - - // 下载医院签名图片 - $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/" . $order_prescription['order_prescription_id'] . ".pdf", 'r'); - - // 处方pdf进行签章 - $data = array(); - $data['sign_param'] = json_encode($sign_param); - $data['pdf_file'] = $pdf_file; - $hospital_sign_pdf_result = $CaOnline->addSignPdf($hospital_entity_id, $data); - if (empty($hospital_sign_pdf_result[0]['fileId'])) { - throw new BusinessException("处方签章失败"); - } - - dump("处方pdf进行医院签章成功"); - - // 下载处方签章文件 - unset($prescription_pdf_result); - $file_id = $hospital_sign_pdf_result[0]['fileId']; - $prescription_pdf_result = $CaOnline->getSignedFile($hospital_entity_id, $file_id); - - if (empty($prescription_pdf_result)) { - throw new BusinessException("下载处方签章文件失败"); - } - - dump("下载医院处方签章文件成功"); - - // 上传oss - $hospital_filename = "applet/prescription/" . $order_prescription['order_prescription_id'] . '.' . 'pdf'; - $prescription_pdf_url = $oss->putObject($hospital_filename, $prescription_pdf_result); - dump("上传医院处方签章文件成功"); - } - - $result = array(); - $result['prescription_img_url'] = $prescription_img_url ?? $order_prescription['prescription_img']; - $result['prescription_pdf_url'] = '/' . $prescription_pdf_url ?: ""; - return $result; - - } catch (\Exception $e) { - throw new BusinessException($e->getMessage()); - } - } - - /** - * 上报处方平台 - * @param string $order_product_id 商品订单id - * @return bool - */ - public function reportPrescription(string $order_product_id): bool - { - // 获取商品订单数据 - $params = array(); - $params['order_product_id'] = $order_product_id; - $order_product = OrderProduct::getOne($params); - if (empty($order_product)) { - throw new BusinessException("上报处方平台失败:商品订单数据错误"); - } - - // 获取处方数据 - $params = array(); - $params['order_prescription_id'] = $order_product['order_prescription_id']; - $order_prescription = OrderPrescription::getOne($params); - if (empty($order_prescription)) { - throw new BusinessException("上报处方平台失败:处方数据错误"); - } - - // 获取问诊订单数据 - $params = array(); - $params['order_inquiry_id'] = $order_prescription['order_inquiry_id']; - $order_inquiry = OrderInquiry::getOne($params); - if (empty($order_inquiry)) { - throw new BusinessException("上报处方平台失败:问诊订单数据错误"); - } - - // 获取商品订单列表数据 - $params = array(); - $params['order_product_id'] = $order_product['order_product_id']; - $order_product_item = OrderProductItem::getList($params); - if (empty($order_product_item)) { - throw new BusinessException("上报处方平台失败:商品订单列表数据错误"); - } - - $wg = new WaitGroup(); - $wg->add(8); - - $user = []; // 就诊患者用户数据 - $patient_family = []; // 家庭成员-基本信息 - $order_prescription_icd = []; // 处方关联疾病数据 - $user_doctor = []; // 医生数据 - $user_doctor_info = []; // 医生详情数据 - $user_pharmacist = []; // 药师数据 - $user_pharmacist_info = []; // 药师详数据 - $order_inquiry_case = []; // 病例数据 - - $user_id = $order_inquiry['user_id']; - $doctor_id = $order_prescription['doctor_id']; - $family_id = $order_inquiry['family_id']; - $pharmacist_id = $order_prescription['pharmacist_id']; - $order_inquiry_id = $order_inquiry['order_inquiry_id']; - - // 获取就诊患者用户数据 - co(function () use ($wg, &$user, $user_id) { - $params = array(); - $params['user_id'] = $user_id; - $user = User::getOne($params)->toArray(); - // 计数器减一 - $wg->done(); - }); - - // 获取家庭成员-基本信息 - co(function () use ($wg, &$patient_family, $family_id) { - $params = array(); - $params['family_id'] = $family_id; - $patient_family = PatientFamily::getOne($params); - - // 计数器减一 - $wg->done(); - }); - - // 获取处方关联疾病数据 - $order_prescription_id = $order_prescription['order_prescription_id']; - co(function () use ($wg, &$order_prescription_icd, $order_prescription_id) { - $params = array(); - $params['order_prescription_id'] = $order_prescription_id; - $order_prescription_icd = OrderPrescriptionIcd::getList($params); - - // 计数器减一 - $wg->done(); - }); - - // 获取医生数据 - co(function () use ($wg, &$user_doctor, $doctor_id) { - $params = array(); - $params['doctor_id'] = $doctor_id; - $user_doctor = UserDoctor::getOne($params); - - // 计数器减一 - $wg->done(); - }); - - // 获取医生详情数据 - co(function () use ($wg, &$user_doctor_info, $doctor_id) { - $params = array(); - $params['doctor_id'] = $doctor_id; - $user_doctor_info = UserDoctorInfo::getOne($params); - - // 计数器减一 - $wg->done(); - }); - - // 获取药师数据 - co(function () use ($wg, &$user_pharmacist, $pharmacist_id) { - $params = array(); - $params['pharmacist_id'] = $pharmacist_id; - $user_pharmacist = UserPharmacist::getOne($params); - - // 计数器减一 - $wg->done(); - }); - - // 获取药师详情数据 - co(function () use ($wg, &$user_pharmacist_info, $pharmacist_id) { - $params = array(); - $params['pharmacist_id'] = $pharmacist_id; - $user_pharmacist_info = UserPharmacistInfo::getOne($params); - - // 计数器减一 - $wg->done(); - }); - - // 获取病例数据 - co(function () use ($wg, &$order_inquiry_case, $order_inquiry_id) { - $params = array(); - $params['order_inquiry_id'] = $order_inquiry_id; - $params['status'] = 1; - $order_inquiry_case = OrderInquiryCase::getOne($params); - - // 计数器减一 - $wg->done(); - }); - - $wg->wait(); - - if (empty($user)) { - throw new BusinessException("用户数据错误"); - } - if (empty($patient_family)) { - throw new BusinessException("用户家庭成员错误"); - } - if (empty($order_prescription_icd)) { - throw new BusinessException("处方疾病数据错误"); - } - if (empty($user_doctor)) { - throw new BusinessException("医生数据错误"); - } - if (empty($user_doctor_info)) { - throw new BusinessException("医生详情数据错误"); - } - if (empty($user_pharmacist)) { - throw new BusinessException("药师数据错误"); - } - if (empty($user_pharmacist_info)) { - throw new BusinessException("药师详情数据错误"); - } - if (empty($order_inquiry_case)) { - 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['department_custom_id'] = $user_doctor['department_custom_id']; - $hospital_department_custom = HospitalDepartmentCustom::getOne($params); - if (empty($hospital_department_custom)) { - throw new BusinessException("医生科室数据错误"); - } - - $arg = array(); - $arg['terminalCode'] = "ZD-10003"; - $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['freight'] = $order_product['logistics_fee']; // 运费(单位:元) - $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['presList'][0]['prescriptionNo'] = $order_prescription['prescription_code']; // 处方编号 - $arg['presList'][0]['prescriptionSubType'] = 1; // 处方类型 0:无类型 1:普 通处方 2:儿科处 方 - $arg['presList'][0]['patientName'] = $order_prescription['patient_name']; // 就诊人姓名 - $arg['presList'][0]['patientPhone'] = $user['mobile']; // 就诊人联系方式 - $arg['presList'][0]['idCard'] = $patient_family['id_number']; // 身份证号 - $arg['presList'][0]['advice'] = $order_prescription['doctor_advice'] ?: ""; // 医嘱 - $arg['presList'][0]['diagnosisName'] = $icd_name ?: ""; // 诊断 - $arg['presList'][0]['thirdDoctorName'] = $user_doctor['user_name']; // 开方医生姓名 - $arg['presList'][0]['thirdDeptName'] = $hospital_department_custom['department_name'] ?: ""; // 开方科室名称 - $arg['presList'][0]['thirdDoctorNameImg'] = addAliyunOssWebsite($user_doctor_info['sign_image']); // 开方医生签名链接 - $arg['presList'][0]['prescriptionTime'] = $order_prescription['doctor_created_time']; // 开方时间 - $arg['presList'][0]['thirdFirstPharmacist'] = $user_pharmacist['user_name']; // 初审药师姓名 - $arg['presList'][0]['thirdFirstPharmacistImg'] = addAliyunOssWebsite($user_pharmacist_info['sign_image']); // 初审药师签名链接 - $arg['presList'][0]['thirdFirstTime'] = $order_prescription['pharmacist_verify_time']; // 初审时间 - $arg['presList'][0]['thirdLastPharmacist'] = $user_pharmacist['user_name']; // 终审药师姓名 - $arg['presList'][0]['thirdLastPharmacistImg'] = addAliyunOssWebsite($user_pharmacist_info['sign_image']); // 终审药师签名 链接 - $arg['presList'][0]['ThirdLastTime'] = $order_prescription['pharmacist_verify_time']; // 终审时间 - $arg['presList'][0]['thirdSignImg'] = addAliyunOssWebsite("/basic/file/hospital_signature.png"); // 处方签章链接 - $arg['presList'][0]['referenceCharge'] = $order_product['amount_total']; // 处方费用(不包含运费) - $arg['presList'][0]['chiefComplaint'] = $order_inquiry_case['disease_desc'] ?: ""; // 主诉 - $arg['presList'][0]['historyPresent'] = $order_inquiry_case['disease_class_name'] ?: ""; // 现病史 - $arg['presList'][0]['pastHistory'] = $order_inquiry_case['family_history'] ?: "无"; // 既往史 - $arg['presList'][0]['physicalExamination'] = "无"; // 体格检查 - $arg['presList'][0]['supplementaryExamination'] = "无"; // 辅助检查 - $arg['presList'][0]['allergicHistory'] = $order_inquiry_case['allergy_history'] ?: "无"; // 过敏史 - - // 药品数据 - foreach ($order_product_item as $key => $item) { - // 获取商品数据 - $params = array(); - $params['product_id'] = $item['product_id']; - $product = Product::getOne($params); - if (empty($product)) { - throw new BusinessException("药品数据错误"); - } - - $arg['presList'][0]['drugList'][$key]['drugCode'] = $product['product_platform_code']; // 药品编码 - $arg['presList'][0]['drugList'][$key]['approvalNumber'] = $product['license_number']; // 批准文号 - $arg['presList'][0]['drugList'][$key]['drugName'] = $product['product_name']; // 药品名称 - $arg['presList'][0]['drugList'][$key]['specifications'] = $product['product_spec']; // 药品规格 - $arg['presList'][0]['drugList'][$key]['price'] = $product['product_price']; // 药品单价 - $arg['presList'][0]['drugList'][$key]['packingCount'] = $item['amount']; // 药品数量 - $arg['presList'][0]['drugList'][$key]['surplusPackingCount'] = 0; // 处方药品剩余使用数量 - $arg['presList'][0]['drugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位 - $arg['presList'][0]['drugList'][$key]['singleDosage'] = 1; // 单次用量 - $arg['presList'][0]['drugList'][$key]['singleDosageUnit'] = "片"; // 单次用量单位 - $arg['presList'][0]['drugList'][$key]['useName'] = $product['single_use']; // 用法名称 - $arg['presList'][0]['drugList'][$key]['frequencyName'] = $product['frequency_use']; // 频次名称 - $arg['presList'][0]['drugList'][$key]['useDays'] = $product['available_days']; // 使用天数 - - $arg['presList'][0]['orderDrugList'][$key]['drugCode'] = $product['product_platform_code']; // 药品编码 - $arg['presList'][0]['orderDrugList'][$key]['approvalNumber'] = $product['license_number']; // 批准文号 - $arg['presList'][0]['orderDrugList'][$key]['drugName'] = $product['product_name']; // 药品名称 - $arg['presList'][0]['orderDrugList'][$key]['specifications'] = $product['product_spec']; // 药品规格 - $arg['presList'][0]['orderDrugList'][$key]['price'] = $product['product_price']; // 药品单价 - $arg['presList'][0]['orderDrugList'][$key]['drugCount'] = $item['amount']; // 药品数量 - $arg['presList'][0]['orderDrugList'][$key]['packingUnit'] = $product['packaging_unit']; // 药品单位 - } - - $Prescription = new Prescription(); - $result = $Prescription->reportPrescription($arg); - if ($result['resultCode'] != "1000"){ - if(!empty($result['resultDesc'])){ - throw new BusinessException("上报处方平台失败:" .$result['resultDesc']); - } - - throw new BusinessException("上报处方平台失败:操作编码:" . $result['resultCode']); - } - - return true; - } - -} \ No newline at end of file diff --git a/app/Services/PatientDoctorService.php b/app/Services/PatientDoctorService.php index 8fbedbd..ec2d6f4 100644 --- a/app/Services/PatientDoctorService.php +++ b/app/Services/PatientDoctorService.php @@ -21,6 +21,129 @@ use Hyperf\DbConnection\Db; class PatientDoctorService extends BaseService { +// /** +// * 获取问诊医生列表 +// * 专家问诊-公益问诊共用 +// * @return array +// */ +// public function getInquiryDoctorList(): array +// { +// $expertise_id = $this->request->input('expertise_id'); +// $province_id = $this->request->input('province_id'); +// $city_id = $this->request->input('city_id'); +// $sort_order = $this->request->input('sort_order',1); +// $keyword = $this->request->input('keyword',""); +// $is_search_welfare_reception = $this->request->input('is_search_welfare_reception',0); +// $page = $this->request->input('page',1); +// $per_page = $this->request->input('per_page',10); +// +// // 组合条件 +// $hospital_params = array();// 医院搜索 +// $doctor_params = array();// 医生搜索 +// $doctor_expertise_params = array();// 医生专长搜索 +// +// // 省市区 +// if (!empty($province_id)) { +// if (empty($city_id)) { +// // 省份存在时需和城市在一块 +// return fail(HttpEnumCode::CLIENT_HTTP_ERROR); +// } +// $hospital_params[] = ['province_id', '=', $province_id]; +// $hospital_params[] = ['city_id', '=', $city_id]; +// } +// +// // 医生专长 +// if (!empty($expertise_id)) { +// $doctor_expertise_params['expertise_id'] = $expertise_id; +// } +// +// // 固定医生查询条件 +// $doctor_params['status'] = 1; // 状态(0:禁用 1:正常 2:删除) +// +// $doctor_params["iden_auth_status"] = 1;// 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) +// $doctor_params["is_bind_bank"] = 1;// 是否已绑定结算银行卡(0:否 1:是) +// +//// if (!empty($is_search_welfare_reception)){ +//// $doctor_params["is_img_welfare_reception"] = $is_search_welfare_reception;// 是否参加公益图文问诊(0:否 1:是) +//// } +// +// $fields = [ +// "doctor_id", +// "user_id", +// "user_name", +// "multi_point_status", +// "is_bind_bank", +// "is_recommend", +// "avatar", +// "doctor_title", +// "department_custom_id", +// "department_custom_name", +// "hospital_id", +// "served_patients_num", +// "praise_rate", +// "avg_response_time", +// "number_of_fans", +// "is_online", +// "be_good_at", +// ]; +// +// $user_doctors = UserDoctor::getInquiryDoctorPage($keyword,$hospital_params, $doctor_params,$doctor_expertise_params, $sort_order, $fields,$page,$per_page); +// +// if (!empty($user_doctors['data'])) { +// foreach ($user_doctors['data'] as &$user_doctor) { +// $user_doctor['doctor_title_name'] = empty($user_doctor['doctor_title']) ? "" : DoctorTitleCode::getMessage($user_doctor['doctor_title']); +// +// // 处理医生专长 +// if (!empty($user_doctor['DoctorExpertise'])) { +// foreach ($user_doctor['DoctorExpertise'] as &$data) { +// if (!empty($data['DiseaseClassExpertise'])) { +// $data['expertise_name'] = $data['DiseaseClassExpertise']['expertise_name']; +// } +// unset($data['DiseaseClassExpertise']); +// } +// } +// +// // 处理问诊价格 +// $user_doctor['price'] = 0; +// $user_doctor['free_clinic_price'] = 0; +// if (!empty($user_doctor['DoctorInquiryConfig'])) { +// foreach ($user_doctor['DoctorInquiryConfig'] as $doctor_inquiry_config) { +// if ($doctor_inquiry_config['inquiry_mode'] == 1) { +// if ($doctor_inquiry_config['inquiry_type'] == 1) { +// // 专家 +// $user_doctor['price'] = $doctor_inquiry_config['inquiry_price'] ?? 0; +// } +// if ($doctor_inquiry_config['inquiry_type'] == 3) { +// // 公益 +// $user_doctor['free_clinic_price'] = $doctor_inquiry_config['inquiry_price']; +// } +// } +// } +// } +// +// // 好评率-超过5个已结束的订单后展示 +// $user_doctor['praise_rate'] = floor($user_doctor['praise_rate'] * 0.05 * 100) / 100; +// // 响应时间-超过5个已结束的订单后展示 +// $user_doctor['avg_response_time'] = (float)floor($user_doctor['avg_response_time'] * 10) / 10; +// +// // 获取医生订单数 +// $params = array(); +// $params['doctor_id'] = $user_doctor['doctor_id']; +// $params['inquiry_status'] = 6; // 已结束 +// $inquiry_order_count = OrderInquiry::getCount($params); +// if (empty($inquiry_order_count) || $inquiry_order_count == 0) { +// $user_doctor['is_display_score'] = false; +// } else { +// $user_doctor['is_display_score'] = true; +// } +// +// // 头像 +// $user_doctor['avatar'] = addAliyunOssWebsite($user_doctor['avatar']); +// } +// } +// return success($user_doctors); +// } + /** * 获取问诊医生列表 * 专家问诊-公益问诊共用 @@ -33,12 +156,29 @@ class PatientDoctorService extends BaseService $city_id = $this->request->input('city_id'); $sort_order = $this->request->input('sort_order',1); $keyword = $this->request->input('keyword',""); - $is_search_welfare_reception = $this->request->input('is_search_welfare_reception',0); + $is_search_welfare_reception = $this->request->input('is_search_welfare_reception',0); // 是否参加公益图文问诊(0:否 1:是) $page = $this->request->input('page',1); $per_page = $this->request->input('per_page',10); // 组合条件 + $hospital_params = array();// 医院搜索 $doctor_params = array();// 医生搜索 + $doctor_expertise_params = array();// 医生专长搜索 + + // 省市区 + if (!empty($province_id)) { + if (empty($city_id)) { + // 省份存在时需和城市在一块 + return fail(HttpEnumCode::CLIENT_HTTP_ERROR); + } + $hospital_params[] = ['province_id', '=', $province_id]; + $hospital_params[] = ['city_id', '=', $city_id]; + } + + // 医生专长 + if (!empty($expertise_id)) { + $doctor_expertise_params['expertise_id'] = $expertise_id; + } // 固定医生查询条件 $doctor_params['status'] = 1; // 状态(0:禁用 1:正常 2:删除) @@ -46,8 +186,10 @@ class PatientDoctorService extends BaseService $doctor_params["iden_auth_status"] = 1;// 身份认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) $doctor_params["is_bind_bank"] = 1;// 是否已绑定结算银行卡(0:否 1:是) + // 问诊类型 + $inquiry_type = [1,3,4]; if (!empty($is_search_welfare_reception)){ - $doctor_params["is_img_welfare_reception"] = $is_search_welfare_reception;// 是否参加公益图文问诊(0:否 1:是) + $inquiry_type = [3,4]; } $fields = [ @@ -67,15 +209,11 @@ class PatientDoctorService extends BaseService "avg_response_time", "number_of_fans", "is_online", - "is_img_expert_reception", - "is_img_welfare_reception", - "is_platform_deep_cooperation", "be_good_at", ]; - $user_doctors = UserDoctor::getInquiryDoctorPage($keyword, $doctor_params, $sort_order, $fields,$page,$per_page); + $user_doctors = UserDoctor::getInquiryDoctorPage($keyword,$hospital_params, $doctor_params,$doctor_expertise_params,$inquiry_type, $sort_order, $fields,$page,$per_page); - // 处理数据 if (!empty($user_doctors['data'])) { foreach ($user_doctors['data'] as &$user_doctor) { $user_doctor['doctor_title_name'] = empty($user_doctor['doctor_title']) ? "" : DoctorTitleCode::getMessage($user_doctor['doctor_title']); @@ -93,20 +231,24 @@ class PatientDoctorService extends BaseService // 处理问诊价格 $user_doctor['price'] = 0; $user_doctor['free_clinic_price'] = 0; + $user_doctor['multi_point_enable'] = 0; if (!empty($user_doctor['DoctorInquiryConfig'])) { foreach ($user_doctor['DoctorInquiryConfig'] as $doctor_inquiry_config) { if ($doctor_inquiry_config['inquiry_mode'] == 1) { - if ($doctor_inquiry_config['inquiry_type'] == 1) { + if ($doctor_inquiry_config['inquiry_type'] == 1 && $doctor_inquiry_config['is_enable'] == 1) { // 专家 $user_doctor['price'] = $doctor_inquiry_config['inquiry_price'] ?? 0; } - if ($doctor_inquiry_config['inquiry_type'] == 3) { + if ($doctor_inquiry_config['inquiry_type'] == 3 && $doctor_inquiry_config['is_enable'] == 1) { // 公益 $user_doctor['free_clinic_price'] = $doctor_inquiry_config['inquiry_price']; } + if ($doctor_inquiry_config['inquiry_type'] == 4 && $doctor_inquiry_config['is_enable'] == 1) { + // 问诊购药 + $user_doctor['multi_point_enable'] = 1; + } } } - unset($user_doctor['DoctorInquiryConfig']); } // 好评率-超过5个已结束的订单后展示 @@ -163,9 +305,6 @@ class PatientDoctorService extends BaseService "avg_response_time", "number_of_fans", "is_online", - "is_img_expert_reception", - "is_img_welfare_reception", - "is_platform_deep_cooperation", "be_good_at", "brief_introduction", ]; @@ -218,21 +357,15 @@ class PatientDoctorService extends BaseService $params['doctor_id'] = $doctor_id; $result['follow'] = PatientFollow::getExists($params); + // 获取医生问诊配置-问诊购药 + $result['multi_point_enable'] = 0; + // 获取问诊价格 // 专家-公益 $params = array(); $params[] = ['doctor_id', '=', $doctor_id]; $params[] = ['inquiry_mode', '=', 1];// 接诊方式(1:图文 2:视频 3:语音 4:电话 5:会员) - - $inquiry_type_in_params = array(); - if ($user_doctor['is_img_expert_reception'] == 1){ - $inquiry_type_in_params[] = 1; - } - if ($user_doctor['is_img_welfare_reception'] == 1){ - $inquiry_type_in_params[] = 3; - } - - $doctor_inquiry_config = DoctorInquiryConfigModel::getInquiryConfigList($params,['*'],$inquiry_type_in_params); + $doctor_inquiry_config = DoctorInquiryConfigModel::getInquiryConfigListByInquiryType($params,['*'],[1,3,4]); if (!empty($doctor_inquiry_config)) { foreach ($doctor_inquiry_config as &$value) { // 获取医生当日的全部订单 @@ -270,6 +403,9 @@ class PatientDoctorService extends BaseService $value['times_number'] = $system_inquiry_config['times_number']; $value['duration'] = $system_inquiry_config['duration']; + if ($value['is_enable'] == 1 && $value['inquiry_type'] == 4 && $value['inquiry_mode'] == 1){ + $result['multi_point_enable'] = 1; + } unset($system_inquiry_config); } $result['doctor_inquiry_config'] = $doctor_inquiry_config; @@ -416,6 +552,20 @@ class PatientDoctorService extends BaseService return fail(HttpEnumCode::HTTP_ERROR,"医生暂不可接诊"); } + // 获取医生问诊配置 + $params = array(); + $params['doctor_id'] = $user_doctor['doctor_id']; + $params['inquiry_type'] = $inquiry_type; + $params['inquiry_mode'] = 1; + $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); + if (empty($doctor_inquiry_config)){ + return fail(HttpEnumCode::HTTP_ERROR,"医生暂不可接诊"); + } + + if ($doctor_inquiry_config['is_enable'] == 0){ + return fail(HttpEnumCode::HTTP_ERROR,"医生暂不可接诊"); + } + // 检测当前医生是否和患者存在未完成问诊订单 $InquiryService = new InquiryService(); $order_inquiry = $InquiryService->checkPatientDoctorProgressInquiry($user_info['client_user_id'],$doctor_id); @@ -497,7 +647,7 @@ class PatientDoctorService extends BaseService /** * 获取我的问诊、关注医生列表 - * @return array|void + * @return array */ public function getDoctorList(){ $user_info = $this->request->getAttribute("userInfo") ?? []; @@ -544,6 +694,20 @@ class PatientDoctorService extends BaseService // 职称 $data['user_doctor']['doctor_title_name'] = empty($data['user_doctor']['doctor_title']) ? "" : DoctorTitleCode::getMessage($data['user_doctor']['doctor_title']); + // 医生问诊配置-问诊购药 + $data['user_doctor']['multi_point_enable'] = 0; + + $params = array(); + $params['doctor_id'] = $data['user_doctor']['doctor_id']; + $params['inquiry_type'] = 4; + $params['inquiry_mode'] = 1; + $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); + if (!empty($doctor_inquiry_config)){ + if ($doctor_inquiry_config['is_enable'] == 1){ + $data['user_doctor']['multi_point_enable'] = 1; + } + } + $item = $data; } } @@ -573,8 +737,6 @@ class PatientDoctorService extends BaseService "department_custom_name", "hospital_id", "is_online", - "is_img_expert_reception", - "is_img_welfare_reception", "be_good_at", ]; @@ -594,11 +756,10 @@ class PatientDoctorService extends BaseService $data['doctor_title'] = empty($recommend_doctor['doctor_title']) ? "" : DoctorTitleCode::getMessage($recommend_doctor['doctor_title']); $data['department_custom_name'] = $recommend_doctor['department_custom_name']; $data['is_online'] = $recommend_doctor['is_online']; - $data['is_img_expert_reception'] = $recommend_doctor['is_img_expert_reception']; - $data['is_img_welfare_reception'] = $recommend_doctor['is_img_welfare_reception']; $data['be_good_at'] = $recommend_doctor['be_good_at']; $data['hospital_name'] = $recommend_doctor['Hospital']['hospital_name'] ?? ""; $data['hospital_level_name'] = $recommend_doctor['Hospital']['hospital_level_name'] ?? ""; + $data['multi_point_enable'] = 0; // 是否开启问诊购药 // 处理接诊价格 $data['price'] = 0; @@ -614,9 +775,15 @@ class PatientDoctorService extends BaseService // 公益 $data['free_clinic_price'] = $doctor_inquiry_config['inquiry_price']; } + + if ($doctor_inquiry_config['inquiry_type'] == 4 && $doctor_inquiry_config['is_enable'] == 1) { + $data['multi_point_enable'] = 1; // 是否开启问诊购药 + } } } + $data['doctor_inquiry_config'] = $recommend_doctor['DoctorInquiryConfig']; + $results[] = $data; unset($data); diff --git a/app/Services/PatientFamilyService.php b/app/Services/PatientFamilyService.php index 9aa2176..a67193d 100644 --- a/app/Services/PatientFamilyService.php +++ b/app/Services/PatientFamilyService.php @@ -42,6 +42,8 @@ class PatientFamilyService extends BaseService 'card_name_mask', 'sex', 'age', + 'nation_id', + 'nation_name', ]; $patient_familys = PatientFamilyModel::getList($params, $field); diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index b89c71a..bf48948 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -4,10 +4,14 @@ namespace App\Services; use App\Amqp\Producer\AssignDoctorDelayDirectProducer; use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer; +use App\Amqp\Producer\DoctorNotYetInquiryDelayDirectProducer; use App\Constants\DoctorTitleCode; use App\Constants\HttpEnumCode; use App\Model\BasicLogisticsCompany; +use App\Model\DetectionProject; +use App\Model\DoctorInquiryConfig; use App\Model\Hospital; +use App\Model\OrderDetection; use App\Model\OrderInquiry; use App\Model\OrderInquiryCase; use App\Model\OrderInquiryCoupon; @@ -194,11 +198,11 @@ class PatientOrderService extends BaseService $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; $order_inquiry_case = OrderInquiryCase::getOne($params, $fields); if (empty($order_inquiry_case)) { - return fail(); + $order_inquiry['case'] = []; + }else{ + $order_inquiry['case'] = $order_inquiry_case->toArray(); } - $order_inquiry['case'] = $order_inquiry_case->toArray(); - // 获取医生数据 $order_inquiry['user_doctor'] = []; if (!empty($order_inquiry['doctor_id'])) { @@ -250,10 +254,22 @@ class PatientOrderService extends BaseService $params['doctor_id'] = $user_doctor['doctor_id']; $user_doctor['follow'] = PatientFollow::getExists($params); + // 获取医生问诊配置-问诊购药 + $user_doctor['multi_point_enable'] = 0; + + $params = array(); + $params['doctor_id'] = $user_doctor['doctor_id']; + $params['inquiry_type'] = 4; + $params['inquiry_mode'] = 1; + $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); + if (!empty($doctor_inquiry_config)){ + if ($doctor_inquiry_config['is_enable'] == 1){ + $user_doctor['multi_point_enable'] = 1; + } + } + $order_inquiry['user_doctor'] = $user_doctor; - - unset($hospital); unset($user_doctor); } @@ -285,12 +301,12 @@ class PatientOrderService extends BaseService $redis = $this->container->get(Redis::class); $redis_key = "order_inquiry_lock_" . $order_inquiry_id; - $redis_lock = $redis->setnx($redis_key,1); + $redis_lock = $redis->setnx($redis_key, 1); // 设置过期时间 - $redis->expire($redis_key,3); - if (!$redis_lock){ + $redis->expire($redis_key, 3); + if (!$redis_lock) { // 设置失败,表示已经设置该值 - return fail(HttpEnumCode::HTTP_SUCCESS,"请您稍后重试"); + return fail(HttpEnumCode::HTTP_SUCCESS, "请您稍后重试"); } // 检测订单状态 @@ -342,31 +358,31 @@ class PatientOrderService extends BaseService } try { - if (!empty($order_inquiry['doctor_id'])){ + if (!empty($order_inquiry['doctor_id'])) { // 获取医生数据 $params = array(); $params['doctor_id'] = $order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ + if (empty($user_doctor)) { Db::rollBack(); - return fail(HttpEnumCode::SERVER_ERROR,"取消失败"); + return fail(HttpEnumCode::SERVER_ERROR, "取消失败"); } // 推送医生-患者取消问诊 - $MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']); + $MessagePush = new MessagePush($user_doctor['user_id'], $order_inquiry['order_inquiry_id']); $MessagePush->patientCancelInquiryToDoctor(); // 获取用户优惠卷信息 $params = array(); $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; $order_inquiry_coupon = OrderInquiryCoupon::getOne($params); - if (!empty($order_inquiry_coupon)){ + if (!empty($order_inquiry_coupon)) { // 发送站内消息-优惠卷退还 $MessagePush = new MessagePush($order_inquiry['user_id'], $order_inquiry['order_inquiry_id']); $MessagePush->patientRefundCoupon($order_inquiry_coupon['coupon_name']); } } - }catch(\Exception $e){ + } catch (\Exception $e) { return success(); } @@ -442,7 +458,7 @@ class PatientOrderService extends BaseService $InquiryService = new InquiryService(); $result = $InquiryService->cancelUnpayInquiryOrder($order_inquiry['inquiry_no'], 2, "主动取消"); - if ($result['status'] != 1){ + if ($result['status'] != 1) { Db::rollBack(); return fail(); } @@ -503,7 +519,7 @@ class PatientOrderService extends BaseService $order_product = OrderProduct::getPatientOrderProductPage($params, $fields, $page, $per_page); - if (!empty($order_product['data'])){ + if (!empty($order_product['data'])) { foreach ($order_product['data'] as $item) { foreach ($item['orderProductItem'] as &$product_item) { $product_item['product_cover_img'] = addAliyunOssWebsite($product_item['product_cover_img']); @@ -567,6 +583,20 @@ class PatientOrderService extends BaseService } $user_doctor['avatar'] = addAliyunOssWebsite($user_doctor['avatar']); + + // 获取医生问诊配置-问诊购药 + $user_doctor['multi_point_enable'] = 0; + + $params = array(); + $params['doctor_id'] = $user_doctor['doctor_id']; + $params['inquiry_type'] = 4; + $params['inquiry_mode'] = 1; + $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); + if (!empty($doctor_inquiry_config)){ + if ($doctor_inquiry_config['is_enable'] == 1){ + $user_doctor['multi_point_enable'] = 1; + } + } } $result = array(); @@ -602,8 +632,8 @@ class PatientOrderService extends BaseService } $OrderProductService = new OrderProductService(); - $result = $OrderProductService->cancelUnpayProductOrder($order_product['order_product_no'],1,"主动取消"); - if ($result['status'] != 1){ + $result = $OrderProductService->cancelUnpayProductOrder($order_product['order_product_no'], 1, "主动取消"); + if ($result['status'] != 1) { Db::rollBack(); return fail(); } @@ -677,13 +707,13 @@ class PatientOrderService extends BaseService // 获取订单金额 $result = array(); - $result['amount_total'] = 0; // 订单金额 + $result['amount_total'] = 0; // 订单总额 $result['payment_amount_total'] = 0; // 实际订单金额 $result['coupon_amount_total'] = 0; // 优惠金额 $result['order_no'] = $order_no; // 订单编号 $result['order_id'] = ""; // 订单主键id(问诊订单:order_inquiry_id 药品订单:order_product_id) $result['created_at'] = ""; // 创建时间 - $result['inquiry_type'] = 0; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) + $result['inquiry_type'] = 0; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测) $result['pay_config'] = []; // 小程序支付配置 if ($order_type == 1) { @@ -699,27 +729,31 @@ class PatientOrderService extends BaseService // 验证订单状态 if ($order_inquiry['inquiry_status'] != 1) { $return_result['message'] = "订单状态错误"; - $return_result['data']['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; - $return_result['data']['inquiry_status'] = $order_inquiry['inquiry_status']; - $return_result['data']['inquiry_pay_status'] = $order_inquiry['inquiry_pay_status']; + $return_result['data'] = $result; + $return_result['data']['order_id'] = $order_inquiry['order_inquiry_id']; + $return_result['data']['order_status'] = $order_inquiry['inquiry_status']; + $return_result['data']['order_pay_status'] = $order_inquiry['inquiry_pay_status']; + return success($return_result); } // 验证订单支付状态 if ($order_inquiry['inquiry_pay_status'] != 1) { $return_result['message'] = "订单支付状态错误"; - $return_result['data']['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; - $return_result['data']['inquiry_status'] = $order_inquiry['inquiry_status']; - $return_result['data']['inquiry_pay_status'] = $order_inquiry['inquiry_pay_status']; + $return_result['data'] = $result; + $return_result['data']['order_id'] = $order_inquiry['order_inquiry_id']; + $return_result['data']['order_status'] = $order_inquiry['inquiry_status']; + $return_result['data']['order_pay_status'] = $order_inquiry['inquiry_pay_status']; return success($return_result); } // 验证订单过期支付时间 $diff_time = (strtotime($order_inquiry['created_at']) - time()) / 60; - if ($diff_time >= 30){ + if ($diff_time >= 30) { $return_result['message'] = "订单已过期"; - $return_result['data']['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; - $return_result['data']['inquiry_status'] = $order_inquiry['inquiry_status']; - $return_result['data']['inquiry_pay_status'] = $order_inquiry['inquiry_pay_status']; + $return_result['data'] = $result; + $return_result['data']['order_id'] = $order_inquiry['order_inquiry_id']; + $return_result['data']['order_status'] = $order_inquiry['inquiry_status']; + $return_result['data']['order_pay_status'] = $order_inquiry['inquiry_pay_status']; return success($return_result); } @@ -732,13 +766,13 @@ class PatientOrderService extends BaseService $result['payment_amount_total'] = $order_inquiry['payment_amount_total']; // 实际订单金额 $result['coupon_amount_total'] = $order_inquiry['coupon_amount_total'];; // 优惠金额 - if ($order_inquiry['payment_amount_total'] > 0){ + if ($order_inquiry['payment_amount_total'] > 0) { // 发起支付 - $WechatPay = new WechatPay(1,1); + $WechatPay = new WechatPay(1, 1); // 获取预支付交易会话标识 - $prepay = $WechatPay->getJsapiPrepayId($order_no, (int)round($order_inquiry['payment_amount_total'] * 100), $user_info['open_id']); + $prepay = $WechatPay->getJsapiPrepayId($order_no, (int)round($order_inquiry['payment_amount_total'] * 100), $user_info['open_id'], "问诊服务"); if (empty($prepay)) { return fail(HttpEnumCode::SERVER_ERROR); } @@ -759,28 +793,31 @@ class PatientOrderService extends BaseService // 验证订单状态 if ($order_product['order_product_status'] != 1) { $return_result['message'] = "订单状态错误"; - $return_result['data']['order_product_id'] = $order_product['order_product_id']; - $return_result['data']['order_product_status'] = $order_product['order_product_status']; - $return_result['data']['pay_status'] = $order_product['pay_status']; + $return_result['data'] = $result; + $return_result['data']['order_id'] = $order_product['order_product_id']; + $return_result['data']['order_status'] = $order_product['order_product_status']; + $return_result['data']['order_pay_status'] = $order_product['pay_status']; return success($return_result); } // 验证订单支付状态 if ($order_product['pay_status'] != 1) { $return_result['message'] = "订单支付状态错误"; + $return_result['data'] = $result; $return_result['data']['order_product_id'] = $order_product['order_product_id']; $return_result['data']['order_product_status'] = $order_product['order_product_status']; - $return_result['data']['pay_status'] = $order_product['pay_status']; + $return_result['data']['order_pay_status'] = $order_product['pay_status']; return success($return_result); } // 验证订单过期支付时间 $diff_time = (strtotime($order_product['created_at']) - time()) / 60; - if ($diff_time >= 30){ + if ($diff_time >= 30) { $return_result['message'] = "订单已过期"; + $return_result['data'] = $result; $return_result['data']['order_product_id'] = $order_product['order_product_id']; $return_result['data']['order_product_status'] = $order_product['order_product_status']; - $return_result['data']['pay_status'] = $order_product['pay_status']; + $return_result['data']['order_pay_status'] = $order_product['pay_status']; return success($return_result); } @@ -792,12 +829,75 @@ class PatientOrderService extends BaseService $result['payment_amount_total'] = $order_product['payment_amount_total']; // 实际订单金额 $result['coupon_amount_total'] = 0; // 优惠金额 - if ($order_product['payment_amount_total'] > 0 ){ + if ($order_product['payment_amount_total'] > 0) { // 发起支付 - $WechatPay = new WechatPay(1,2); + $WechatPay = new WechatPay(1, 2); // 获取预支付交易会话标识 - $prepay = $WechatPay->getJsapiPrepayId($order_no, (int)round($order_product['payment_amount_total'] * 100), $user_info['open_id']); + $prepay = $WechatPay->getJsapiPrepayId($order_no, (int)round($order_product['payment_amount_total'] * 100), $user_info['open_id'], "问诊服务"); + if (empty($prepay)) { + return fail(HttpEnumCode::SERVER_ERROR); + } + + // 获取小程序支付配置 + $pay_config = $WechatPay->getAppletsPayConfig($prepay['prepay_id']); + } + } elseif ($order_type == 3) { + // 检测订单 + // 获取检测订单数据 + $params = array(); + $params['detection_no'] = $order_no; + $params['patient_id'] = $user_info['client_user_id']; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)) { + return fail(HttpEnumCode::HTTP_ERROR, "非法订单"); + } + + // 验证订单状态 + if ($order_detection['detection_status'] != 1) { + $return_result['message'] = "订单状态错误"; + $return_result['data'] = $result; + $return_result['data']['order_id'] = $order_detection['order_detection_id']; + $return_result['data']['order_status'] = $order_detection['detection_status']; + $return_result['data']['order_pay_status'] = $order_detection['detection_pay_status']; + return success($return_result); + } + + // 验证订单支付状态 + if ($order_detection['detection_pay_status'] != 1) { + $return_result['message'] = "订单支付状态错误"; + $return_result['data'] = $result; + $return_result['data']['order_id'] = $order_detection['order_detection_id']; + $return_result['data']['order_status'] = $order_detection['detection_status']; + $return_result['data']['order_pay_status'] = $order_detection['detection_pay_status']; + return success($return_result); + } + + // 验证订单过期支付时间 + $diff_time = (strtotime($order_detection['created_at']) - time()) / 60; + if ($diff_time >= 30) { + $return_result['message'] = "订单已过期"; + $return_result['data'] = $result; + $return_result['data']['order_id'] = $order_detection['order_detection_id']; + $return_result['data']['order_status'] = $order_detection['detection_status']; + $return_result['data']['order_pay_status'] = $order_detection['detection_pay_status']; + return success($return_result); + } + + $result['order_id'] = $order_detection['order_detection_id']; + $result['created_at'] = $order_detection['created_at']; + + // 获取订单金额 + $result['amount_total'] = $order_detection['amount_total']; // 订单金额 + $result['payment_amount_total'] = $order_detection['amount_total'] - 0; // 实际订单金额 + $result['coupon_amount_total'] = 0; // 优惠金额 + + if ($order_detection['payment_amount_total'] > 0) { + // 发起支付 + $WechatPay = new WechatPay(1, 3); + + // 获取预支付交易会话标识 + $prepay = $WechatPay->getJsapiPrepayId($order_no, (int)round($order_detection['payment_amount_total'] * 100), $user_info['open_id'], "检测服务"); if (empty($prepay)) { return fail(HttpEnumCode::SERVER_ERROR); } @@ -843,15 +943,24 @@ class PatientOrderService extends BaseService return fail(HttpEnumCode::HTTP_ERROR, "非法订单"); } + // 获取病例数据 + $params = array(); + $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + $order_inquiry_case = OrderInquiryCase::getOne($params); + if (empty($order_inquiry_case)){ + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, "患者病例错误"); + } + // 验证订单状态 - if ($order_inquiry['inquiry_status'] != 1){ + if ($order_inquiry['inquiry_status'] != 1) { Db::rollBack(); // 问诊订单状态(1:待支付 2:待分配 3:待接诊 4:已接诊 5:已完成 6:已结束 7:已取消) return fail(HttpEnumCode::HTTP_ERROR, "支付失败"); } // 验证支付金额 - if ($order_inquiry['payment_amount_total'] != 0){ + if ($order_inquiry['payment_amount_total'] != 0) { Db::rollBack(); return fail(HttpEnumCode::HTTP_ERROR, "支付失败"); } @@ -862,22 +971,22 @@ class PatientOrderService extends BaseService $data = array(); $data['inquiry_pay_channel'] = 3; // 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付) $data['inquiry_pay_status'] = 2; - if ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3){ + if ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3) { // 专家-公益 $data['inquiry_status'] = 3;// 3:待接诊 - }elseif ($order_inquiry['inquiry_type'] == 2 || $order_inquiry['inquiry_type'] == 4){ + } elseif ($order_inquiry['inquiry_type'] == 2 || $order_inquiry['inquiry_type'] == 4) { // 快速-购药 $data['inquiry_status'] = 2;// 2:待分配 } $data['escrow_trade_no'] = "GD" . $generator->generate(); // 第三方支付流水号 - $data['pay_time'] = date('Y-m-d H:i:s',time());// 支付时间 - $data['updated_at'] = date('Y-m-d H:i:s',time()); + $data['pay_time'] = date('Y-m-d H:i:s', time());// 支付时间 + $data['updated_at'] = date('Y-m-d H:i:s', time()); $params = array(); $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; - OrderInquiry::edit($params,$data); + OrderInquiry::edit($params, $data); - if ($order_inquiry['inquiry_type'] == 2 || $order_inquiry['inquiry_type'] == 4){ + if ($order_inquiry['inquiry_type'] == 2 || $order_inquiry['inquiry_type'] == 4) { // 快速-购药 // 加入分配医生队列 $data = array(); @@ -891,32 +1000,44 @@ class PatientOrderService extends BaseService Db::rollBack(); return fail(HttpEnumCode::HTTP_ERROR, "分配医生失败"); } - }elseif ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3){ + } elseif ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3) { // 专家-公益,发送im消息 // 获取订单医生数据 $params = array(); $params['doctor_id'] = $order_inquiry['doctor_id']; $user_doctor = UserDoctor::getOne($params); - if (empty($user_doctor)){ + if (empty($user_doctor)) { Db::rollBack(); return fail(HttpEnumCode::HTTP_ERROR, "医生数据错误"); } - // 发送IM消息-等待医生接诊 + // 发送im消息 $imService = new ImService(); - $imService->waitDoctorInquiry($order_inquiry,$user_doctor['user_id'],$order_inquiry['user_id']); + + // 等待医生接诊 + $imService->waitDoctorInquiry($order_inquiry, $user_doctor['user_id'], $order_inquiry['user_id']); // 发送站内、订阅失败发送短信消息-医生有新问诊 - $MessagePush = new MessagePush($user_doctor['user_id'],$order_inquiry['order_inquiry_id']); + $MessagePush = new MessagePush($user_doctor['user_id'], $order_inquiry['order_inquiry_id']); $MessagePush->doctorHaveNewInquiry(); + // 加入xx时间未接诊通知队列 + $data = array(); + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + + $time = 1000 * 60 * 60 * 2; + $message = new DoctorNotYetInquiryDelayDirectProducer($data); + $message->setDelayMs($time); + $producer = $this->container->get(Producer::class); + $producer->produce($message); + Log::getInstance()->info("发送im消息成功"); } Db::commit(); } catch (\Exception $e) { Db::rollBack(); - return fail(HttpEnumCode::SERVER_ERROR,$e->getMessage()); + return fail(HttpEnumCode::SERVER_ERROR, $e->getMessage()); } return success(); @@ -1009,15 +1130,15 @@ class PatientOrderService extends BaseService return fail(HttpEnumCode::HTTP_ERROR, "存在库存不足商品", $not_enough_product_ids); } - $app_env = config('app_env','prod'); - if ($app_env != "dev"){ + $app_env = config('app_env', 'prod'); + if ($app_env != "dev") { // 获取运费金额 $Prescription = new Prescription(); $result = $Prescription->getLogisticsFee(); - if ($amount_total >= $result['drugCost']){ + if ($amount_total >= $result['drugCost']) { $logistics_fee = 0; - }else{ + } else { $logistics_fee = $result['freight']; } @@ -1025,7 +1146,7 @@ class PatientOrderService extends BaseService $payment_amount_total = $amount_total + $logistics_fee; } - if ($app_env == "dev"){ + if ($app_env == "dev") { $logistics_fee = 0; $payment_amount_total = 0.01; } @@ -1096,7 +1217,7 @@ class PatientOrderService extends BaseService $params = array(); $params['product_platform_code'] = $product['product_platform_code']; $product_platform_amount = ProductPlatformAmount::getSharedLockOne($params); - if (empty($product_platform_amount)){ + if (empty($product_platform_amount)) { Db::rollBack(); return fail(HttpEnumCode::HTTP_ERROR, "无商品库存数据"); } @@ -1184,7 +1305,7 @@ class PatientOrderService extends BaseService $params['order_product_id'] = $order_product_id; $params['patient_id'] = $user_info['client_user_id']; $order_product = OrderProduct::getOne($params); - if (empty($order_product)){ + if (empty($order_product)) { return fail(); } @@ -1211,14 +1332,14 @@ class PatientOrderService extends BaseService $params = array(); $params['order_product_id'] = $order_product_id; $order_product_logistics = OrderProductLogistic::getOne($params); - if (empty($order_product_logistics)){ - if (!empty($order_product['logistics_no']) && !empty($order_product['logistics_company_code'])){ + if (empty($order_product_logistics)) { + if (!empty($order_product['logistics_no']) && !empty($order_product['logistics_company_code'])) { // 获取快递公司名称 $params = array(); $params['company_code'] = $order_product['logistics_company_code']; $params['company_type'] = 1; $basic_logistics_company = BasicLogisticsCompany::getOne($params); - if (!empty($basic_logistics_company)){ + if (!empty($basic_logistics_company)) { $logistics = array(); $logistics['order_product_id'] = $order_product_id; $logistics['company_name'] = $basic_logistics_company['company_name']; @@ -1227,10 +1348,10 @@ class PatientOrderService extends BaseService $result['logistics'] = $logistics; } } - }else{ + } else { $order_product_logistics = $order_product_logistics->toArray(); - $order_product_logistics['logistics_content'] = json_decode($order_product_logistics['logistics_content'],true); + $order_product_logistics['logistics_content'] = json_decode($order_product_logistics['logistics_content'], true); $result['logistics'] = $order_product_logistics; } return success($result); @@ -1296,7 +1417,7 @@ class PatientOrderService extends BaseService $params = array(); $params['order_prescription_id'] = $order_prescription_id; $order_prescription_file = OrderPrescriptionFile::getOne($params); - if (empty($order_prescription_file)){ + if (empty($order_prescription_file)) { return fail(); } @@ -1306,7 +1427,7 @@ class PatientOrderService extends BaseService $params = array(); $params['doctor_id'] = $order_prescription['doctor_id']; $user_doctor_info = UserDoctorInfo::getOne($params); - if (empty($user_doctor_info)){ + if (empty($user_doctor_info)) { return fail(HttpEnumCode::SERVER_ERROR); } $order_prescription['doctor_sign_image'] = addAliyunOssWebsite($user_doctor_info['sign_image']); @@ -1315,7 +1436,7 @@ class PatientOrderService extends BaseService $params = array(); $params['pharmacist_id'] = $order_prescription['pharmacist_id']; $user_pharmacist_info = UserPharmacistInfo::getOne($params); - if (empty($user_pharmacist_info)){ + if (empty($user_pharmacist_info)) { return fail(HttpEnumCode::SERVER_ERROR); } $order_prescription['pharmacist_sign_image'] = addAliyunOssWebsite($user_pharmacist_info['sign_image']); @@ -1396,18 +1517,18 @@ class PatientOrderService extends BaseService // 获取运费金额 $logistics_fee = 0; - if (env("APP_ENV") == "prod"){ + if (env("APP_ENV") == "prod") { $Prescription = new Prescription(); $result = $Prescription->getLogisticsFee(); - if ($amount_total < $result['drugCost']){ + if ($amount_total < $result['drugCost']) { $logistics_fee = $result['freight']; } } // 实际支付金额 - if (env("APP_ENV") == "dev"){ + if (env("APP_ENV") == "dev") { $payment_amount_total = 0.01; - }else{ + } else { $payment_amount_total = $amount_total + $logistics_fee; } @@ -1476,6 +1597,398 @@ class PatientOrderService extends BaseService return success(); } + /** + * 获取患者检测订单列表 + * @return array + */ + public function getPatientDetectionOrderList(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $detection_status = $this->request->input('detection_status', 0); + $family_id = $this->request->input('family_id'); + $page = $this->request->input('page', 1); + $per_page = $this->request->input('per_page', 10); + + $params = array(); + $params['patient_id'] = $user_info['client_user_id']; + if (!empty($family_id)) { + $params['family_id'] = $family_id; + } + + $detection_status_params = []; + if (!empty($detection_status) && $detection_status != 0) { + // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + $detection_status_params = [$detection_status]; + } + + $params['is_delete'] = 0; + + $fields = [ + 'order_detection_id', + 'patient_id', + 'doctor_id', + 'family_id', + 'detection_status', + 'is_delete', + 'detection_refund_status', + 'detection_pay_channel', + 'detection_pay_status', + 'detection_no', + 'escrow_trade_no', + 'amount_total', + 'payment_amount_total', + 'patient_name', + 'patient_name_mask', + 'patient_sex', + 'patient_age', + 'created_at', + ]; + $order_detection = OrderDetection::getPatientOrderDetectionPage($params, $detection_status_params, $fields, $page, $per_page); + if (empty($order_detection['data'])) { + return success($order_detection); + } + + foreach ($order_detection['data'] as &$item) { + // 获取医生数据 + $item['user_doctor'] = []; + if (!empty($item['doctor_id'])) { + $fields = [ + 'doctor_id', + 'user_name', + 'doctor_title', + 'hospital_id', + "avatar" + ]; + + $params = array(); + $params['doctor_id'] = $item['doctor_id']; + $user_doctor = UserDoctor::getOne($params, $fields); + if (empty($user_doctor)) { + return fail(HttpEnumCode::SERVER_ERROR); + } + + // 转换医生职称 + $user_doctor['doctor_title'] = empty($user_doctor['doctor_title']) ? "" : DoctorTitleCode::getMessage($user_doctor['doctor_title']); + + // 获取医生医院名称 + $user_doctor['hospital_name'] = ""; + $user_doctor['hospital_level_name'] = ""; + + // 医生头像 + $user_doctor['avatar'] = addAliyunOssWebsite($user_doctor['avatar']); + + $fields = [ + 'hospital_id', + 'hospital_name', + 'hospital_level_name', + ]; + + $params = array(); + $params['hospital_id'] = $user_doctor['hospital_id']; + $hospital = Hospital::getOne($params, $fields); + if (!empty($hospital)) { + $user_doctor['hospital_name'] = $hospital['hospital_name']; + $user_doctor['hospital_level_name'] = $hospital['hospital_level_name']; + } + + $item['user_doctor'] = $user_doctor; + unset($hospital); + unset($user_doctor); + } + } + + return success($order_detection); + } + + /** + * 获取患者检测订单详情 + * @return array + */ + public function getPatientDetectionOrderInfo(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $order_no = $this->request->route('order_no'); + + // 获取订单数据 + $params = array(); + $params['patient_id'] = $user_info['client_user_id']; + $params['detection_no'] = $order_no; + $params['is_delete'] = 0; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)) { + return fail(); + } + + $order_detection = $order_detection->toArray(); + + // 获取医生数据 + $order_detection['user_doctor'] = []; + if (!empty($order_detection['doctor_id'])) { + $fields = [ + 'user_id', + 'doctor_id', + 'user_name', + 'doctor_title', + 'hospital_id', + 'avatar', + 'department_custom_name', + 'multi_point_status', + ]; + + $params = array(); + $params['doctor_id'] = $order_detection['doctor_id']; + $user_doctor = UserDoctor::getOne($params, $fields); + if (empty($user_doctor)) { + return fail(HttpEnumCode::SERVER_ERROR); + } + + // 转换医生职称 + $user_doctor['doctor_title'] = empty($user_doctor['doctor_title']) ? "" : DoctorTitleCode::getMessage($user_doctor['doctor_title']); + + // 头像 + $user_doctor['avatar'] = addAliyunOssWebsite($user_doctor['avatar']); + + // 获取医生医院名称 + $user_doctor['hospital_name'] = ""; + $user_doctor['hospital_level_name'] = ""; + + $fields = [ + 'hospital_id', + 'hospital_name', + 'hospital_level_name', + ]; + + $params = array(); + $params['hospital_id'] = $user_doctor['hospital_id']; + $hospital = Hospital::getOne($params, $fields); + if (!empty($hospital)) { + $user_doctor['hospital_name'] = $hospital['hospital_name']; + $user_doctor['hospital_level_name'] = $hospital['hospital_level_name']; + } + + // 获取医生关注状态 + $params = array(); + $params['patient_id'] = $user_info['client_user_id']; + $params['doctor_id'] = $user_doctor['doctor_id']; + $user_doctor['follow'] = PatientFollow::getExists($params); + + // 获取医生问诊配置-问诊购药 + $user_doctor['multi_point_enable'] = 0; + + $params = array(); + $params['doctor_id'] = $user_doctor['doctor_id']; + $params['inquiry_type'] = 4; + $params['inquiry_mode'] = 1; + $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); + if (!empty($doctor_inquiry_config)){ + if ($doctor_inquiry_config['is_enable'] == 1){ + $user_doctor['multi_point_enable'] = 1; + } + } + + $order_detection['user_doctor'] = $user_doctor; + + unset($hospital); + unset($user_doctor); + } + + // 检测管图片 + if (!empty($order_detection['detection_pic'])){ + $detection_pic = explode(',', $order_detection['detection_pic']); + foreach ($detection_pic as &$value) { + $value = addAliyunOssWebsite($value); + } + $order_detection['detection_pic'] = $detection_pic; + } + + // 获取项目名称 + $params = array(); + $params['detection_project_id'] = $order_detection['detection_project_id']; + $detection_project = DetectionProject::getOne($params); + if (empty($detection_project)){ + return fail(); + } + + $order_detection['detection_project_name'] = $detection_project['detection_project_name']; + $order_detection['detection_result_pdf'] = addAliyunOssWebsite($order_detection['detection_result_pdf']); + + // 检测成功时间 + $detection_success_time = date('Y-m-d',time() + 60 * 60 * $detection_project['detection_time']); + $order_detection['detection_success_time'] = $detection_success_time; + + return success($order_detection); + } + + /** + * 删除检测订单 + * @return array + */ + public function deletePatientDetectionOrder(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $order_detection_id = $this->request->route('order_detection_id'); + + // 获取订单数据 + $params = array(); + $params['patient_id'] = $user_info['client_user_id']; + $params['order_detection_id'] = $order_detection_id; + $params['is_delete'] = 0; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)) { + return fail(); + } + + // 检测订单状态 + if (!in_array($order_detection['detection_status'], [5])) { + // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + return fail(HttpEnumCode::HTTP_ERROR, "订单无法删除"); + } + + // 修改订单删除状态 + $data = array(); + $data['is_delete'] = 1; + + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + + OrderDetection::editOrderDetection($params, $data); + + return success(); + } + + /** + * 取消检测订单 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function putCancelPatientDetectionOrder(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $order_detection_id = $this->request->route('order_detection_id'); + + // 获取订单数据 + $params = array(); + $params['patient_id'] = $user_info['client_user_id']; + $params['order_detection_id'] = $order_detection_id; + $params['is_delete'] = 0; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)) { + return fail(); + } + + $redis = $this->container->get(Redis::class); + $redis_key = "order_detection_lock_" . $order_detection_id; + $redis_lock = $redis->setnx($redis_key, 1); + // 设置过期时间 + $redis->expire($redis_key, 3); + if (!$redis_lock) { + // 设置失败,表示已经设置该值 + return fail(HttpEnumCode::HTTP_SUCCESS, "请您稍后重试"); + } + + // 检测订单状态 + if (!in_array($order_detection['detection_status'], [2])) { + // 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消) + return fail(HttpEnumCode::HTTP_ERROR, "订单无法取消"); + } + + if ($order_detection['detection_refund_status'] == 1) { + // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭) + return fail(HttpEnumCode::HTTP_ERROR, "订单申请退款中,请您稍后取消"); + } + + if ($order_detection['detection_refund_status'] == 2) { + // 问诊订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭) + return fail(HttpEnumCode::HTTP_ERROR, "订单正在退款中,请您稍后取消"); + } + + Db::beginTransaction(); + try { + // 退款成功 + // 修改问诊订单为取消 + $data = array(); + $data['detection_status'] = 5; + $data['cancel_time'] = date("Y-m-d H:i:s", time()); + $data['cancel_reason'] = 2; // 取消订单原因(1:主动取消 2:客服取消 3:支付超时) + $data['updated_at'] = date("Y-m-d H:i:s", time()); + + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + OrderDetection::editOrderDetection($params, $data); + + // 检测支付状态,判断是否需要退款处理 + if ($order_detection['detection_pay_status'] == 2 && $order_detection['detection_refund_status'] != 3) { + // 需退款 + $detectionService = new DetectionService(); + $detectionService->detectionRefund($order_detection['order_detection_id'], "取消检测"); + } + + // 删除锁 + $redis->del($redis_key); + + Db::commit(); + } catch (\Exception $e) { + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage()); + } + + try { + // 推送患者-订单取消成功通知 + $MessagePush = new MessagePush($order_detection['user_id']); + $MessagePush->patientCancelDetectionOrderSuccess($order_detection['order_detection_id']); + } catch (\Exception $e) { + return success(); + } + + return success(); + } + + /** + * 检测订单取消支付 + * @return array + */ + public function putPatientDetectionOrderCancelPay(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + $order_detection_id = $this->request->route('order_detection_id'); + + Db::beginTransaction(); + + try { + // 获取订单数据 + $params = array(); + $params['patient_id'] = $user_info['client_user_id']; + $params['order_detection_id'] = $order_detection_id; + $params['is_delete'] = 0; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)) { + return fail(); + } + + // 检测订单取消 + // 取消订单原因(1:主动取消 2:客服取消 3:支付超时) + $DetectionService = new DetectionService(); + $result = $DetectionService->cancelUnpayDetectionOrder($order_detection['detection_no'], 1, "主动取消"); + if ($result['status'] != 1) { + Db::rollBack(); + return fail(); + } + + Db::commit(); + } catch (\Exception $e) { + Db::rollBack(); + return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage()); + } + + return success(); + } + /** * 获取患者未完成订单 * @param string $patient_id @@ -1486,21 +1999,21 @@ class PatientOrderService extends BaseService public function getNotFinishedOrderInquiry(string|int $inquiry_type, string $patient_id = '', string $family_id = ''): string { $params = array(); - if (!empty($patient_id)){ - $params[] = ['patient_id','=',$patient_id]; + if (!empty($patient_id)) { + $params[] = ['patient_id', '=', $patient_id]; } - if (!empty($family_id)){ - $params[] = ['family_id','=',$family_id]; + if (!empty($family_id)) { + $params[] = ['family_id', '=', $family_id]; } - $params[] = ['inquiry_type','=',$inquiry_type]; - $params[] = ['inquiry_mode','=',1]; - $params[] = ['inquiry_refund_status','=',0]; + $params[] = ['inquiry_type', '=', $inquiry_type]; + $params[] = ['inquiry_mode', '=', 1]; + $params[] = ['inquiry_refund_status', '=', 0]; $order_inquiry = OrderInquiry::getOrderOne($params); if (!empty($order_inquiry)) { // 1:待支付 2:待分配 3:待接诊 4:已接诊 - if (in_array($order_inquiry['inquiry_status'], [1,2, 3, 4])) { + if (in_array($order_inquiry['inquiry_status'], [1, 2, 3, 4])) { return $order_inquiry['order_inquiry_id']; } } diff --git a/app/Services/SafeService.php b/app/Services/SafeService.php index a2bf80c..bb7c976 100644 --- a/app/Services/SafeService.php +++ b/app/Services/SafeService.php @@ -52,6 +52,10 @@ class SafeService extends BaseService // 名片 $dir = $dir . 'card/'; break; + case 4: + // 检测管 + $dir = $dir . 'detection/'; + break; default: // code... diff --git a/app/Services/SystemService.php b/app/Services/SystemService.php index c6d7d60..8a30d61 100644 --- a/app/Services/SystemService.php +++ b/app/Services/SystemService.php @@ -47,7 +47,6 @@ class SystemService extends BaseService return fail(); } - dump($system_inquiry_time->toArray()); $time = []; foreach ($system_inquiry_time as $item){ $start_hour = substr($item['start_time'], 0, 1); diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index 45fcb34..0ad7623 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -484,9 +484,14 @@ class UserDoctorService extends BaseService // 获取处方数据 $params = array(); $params['doctor_id'] = $user_info['client_user_id']; - $params['prescription_status'] = 1; $params['pharmacist_audit_status'] = $pharmacist_audit_status; $params['is_delete'] = 0; + + if ($pharmacist_audit_status == 1){ + // 审核通过 + $params['platform_audit_status'] = 1; + } + $order_prescriptions = OrderPrescription::getWithIcdPage($params,['*'],$page,$per_page); if (empty($order_prescriptions)) { return success($order_prescriptions); @@ -522,7 +527,7 @@ class UserDoctorService extends BaseService // 患病时长 if (empty($order_inquiry_case['diagnosis_date'])) { - $data['diagnosis_date'] = "未知"; + $data['diagnosis_date'] = ""; } else { $data['diagnosis_date'] = date('Y-m-d', strtotime($order_inquiry_case['diagnosis_date'])); } @@ -530,6 +535,12 @@ class UserDoctorService extends BaseService // 疾病信息 $data['order_prescription_icd'] = $order_prescription['OrderPrescriptionIcd'] ?? []; + // 患者id + $data['patient_id'] = $order_inquiry_case['patient_id']; + + // 医生id + $data['doctor_id'] = $order_prescription['doctor_id']; + $result[] = $data; } @@ -559,6 +570,7 @@ class UserDoctorService extends BaseService 'multi_point_status', 'is_bind_bank', 'avatar', + 'doctor_title', ]; $user_doctor = UserDoctor::getOne($params, $fields); if (empty($user_doctor)) { @@ -597,6 +609,7 @@ class UserDoctorService extends BaseService $user_doctor['balance_account'] = $balance_account; $user_doctor['estimate_income'] = $estimate_income; + $user_doctor['doctor_title'] = DoctorTitleCode::getMessage($user_doctor['doctor_title']); return success($user_doctor); } @@ -1271,6 +1284,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'); + $disease_desc = $this->request->input('disease_desc'); // 病情主诉 // 获取医生信息 $params = array(); @@ -1289,6 +1303,20 @@ class UserDoctorService extends BaseService return fail(HttpEnumCode::HTTP_ERROR, "请先完成多点执业认证"); } + // 获取医生问诊配置-问诊购药 + $params = array(); + $params['doctor_id'] = $user_doctor['doctor_id']; + $params['inquiry_type'] = 4; + $params['inquiry_mode'] = 1; + $doctor_inquiry_config = DoctorInquiryConfig::getOne($params); + if (empty($doctor_inquiry_config)) { + return fail(HttpEnumCode::HTTP_ERROR, "请联系客服开启问诊购药服务"); + } + + if ($doctor_inquiry_config['is_enable'] == 0){ + return fail(HttpEnumCode::HTTP_ERROR, "请联系客服开启问诊购药服务"); + } + // 获取问诊订单数据 $params = array(); $params['doctor_id'] = $user_info['client_user_id']; @@ -1321,10 +1349,32 @@ class UserDoctorService extends BaseService } } + // 获取患者问诊病例 + $params = array(); + $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + $order_inquiry_case = OrderInquiryCase::getOne($params); + if (empty($order_inquiry_case)){ + return fail(HttpEnumCode::HTTP_ERROR, "患者病例数据错误"); + } + + if (empty($order_inquiry_case['disease_desc']) && empty($disease_desc)){ + return fail(HttpEnumCode::HTTP_ERROR, "请填写病情主诉"); + } + Db::beginTransaction(); $generator = $this->container->get(IdGeneratorInterface::class); try { + // 修改问诊病例表 + if (empty($order_inquiry_case['disease_desc'])){ + $data = array(); + $data['disease_desc'] = $disease_desc; + + $params = array(); + $params['inquiry_case_id'] = $order_inquiry_case['inquiry_case_id']; + OrderInquiryCase::edit($params,$data); + } + // 新增处方表 $data = array(); $data['order_inquiry_id'] = $order_inquiry_id; @@ -1435,7 +1485,7 @@ class UserDoctorService extends BaseService // 开具处方 $OrderPrescriptionService = new OrderPrescriptionService(); - $prescription_open_result = $OrderPrescriptionService->openPrescription($order_prescription->order_prescription_id,$user_info['user_id']); + $prescription_open_result = $OrderPrescriptionService->openPrescription($order_prescription->order_prescription_id,2,$user_info['user_id']); if (empty($prescription_open_result['prescription_img_oss_path']) || empty($prescription_open_result['file_id'])){ Db::rollBack(); return fail(HttpEnumCode::SERVER_ERROR, "处方开具失败"); @@ -1749,7 +1799,7 @@ class UserDoctorService extends BaseService $params['order_inquiry_id'] = $order_inquiry_id; OrderInquiry::edit($params,$data); - // 添加自动完成队列 + // 添加自动结束队列 if ($order_inquiry['inquiry_type'] == 1 || $order_inquiry['inquiry_type'] == 3){ // 专家问诊-公益问诊 $time = 1000 * 60 * 60 * 24; @@ -1782,10 +1832,29 @@ class UserDoctorService extends BaseService } try { + // 获取订单医生数据 + $params = array(); + $params['doctor_id'] = $order_inquiry['doctor_id']; + $user_doctor = UserDoctor::getOne($params); + if (empty($user_doctor)) { + return success([],HttpEnumCode::HTTP_SUCCESS,"医生数据错误"); + } + + // 获取病例数据 + $params = array(); + $params['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + $order_inquiry_case = OrderInquiryCase::getOne($params); + if (empty($order_inquiry_case)){ + return success([],HttpEnumCode::HTTP_SUCCESS,"患者病例错误"); + } + // 发送IM消息-医生接诊 $imService = new ImService(); $imService->doctorInquiry($order_inquiry,$user_info['user_id'],$order_inquiry['user_id']); + // 发送IM消息-患者病例 + $imService->patientCase($order_inquiry,$user_doctor['user_id'],$order_inquiry_case['disease_desc']); + // 发送站内、订阅、短信消息-医生已接诊 $MessagePush = new MessagePush($order_inquiry['user_id'],$order_inquiry['order_inquiry_id']); $MessagePush->patientAcceptedInquiry(); @@ -1825,47 +1894,6 @@ class UserDoctorService extends BaseService return true; } - /** - * 检测是否存在对应问诊的在线医生 - * @param int|string $inquiry_type 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药) - * @return bool - */ - public function checkDoctorOnline(int|string $inquiry_type): bool - { - $params = array(); - $params['status'] = 1; // 状态 - $params['idcard_status'] = 1; // 实名认证状态 - $params['iden_auth_status'] = 1;// 身份认证状态 - - if ($inquiry_type == 4) { - // 问诊购药 - $params['multi_point_status'] = 1;// 医生多点执业认证状态(0:未认证 1:认证通过 2:审核中 3:认证失败) - } - - $params['is_online'] = 1;// 是否在线(0:不在线 1:在线) - - switch ($inquiry_type) { - case 1: - // 专家 - $params['is_img_expert_reception'] = 1;// 是否参加专家图文接诊(0:否 1:是) - break; - case 2: - // 快速 - $params['is_img_quick_reception'] = 1;// 是否参加快速图文接诊(0:否 1:是) - break; - case 3: - // 公益 - $params['is_img_welfare_reception'] = 1;// 是否参加公益图文问诊(0:否 1:是) - break; - - default: - throw new BusinessException(); - break; - } - - return UserDoctor::getExists($params); - } - /** * 获取当前时间N分钟前接诊中的医生 * @param string|int $minute 分钟 @@ -1912,7 +1940,7 @@ class UserDoctorService extends BaseService if ($is_system_time_pass){ // 获取坐班时间包含当前时间的深度合作医生 - $doctor_ids = $this->getMinPlatDeepCooperationDoctorId($inquiry_type,time(),$not_doctor_ids); + $doctor_ids = $this->getNowTimePlatDeepCooperationDoctorId($inquiry_type,time(),$not_doctor_ids); Log::getInstance()->info("获取坐班时间包含当前时间的深度合作医生:" ,$doctor_ids); // 检测医生是否可被分配 @@ -1979,7 +2007,6 @@ class UserDoctorService extends BaseService return ""; } - /** * 获取坐班时间包含某时间的平台深度合作医生 * @param string $inquiry_type @@ -1999,64 +2026,19 @@ class UserDoctorService extends BaseService $user_doctor_params = array(); $user_doctor_params['is_platform_deep_cooperation'] = 1; - if ($inquiry_type == 2){ - // 快速问诊 - $user_doctor_params['is_img_quick_reception'] = 1; - }elseif ($inquiry_type == 4){ - // 问诊购药 + + // 问诊购药 + if ($inquiry_type == 4){ $user_doctor_params['multi_point_status'] = 1; } - $doctor_inquiry_times = DoctorInquiryTime::getWithDoctorNotInList($params,$user_doctor_params,$not_doctor_ids); - if (!empty($doctor_inquiry_times)){ - foreach ($doctor_inquiry_times as $item){ - // 检测是否存在日期 - if (!empty($item['inquiry_date'])){ - // 获取当前日期 - $now_day = date('Y-m-d',time()); - if ($item['inquiry_date'] == $now_day){ - $doctor_ids[] = $item['doctor_id']; - } - }else{ - $doctor_ids[] = $item['doctor_id']; - } - } - } - if (!empty($doctor_ids)){ - $doctor_ids = array_unique($doctor_ids); - $doctor_ids = array_values($doctor_ids); - } + // 问诊配置 + $doctor_inquiry_config_params = array(); + $doctor_inquiry_config_params['inquiry_type'] = $inquiry_type; + $doctor_inquiry_config_params['inquiry_mode'] = 1; + $doctor_inquiry_config_params['is_enable'] = 1; - return $doctor_ids; - } - - /** - * 获取坐班时间包含某时间的平台深度合作医生 - * @param string $inquiry_type - * @param string $time 时间戳 - * @param array $not_doctor_ids 不可选择的医生id数组 - * @return array 医生id - */ - public function getMinPlatDeepCooperationDoctorId(string $inquiry_type,string $time,array $not_doctor_ids = []): array - { - $doctor_ids = []; - - $params = array(); - $params[] = ['inquiry_type','=',$inquiry_type]; - $params[] = ['inquiry_mode','=',1]; - $params[] = ['start_time','<',date('H',$time) . date('i',$time)]; - $params[] = ['end_time','>',date('H',$time) . date('i',$time)]; - - $user_doctor_params = array(); - $user_doctor_params['is_platform_deep_cooperation'] = 1; - if ($inquiry_type == 2){ - // 快速问诊 - $user_doctor_params['is_img_quick_reception'] = 1; - }elseif ($inquiry_type == 4){ - // 问诊购药 - $user_doctor_params['multi_point_status'] = 1; - } - $doctor_inquiry_times = DoctorInquiryTime::getWithDoctorNotInList($params,$user_doctor_params,$not_doctor_ids); + $doctor_inquiry_times = DoctorInquiryTime::getMinPlatDeepCooperationDoctor($params,$user_doctor_params,$not_doctor_ids,$doctor_inquiry_config_params); if (!empty($doctor_inquiry_times)){ foreach ($doctor_inquiry_times as $item){ // 检测是否存在日期 @@ -2147,16 +2129,20 @@ class UserDoctorService extends BaseService $params['iden_auth_status'] = 1; $params['is_bind_bank'] = 1; $params['is_online'] = 1; - if ($inquiry_type == 2){ - // 快速问诊 - $params['is_img_quick_reception'] = 1; - }elseif ($inquiry_type == 4){ - // 问诊购药 + + // 问诊购药 + if ($inquiry_type == 4){ $params['multi_point_status'] = 1; } + + $doctor_inquiry_config_params = array(); + $doctor_inquiry_config_params['inquiry_type'] = $inquiry_type; + $doctor_inquiry_config_params['inquiry_mode'] = 1; + $doctor_inquiry_config_params['is_enable'] = 1; + $params['is_platform_deep_cooperation'] = 1; - $user_doctor = UserDoctor::getUserDoctorNotInList($params,$not_doctor_ids); + $user_doctor = UserDoctor::getListWithConfig($params,$not_doctor_ids,$doctor_inquiry_config_params); return $user_doctor->toArray(); } @@ -2173,16 +2159,19 @@ class UserDoctorService extends BaseService $params['idcard_status'] = 1; $params['iden_auth_status'] = 1; $params['is_bind_bank'] = 1; - if ($inquiry_type == 2){ - // 快速问诊 - $params['is_img_quick_reception'] = 1; - }elseif ($inquiry_type == 4){ - // 问诊购药 + + // 问诊购药 + if ($inquiry_type == 4){ $params['multi_point_status'] = 1; } + $doctor_inquiry_config_params = array(); + $doctor_inquiry_config_params['inquiry_type'] = $inquiry_type; + $doctor_inquiry_config_params['inquiry_mode'] = 1; + $doctor_inquiry_config_params['is_enable'] = 1; + $params['is_platform_deep_cooperation'] = 0; - $user_doctor = UserDoctor::getUserDoctorNotInList($params,$not_doctor_ids); + $user_doctor = UserDoctor::getListWithConfig($params,$not_doctor_ids,$doctor_inquiry_config_params); return $user_doctor->toArray(); } diff --git a/app/Services/UserPatientService.php b/app/Services/UserPatientService.php index 6e2de0a..1df621b 100644 --- a/app/Services/UserPatientService.php +++ b/app/Services/UserPatientService.php @@ -59,6 +59,10 @@ class UserPatientService extends BaseService $OrderProductService = new OrderProductService(); $order_product_count = $OrderProductService->getPatientProductWithStatus($user_patient['patient_id'],1); + // 获取检测数量-待支付 + $detectionService = new DetectionService(); + $order_detection_count = $detectionService->getPatientDetectionWithStatus($user_patient['patient_id'],1); + // 处理头像 $user_patient['avatar'] = addAliyunOssWebsite($user_patient['avatar']); @@ -70,6 +74,7 @@ class UserPatientService extends BaseService $result['order_inquiry_count'] = $order_inquiry_count; $result['order_prescription_count'] = $order_prescription_count; $result['order_product_count'] = $order_product_count; + $result['order_detection_count'] = $order_detection_count; return success($result); } diff --git a/app/Services/UserService.php b/app/Services/UserService.php index f597bed..a5d2a85 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -3,16 +3,20 @@ namespace App\Services; use App\Constants\HttpEnumCode; +use App\Model\Area; use App\Model\Popup; use App\Model\SubTemplate; use App\Model\User; use App\Model\User as UserModel; use App\Model\UserDoctor; use App\Model\UserDoctorInfo; +use App\Model\UserLocation; use App\Model\UserPatient; use App\Model\UserShipAddress; +use App\Model\UserSystem; use App\Utils\Mask; use App\Utils\PcreMatch; +use Extend\Tencent\map\Location; use Extend\TencentIm\Profile; use Extend\Wechat\Wechat; use GuzzleHttp\Exception\GuzzleException; @@ -553,6 +557,204 @@ class UserService extends BaseService return success($popup->toArray()); } + /** + * 上报用户地址 + * @return array + */ + public function postLocation(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + $request_params = $this->request->all(); + + if (empty($request_params['lon']) || empty($request_params['lat'])){ + return success(); + } + + // 处理地址逆解析 + try { + $location = new Location(); + $result = $location->getLocation($request_params['lon'],$request_params['lat']); + if (empty($result)){ + return success(); + } + + if (empty($result['address_component'])){ + return success(); + } + + if (empty($result['address_component']['province']) || empty($result['address_component']['city'])){ + return success(); + } + + // 处理需修改/新增数据 + $data = array(); + $data['lon'] = $request_params['lon']; + $data['lat'] = $request_params['lat']; + $data['province'] = $result['address_component']['province']; + $data['city'] = $result['address_component']['city']; + $data['county'] = $result['address_component']['district'] ?: ""; + $data['address'] = $result['address_component']['street_number'] ?: ""; + + // 获取用户地理位置 + $params = array(); + $params['user_id'] = $user_info['user_id']; + $user_location = UserLocation::getOne($params); + if (empty($user_location)){ + // 新增 + $data['user_id'] = $user_info['user_id']; + $user_location = UserLocation::addUserLocation($data); + if (empty($user_location)){ + return success(); + } + }else{ + // 修改 + $params = array(); + $params['user_id'] = $user_info['user_id']; + $res = UserLocation::editUserLocation($params,$data); + if (!$res){ + return success(); + } + } + }catch (\Exception $e){ + dump($e->getMessage()); + return success(); + } + + return success(); + } + + /** + * 获取用户地址 + * @return array + */ + public function getLocation(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + // 定义返回数据 + $area = [ + "province_id" => "", + "province" => "", + "city_id" => "", + "city" => "", + "county_id" => "", + "county" => "", + ]; + + $params = array(); + $params['user_id'] = $user_info['user_id']; + $user_location = UserLocation::getOne($params); + if (empty($user_location)){ + return success($area); + } + + // 处理省市区对应 + if (!empty($user_location['province']) && !empty($user_location['city'])){ + $params = array(); + $params['area_name'] = $user_location['province']; + $params['area_type'] = 2; + $area_province = Area::getOne($params); + if (!empty($area_province)){ + $area['province_id'] = $area_province['area_id']; + $area['province'] = $area_province['area_name']; + } + + if (!empty($area['province_id'])){ + $params = array(); + $params['area_name'] = $user_location['city']; + $params['parent_id'] = $area['province_id']; + $params['area_type'] = 3; + $area_city = Area::getOne($params); + if (!empty($area_city)){ + $area['city_id'] = $area_city['area_id']; + $area['city'] = $area_city['area_name']; + } + } + } + + if (!empty($area['city_id']) && !empty($user_location['county'])){ + $params = array(); + $params['area_name'] = $user_location['county']; + $params['parent_id'] = $area['city_id']; + $params['area_type'] = 4; + $area_county = Area::getOne($params); + if (!empty($area_county)){ + $area['county_id'] = $area_county['area_id']; + $area['county'] = $area_county['area_name']; + } + } + + return success($area); + } + + /** + * 获取用户配置 + * @return array + */ + public function getUserSystem(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + + // 定义返回数据 + $result = array( + "is_accept_im_message_push" => 0, + ); + + // 获取用户配置数据 + $params = array(); + $params['user_id'] = $user_info['user_id']; + $user_system = UserSystem::getOne($params); + if (empty($user_system)){ + return success($result); + } + + $result['is_accept_im_message_push'] = $user_system['is_accept_im_message_push']; + return success($result); + } + + /** + * 修改用户配置 + * @return array + */ + public function putUserSystem(): array + { + $user_info = $this->request->getAttribute("userInfo") ?? []; + $request_params = $this->request->all(); + + // 获取用户配置数据 + $params = array(); + $params['user_id'] = $user_info['user_id']; + $user_system = UserSystem::getOne($params); + if (empty($user_system)){ + // 新增 + $data = array(); + $data['user_id'] = $user_info['user_id']; + $data['is_accept_im_message_push'] = $request_params['is_accept_im_message_push']; + $user_system = UserSystem::addUserSystem($data); + if (empty($user_system)){ + return fail(); + } + }else{ + // 修改 + $data = array(); + + if ($user_system['is_accept_im_message_push'] != $request_params['is_accept_im_message_push']){ + $data['is_accept_im_message_push'] = $request_params['is_accept_im_message_push']; + } + + if (!empty($data)){ + $params = array(); + $params['user_system_id'] = $user_system['user_system_id']; + + $res = UserSystem::edit($params,$data); + if (!$res){ + return fail(); + } + } + } + return success(); + } + /** * 通过user_id获取用户openid * @param string|int $user_id @@ -632,4 +834,89 @@ class UserService extends BaseService return $avatar; } + /** + * 用户im消息通知 + * @param int|string $user_id + * @param string|int $order_inquiry_id + * @param array $msg_body + * @return bool + */ + public function userImMessageNotice(int|string $user_id,string|int $order_inquiry_id,array $msg_body): bool + { + try { + // 获取用户数据 + $params = array(); + $params['user_id'] = $user_id; + $user = User::getOne($params); + if (empty($user)){ + return false; + } + + // 获取用户配置 + $params = array(); + $params['user_id'] = $user['user_id']; + $user_system = UserSystem::getOne($params); + if (empty($user_system)){ + $data = array(); + $data['user_id'] = $user['user_id']; + $data['is_accept_im_message_push'] = 1; // 默认新增一下配置表 + $user_system = UserSystem::addUserSystem($data); + if (empty($user_system)){ + return false; + } + } + + // 无需发送 + if ($user_system['is_accept_im_message_push'] == 0){ + return true; + } + + $message = "您有一条新的问诊消息"; + // 判断消息类型 + if (isset($msg_body[0]['MsgType'])){ + switch ($msg_body[0]['MsgType']) { + case 'TIMLocationElem': + $message = "地理位置"; + break; + case 'TIMFaceElem': + $message = "表情消息"; + break; + + case 'TIMSoundElem': + $message = "语音消息"; + break; + case 'TIMImageElem': + $message = "图像消息"; + break; + case 'TIMFileElem': + $message = "文件消息"; + break; + case 'TIMTextElem': + if (isset($msg_body[0]['MsgContent']['Text'])){ + $message = $msg_body[0]['MsgContent']['Text']; + } + break; + default: + // code... + break; + } + } + + $MessagePush = new MessagePush($user_id, $order_inquiry_id); + + if ($user['user_type'] == 1){ + // 患者 + $MessagePush->patientImMessageNotice($message); + } elseif ($user['user_type'] == 2){ + // 医师 + $MessagePush->doctorImMessageNotice($message); + }else{ + return false; + } + }catch (\Throwable $e){ + return false; + } + + return true; + } } \ No newline at end of file diff --git a/app/Utils/Auth.php b/app/Utils/Auth.php index 07f9f35..78d99a2 100644 --- a/app/Utils/Auth.php +++ b/app/Utils/Auth.php @@ -28,15 +28,17 @@ class Auth "/callback/wxpay/inquiry/refund" => "post", // 微信问诊退款回调 "/callback/wxpay/product/success" => "post", // 微信药品支付回调 "/callback/wxpay/product/refund" => "post", // 微信药品退款回调 + "/callback/wxpay/detection/success" => "post", // 微信检测订单支付回调 + "/callback/wxpay/detection/refund" => "post", // 微信检测订单退款回调 "/callback/im" => "post", // im回调 "/callback/platform/logistics" => "post", // 处方平台物流回调 "/callback/logistics" => "post", // 快递100订阅回调 "/popup" => "get", // 获取弹窗数据 "/basic/keyword/search" => "get", // 获取热门搜索关键词 "/test/uninquiry" => "get", // 获取未接诊的医生 - "/test/refund" => "get", // 测试退款 "/test" => "get", // 测试 + "/callback/detection" => "post", // 检测所结果回调 ]; } diff --git a/composer.json b/composer.json index f6501b8..f7598f0 100644 --- a/composer.json +++ b/composer.json @@ -94,14 +94,5 @@ "Composer\\Config::disableProcessTimeout", "php ./bin/hyperf.php start" ] - }, - "repositories": { - "proxy": { - "type": "composer", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy", - "only": [ - "hyperf/*" - ] - } } } diff --git a/composer.lock b/composer.lock index 2a38ce5..d26c613 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "05e3ba05b453d5d07af51ee1337d0eaf", + "content-hash": "7b8eb338a7660aee649c5dd55b456b7c", "packages": [ { "name": "adbario/php-dot-notation", @@ -385,16 +385,16 @@ }, { "name": "alibabacloud/tea-utils", - "version": "0.2.18", + "version": "0.2.19", "source": { "type": "git", "url": "https://github.com/alibabacloud-sdk-php/tea-utils.git", - "reference": "103e6cde583cf446b217fbb5c565b9007c238702" + "reference": "8dfc1a93e9415818e93a621b644abbb84981aea4" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/alibabacloud/tea-utils/0.2.18/alibabacloud-tea-utils-0.2.18.zip", - "reference": "103e6cde583cf446b217fbb5c565b9007c238702", + "url": "https://mirrors.huaweicloud.com/repository/php/alibabacloud/tea-utils/0.2.19/alibabacloud-tea-utils-0.2.19.zip", + "reference": "8dfc1a93e9415818e93a621b644abbb84981aea4", "shasum": "" }, "require": { @@ -417,27 +417,27 @@ } ], "description": "Alibaba Cloud Tea Utils for PHP", - "time": "2023-04-11T02:17:04+00:00" + "time": "2023-06-26T09:49:19+00:00" }, { "name": "alibabacloud/tea-xml", - "version": "0.2.3", + "version": "0.2.4", "source": { "type": "git", "url": "https://github.com/alibabacloud-sdk-php/tea-xml.git", - "reference": "4bd2303d71c968cb7ae4e487c5fa3023aed3ff3b" + "reference": "3e0c000bf536224eebbac913c371bef174c0a16a" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/alibabacloud/tea-xml/0.2.3/alibabacloud-tea-xml-0.2.3.zip", - "reference": "4bd2303d71c968cb7ae4e487c5fa3023aed3ff3b", + "url": "https://mirrors.huaweicloud.com/repository/php/alibabacloud/tea-xml/0.2.4/alibabacloud-tea-xml-0.2.4.zip", + "reference": "3e0c000bf536224eebbac913c371bef174c0a16a", "shasum": "" }, "require": { "php": ">5.5" }, "require-dev": { - "phpunit/phpunit": "^4.8.35|^5.4.3", + "phpunit/phpunit": "*", "symfony/var-dumper": "*" }, "type": "library", @@ -456,7 +456,7 @@ } ], "description": "Alibaba Cloud Tea XML Library for PHP", - "time": "2021-12-08T06:43:00+00:00" + "time": "2022-08-02T04:12:58+00:00" }, { "name": "aliyuncs/oss-sdk-php", @@ -500,16 +500,16 @@ }, { "name": "doctrine/deprecations", - "version": "v1.1.1", + "version": "1.1.2", "source": { "type": "git", "url": "https://github.com/doctrine/deprecations.git", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3" + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/doctrine/deprecations/v1.1.1/doctrine-deprecations-v1.1.1.zip", - "reference": "612a3ee5ab0d5dd97b7cf3874a6efe24325efac3", + "url": "https://mirrors.huaweicloud.com/repository/php/doctrine/deprecations/1.1.2/doctrine-deprecations-1.1.2.zip", + "reference": "4f2d4f2836e7ec4e7a8625e75c6aa916004db931", "shasum": "" }, "require": { @@ -538,7 +538,7 @@ ], "description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.", "homepage": "https://www.doctrine-project.org/", - "time": "2023-06-03T09:27:29+00:00" + "time": "2023-09-27T20:04:15+00:00" }, { "name": "doctrine/inflector", @@ -879,16 +879,16 @@ }, { "name": "firebase/php-jwt", - "version": "v6.8.0", + "version": "v6.9.0", "source": { "type": "git", "url": "https://github.com/firebase/php-jwt.git", - "reference": "48b0210c51718d682e53210c24d25c5a10a2299b" + "reference": "f03270e63eaccf3019ef0f32849c497385774e11" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/firebase/php-jwt/v6.8.0/firebase-php-jwt-v6.8.0.zip", - "reference": "48b0210c51718d682e53210c24d25c5a10a2299b", + "url": "https://mirrors.huaweicloud.com/repository/php/firebase/php-jwt/v6.9.0/firebase-php-jwt-v6.9.0.zip", + "reference": "f03270e63eaccf3019ef0f32849c497385774e11", "shasum": "" }, "require": { @@ -933,7 +933,7 @@ "jwt", "php" ], - "time": "2023-06-20T16:45:35+00:00" + "time": "2023-10-05T00:24:42+00:00" }, { "name": "graham-campbell/result-type", @@ -994,22 +994,22 @@ }, { "name": "guzzlehttp/guzzle", - "version": "7.7.0", + "version": "7.8.0", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5" + "reference": "1110f66a6530a40fe7aea0378fe608ee2b2248f9" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/guzzlehttp/guzzle/7.7.0/guzzlehttp-guzzle-7.7.0.zip", - "reference": "fb7566caccf22d74d1ab270de3551f72a58399f5", + "url": "https://mirrors.huaweicloud.com/repository/php/guzzlehttp/guzzle/7.8.0/guzzlehttp-guzzle-7.8.0.zip", + "reference": "1110f66a6530a40fe7aea0378fe608ee2b2248f9", "shasum": "" }, "require": { "ext-json": "*", - "guzzlehttp/promises": "^1.5.3 || ^2.0", - "guzzlehttp/psr7": "^1.9.1 || ^2.4.5", + "guzzlehttp/promises": "^1.5.3 || ^2.0.1", + "guzzlehttp/psr7": "^1.9.1 || ^2.5.1", "php": "^7.2.5 || ^8.0", "psr/http-client": "^1.0", "symfony/deprecation-contracts": "^2.2 || ^3.0" @@ -1111,7 +1111,7 @@ "type": "tidelift" } ], - "time": "2023-05-21T14:04:53+00:00" + "time": "2023-08-27T10:20:53+00:00" }, { "name": "guzzlehttp/promises", @@ -1193,16 +1193,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "2.6.0", + "version": "2.6.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "8bd7c33a0734ae1c5d074360512beb716bef3f77" + "reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/guzzlehttp/psr7/2.6.0/guzzlehttp-psr7-2.6.0.zip", - "reference": "8bd7c33a0734ae1c5d074360512beb716bef3f77", + "url": "https://mirrors.huaweicloud.com/repository/php/guzzlehttp/psr7/2.6.1/guzzlehttp-psr7-2.6.1.zip", + "reference": "be45764272e8873c72dbe3d2edcfdfcc3bc9f727", "shasum": "" }, "require": { @@ -1300,20 +1300,20 @@ "type": "tidelift" } ], - "time": "2023-08-03T15:06:02+00:00" + "time": "2023-08-27T10:13:57+00:00" }, { "name": "hyperf/amqp", - "version": "v3.0.18", + "version": "v3.0.37", "source": { "type": "git", "url": "https://github.com/hyperf/amqp.git", - "reference": "701520b989a0277d2faded8a1141e1c4545261c2" + "reference": "58b406a866191eba72564af9bcd22d9264114f48" }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/proxy/archive/hyperf/amqp/v3.0.18?source=%E5%AE%98%E6%96%B9%E6%BA%90", - "reference": "701520b989a0277d2faded8a1141e1c4545261c2", + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/amqp/v3.0.37/hyperf-amqp-v3.0.37.zip", + "reference": "58b406a866191eba72564af9bcd22d9264114f48", "shasum": "" }, "require": { @@ -1359,16 +1359,21 @@ "hyperf", "php" ], - "time": "2023-04-26T03:02:31+00:00" + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/async-queue", - "version": "v3.0.18", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/async-queue.git", + "reference": "b7976f748fa56d4d0d4e343c4fe32a91518ea031" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/async-queue/v3.0.18", - "reference": "477d7813d11661b7b8e83d3500bb99150398ec61", - "shasum": "477d7813d11661b7b8e83d3500bb99150398ec61" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/async-queue/v3.0.37/hyperf-async-queue-v3.0.37.zip", + "reference": "b7976f748fa56d4d0d4e343c4fe32a91518ea031", + "shasum": "" }, "require": { "hyperf/codec": "~3.0.0", @@ -1401,11 +1406,6 @@ "Hyperf\\AsyncQueue\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\AsyncQueue\\": "tests/" - } - }, "license": [ "MIT" ], @@ -1416,20 +1416,21 @@ "hyperf", "php" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/cache", - "version": "v3.0.26", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/cache.git", + "reference": "0dc19cfaa49f7c26d1d360cc9556b057f85ccc3b" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/cache/v3.0.26", - "reference": "4578ba1d3f438f2f8f07a0d4144af7a1403ee90d", - "shasum": "4578ba1d3f438f2f8f07a0d4144af7a1403ee90d" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/cache/v3.0.37/hyperf-cache-v3.0.37.zip", + "reference": "0dc19cfaa49f7c26d1d360cc9556b057f85ccc3b", + "shasum": "" }, "require": { "hyperf/codec": "~3.0.0", @@ -1459,11 +1460,6 @@ "Hyperf\\Cache\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Cache\\": "tests/" - } - }, "license": [ "MIT" ], @@ -1474,20 +1470,21 @@ "hyperf", "php" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/code-parser", - "version": "v3.0.18", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/code-parser.git", + "reference": "946fcd1c8d72747a59277926605e2544fb35b032" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/code-parser/v3.0.18", - "reference": "89d74d0ac53e6caa28d489c00f74ab8c151e7344", - "shasum": "89d74d0ac53e6caa28d489c00f74ab8c151e7344" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/code-parser/v3.0.37/hyperf-code-parser-v3.0.37.zip", + "reference": "946fcd1c8d72747a59277926605e2544fb35b032", + "shasum": "" }, "require": { "hyperf/collection": "~3.0.0", @@ -1510,11 +1507,6 @@ "Hyperf\\CodeParser\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\CodeParser\\": "tests/" - } - }, "license": [ "MIT" ], @@ -1526,20 +1518,21 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/codec", - "version": "v3.0.30", + "version": "v3.0.38", + "source": { + "type": "git", + "url": "https://github.com/hyperf/codec.git", + "reference": "dfe4ff846540362c5a56e9ade6bdeef16d264fb8" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/codec/v3.0.30", - "reference": "b0c06dc71ab7471ff1a42047fb0cdf0e56faa2a3", - "shasum": "b0c06dc71ab7471ff1a42047fb0cdf0e56faa2a3" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/codec/v3.0.38/hyperf-codec-v3.0.38.zip", + "reference": "dfe4ff846540362c5a56e9ade6bdeef16d264fb8", + "shasum": "" }, "require": { "ext-json": "*", @@ -1561,11 +1554,6 @@ "Hyperf\\Codec\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Codec\\": "tests/" - } - }, "license": [ "MIT" ], @@ -1577,20 +1565,21 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-30T06:00:08+00:00" }, { "name": "hyperf/collection", - "version": "v3.0.29", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/collection.git", + "reference": "e3c47b1b119fc6dbfba77f4a494b6159b03ec532" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/collection/v3.0.29", - "reference": "71be6bdaa2e739b5d205d3c430f592b71c8835f7", - "shasum": "71be6bdaa2e739b5d205d3c430f592b71c8835f7" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/collection/v3.0.37/hyperf-collection-v3.0.37.zip", + "reference": "e3c47b1b119fc6dbfba77f4a494b6159b03ec532", + "shasum": "" }, "require": { "hyperf/contract": "~3.0.0", @@ -1604,16 +1593,11 @@ } }, "autoload": { - "psr-4": { - "Hyperf\\Collection\\": "src/" - }, "files": [ "src/Functions.php" - ] - }, - "autoload-dev": { + ], "psr-4": { - "HyperfTest\\Collection\\": "tests/" + "Hyperf\\Collection\\": "src/" } }, "license": [ @@ -1627,20 +1611,21 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/command", - "version": "v3.0.27", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/command.git", + "reference": "20731f30a2fb8aed76874f6e2d9f57b757cd7710" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/command/v3.0.27", - "reference": "e7c99353b3d03e6a55a7a8a1ef44ea9ceee9ff51", - "shasum": "e7c99353b3d03e6a55a7a8a1ef44ea9ceee9ff51" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/command/v3.0.37/hyperf-command-v3.0.37.zip", + "reference": "20731f30a2fb8aed76874f6e2d9f57b757cd7710", + "shasum": "" }, "require": { "hyperf/support": "~3.0.0", @@ -1664,11 +1649,6 @@ "Hyperf\\Command\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Command\\": "tests/" - } - }, "license": [ "MIT" ], @@ -1677,16 +1657,22 @@ "command", "php", "swoole" - ] + ], + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/conditionable", - "version": "v3.0.0", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/conditionable.git", + "reference": "8e35db68166b333ce9e8b4ef6c04e81206ad5660" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/conditionable/v3.0.0", - "reference": "b758b9a4b1b248b5bb8a5aa02c8d043e6182c3d5", - "shasum": "b758b9a4b1b248b5bb8a5aa02c8d043e6182c3d5" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/conditionable/v3.0.37/hyperf-conditionable-v3.0.37.zip", + "reference": "8e35db68166b333ce9e8b4ef6c04e81206ad5660", + "shasum": "" }, "require": { "php": ">=7.4" @@ -1702,11 +1688,6 @@ "Hyperf\\Conditionable\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Conditionable\\": "tests/" - } - }, "license": [ "MIT" ], @@ -1718,20 +1699,21 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/config", - "version": "v3.0.20", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/config.git", + "reference": "faee71c69eacde52e3a68e003bdf98de9db4e2cb" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/config/v3.0.20", - "reference": "d719449bb2b75455f410d4c718b65d74f686273b", - "shasum": "d719449bb2b75455f410d4c718b65d74f686273b" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/config/v3.0.37/hyperf-config-v3.0.37.zip", + "reference": "faee71c69eacde52e3a68e003bdf98de9db4e2cb", + "shasum": "" }, "require": { "hyperf/collection": "~3.0.0", @@ -1758,16 +1740,11 @@ } }, "autoload": { - "psr-4": { - "Hyperf\\Config\\": "src/" - }, "files": [ "./src/Functions.php" - ] - }, - "autoload-dev": { + ], "psr-4": { - "HyperfTest\\Config\\": "tests/" + "Hyperf\\Config\\": "src/" } }, "license": [ @@ -1782,20 +1759,21 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/constants", - "version": "v3.0.18", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/constants.git", + "reference": "59ae4cad155e742368fe9c564885c813fdea9376" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/constants/v3.0.18", - "reference": "733009cca5e1a264488b483ef9f017073854bff3", - "shasum": "733009cca5e1a264488b483ef9f017073854bff3" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/constants/v3.0.37/hyperf-constants-v3.0.37.zip", + "reference": "59ae4cad155e742368fe9c564885c813fdea9376", + "shasum": "" }, "require": { "hyperf/di": "~3.0.0", @@ -1820,11 +1798,6 @@ "Hyperf\\Constants\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Constants\\": "tests/" - } - }, "license": [ "MIT" ], @@ -1835,20 +1808,21 @@ "hyperf", "php" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/context", - "version": "v3.0.18", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/context.git", + "reference": "264e06fb882426d90758eca2c5bb8293f8b60455" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/context/v3.0.18", - "reference": "35cabcd8756b8eff1f6b72352389cb7f6f823627", - "shasum": "35cabcd8756b8eff1f6b72352389cb7f6f823627" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/context/v3.0.37/hyperf-context-v3.0.37.zip", + "reference": "264e06fb882426d90758eca2c5bb8293f8b60455", + "shasum": "" }, "require": { "hyperf/engine": "^1.2|^2.0", @@ -1865,36 +1839,32 @@ "Hyperf\\Context\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Context\\": "tests/" - } - }, "license": [ "MIT" ], "description": "A coroutine/application context library.", "homepage": "https://hyperf.io", "keywords": [ - "context", + "Context", "hyperf", "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/contract", - "version": "v3.0.10", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/contract.git", + "reference": "2e8290104468a8d90855067d8644a32114474452" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/contract/v3.0.10", - "reference": "5d1d146ea199b538b7be4714951df6b9a8c5ea31", - "shasum": "5d1d146ea199b538b7be4714951df6b9a8c5ea31" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/contract/v3.0.37/hyperf-contract-v3.0.37.zip", + "reference": "2e8290104468a8d90855067d8644a32114474452", + "shasum": "" }, "require": { "php": ">=8.0" @@ -1920,20 +1890,21 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/coordinator", - "version": "v3.0.22", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/coordinator.git", + "reference": "423f38c113982fd5faaf69f5c31c2a655da6b144" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/coordinator/v3.0.22", - "reference": "bb78c3fa09045b8bc09b5f49e093f82a3865ebec", - "shasum": "bb78c3fa09045b8bc09b5f49e093f82a3865ebec" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/coordinator/v3.0.37/hyperf-coordinator-v3.0.37.zip", + "reference": "423f38c113982fd5faaf69f5c31c2a655da6b144", + "shasum": "" }, "require": { "hyperf/engine": "^1.2|^2.0", @@ -1950,36 +1921,32 @@ "Hyperf\\Coordinator\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Coordinator\\": "tests/" - } - }, "license": [ "MIT" ], "description": "Hyperf Coordinator", "homepage": "https://hyperf.io", "keywords": [ - "coordinator", + "Coordinator", "hyperf", "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/coroutine", - "version": "v3.0.16", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/coroutine.git", + "reference": "f7ecb9d25a6ae7bd927a1e161547d44e29e157f4" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/coroutine/v3.0.16", - "reference": "39250744200eeabfef0b01d4c8b197ea9ff0e1dd", - "shasum": "39250744200eeabfef0b01d4c8b197ea9ff0e1dd" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/coroutine/v3.0.37/hyperf-coroutine-v3.0.37.zip", + "reference": "f7ecb9d25a6ae7bd927a1e161547d44e29e157f4", + "shasum": "" }, "require": { "hyperf/context": "~3.0.0", @@ -1994,16 +1961,11 @@ } }, "autoload": { - "psr-4": { - "Hyperf\\Coroutine\\": "src/" - }, "files": [ "src/Functions.php" - ] - }, - "autoload-dev": { + ], "psr-4": { - "HyperfTest\\Coroutine\\": "tests/" + "Hyperf\\Coroutine\\": "src/" } }, "license": [ @@ -2017,28 +1979,25 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/crontab", - "version": "v3.0.16", + "version": "v3.0.37", "source": { "type": "git", "url": "https://github.com/hyperf/crontab.git", - "reference": "99f8accd65cda19035f74023e80fd154bd7a576f" + "reference": "c28ae42f35b9b2448acc3cb7817e76316ae89775" }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/proxy/archive/hyperf/crontab/v3.0.16?source=%E5%AE%98%E6%96%B9%E6%BA%90", - "reference": "99f8accd65cda19035f74023e80fd154bd7a576f", + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/crontab/v3.0.37/hyperf-crontab-v3.0.37.zip", + "reference": "c28ae42f35b9b2448acc3cb7817e76316ae89775", "shasum": "" }, "require": { "hyperf/framework": "~3.0.0", + "hyperf/support": "~3.0.0", "hyperf/utils": "~3.0.0", "nesbot/carbon": "^2.0", "php": ">=8.0" @@ -2072,16 +2031,21 @@ "php", "swoole" ], - "time": "2023-04-12T04:36:10+00:00" + "time": "2023-09-20T11:44:00+00:00" }, { "name": "hyperf/database", - "version": "v3.0.30", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/database.git", + "reference": "e5d7ae826c7f8cec12db485ddccbac155848ae19" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/database/v3.0.30", - "reference": "afcadd4d7835861595d522e83270009494c5f8d6", - "shasum": "afcadd4d7835861595d522e83270009494c5f8d6" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/database/v3.0.37/hyperf-database-v3.0.37.zip", + "reference": "e5d7ae826c7f8cec12db485ddccbac155848ae19", + "shasum": "" }, "require": { "hyperf/code-parser": "~3.0.0", @@ -2111,11 +2075,6 @@ "Hyperf\\Database\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Database\\": "tests/" - } - }, "license": [ "MIT" ], @@ -2126,20 +2085,21 @@ "hyperf", "php" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/db-connection", "version": "v3.0.18", + "source": { + "type": "git", + "url": "https://github.com/hyperf/db-connection.git", + "reference": "e4264bbaaa4b2f6a02096400ee05e4289b6a5509" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/db-connection/v3.0.18", - "reference": "f56782784de4fdc6258e920fc4f70970cc2e4adb", - "shasum": "f56782784de4fdc6258e920fc4f70970cc2e4adb" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/db-connection/v3.0.18/hyperf-db-connection-v3.0.18.zip", + "reference": "e4264bbaaa4b2f6a02096400ee05e4289b6a5509", + "shasum": "" }, "require": { "hyperf/database": "~3.0.0", @@ -2166,36 +2126,32 @@ "Hyperf\\DbConnection\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\DbConnection\\": "tests/" - } - }, "license": [ "MIT" ], "description": "A hyperf db connection handler for hyperf/database.", "homepage": "https://hyperf.io", "keywords": [ - "connection", + "Connection", "database", "hyperf", "php" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-04-26T03:02:31+00:00" }, { "name": "hyperf/di", - "version": "v3.0.24", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/di.git", + "reference": "86ff03dbbedebd7cc6f4f7f0d67999bbbc4b9358" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/di/v3.0.24", - "reference": "ca880c25d039dd08f24a7d162dab247a3c1418e7", - "shasum": "ca880c25d039dd08f24a7d162dab247a3c1418e7" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/di/v3.0.37/hyperf-di-v3.0.37.zip", + "reference": "86ff03dbbedebd7cc6f4f7f0d67999bbbc4b9358", + "shasum": "" }, "require": { "doctrine/instantiator": "^1.0", @@ -2227,11 +2183,6 @@ "Hyperf\\Di\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Di\\": "tests/" - } - }, "license": [ "MIT" ], @@ -2244,20 +2195,21 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/dispatcher", - "version": "v3.0.24", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/dispatcher.git", + "reference": "9132a800f3156aeb1c54a34ce5dd094046c18062" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/dispatcher/v3.0.24", - "reference": "3212e84825cc593f3b16e984051c74116bb46e3c", - "shasum": "3212e84825cc593f3b16e984051c74116bb46e3c" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/dispatcher/v3.0.37/hyperf-dispatcher-v3.0.37.zip", + "reference": "9132a800f3156aeb1c54a34ce5dd094046c18062", + "shasum": "" }, "require": { "hyperf/contract": "~3.0.0", @@ -2280,11 +2232,6 @@ "Hyperf\\Dispatcher\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Dispatcher\\": "tests/" - } - }, "license": [ "MIT" ], @@ -2298,11 +2245,7 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/engine", @@ -2314,7 +2257,7 @@ }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/proxy/archive/hyperf/engine/v1.10.0?source=%E5%AE%98%E6%96%B9%E6%BA%90", + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/engine/v1.10.0/hyperf-engine-v1.10.0.zip", "reference": "da38c8708f3d78d1490331e432d385489720568f", "shasum": "" }, @@ -2357,12 +2300,17 @@ }, { "name": "hyperf/event", - "version": "v3.0.0", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/event.git", + "reference": "76534832f51db7bf74f0dcd0a8dd9720e6e8080b" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/event/v3.0.0", - "reference": "d56b753f2d0dbfe3f5a5075b9d5c8cefa7f00fd8", - "shasum": "d56b753f2d0dbfe3f5a5075b9d5c8cefa7f00fd8" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/event/v3.0.37/hyperf-event-v3.0.37.zip", + "reference": "76534832f51db7bf74f0dcd0a8dd9720e6e8080b", + "shasum": "" }, "require": { "hyperf/contract": "~3.0.0", @@ -2386,11 +2334,6 @@ "Hyperf\\Event\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Event\\": "tests/" - } - }, "license": [ "MIT" ], @@ -2402,20 +2345,21 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/exception-handler", - "version": "v3.0.24", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/exception-handler.git", + "reference": "baf189572b529e9f4223cc31c23a20232179db05" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/exception-handler/v3.0.24", - "reference": "18d928d28304da9c124eec4648caa060581283ea", - "shasum": "18d928d28304da9c124eec4648caa060581283ea" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/exception-handler/v3.0.37/hyperf-exception-handler-v3.0.37.zip", + "reference": "baf189572b529e9f4223cc31c23a20232179db05", + "shasum": "" }, "require": { "hyperf/contract": "~3.0.0", @@ -2440,11 +2384,6 @@ "Hyperf\\ExceptionHandler\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\ExceptionHandler\\": "tests/" - } - }, "license": [ "MIT" ], @@ -2455,20 +2394,21 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/framework", - "version": "v3.0.23", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/framework.git", + "reference": "73866e5198036ba1050aa8fc068a8f369225f7db" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/framework/v3.0.23", - "reference": "c0b527b1905782082c944ab0e6c9fdef5e6505a5", - "shasum": "c0b527b1905782082c944ab0e6c9fdef5e6505a5" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/framework/v3.0.37/hyperf-framework-v3.0.37.zip", + "reference": "73866e5198036ba1050aa8fc068a8f369225f7db", + "shasum": "" }, "require": { "fig/http-message-util": "^1.1.2", @@ -2501,38 +2441,34 @@ "Hyperf\\Framework\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Framework\\": "tests/" - } - }, "license": [ "MIT" ], "description": "A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.", "homepage": "https://hyperf.io", "keywords": [ + "Microservice", "framework", "hyperf", - "microservice", "middleware", "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/guzzle", - "version": "v3.0.24", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/guzzle.git", + "reference": "312d15dd1c94e423da3ab959363fa5c42e131c52" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/guzzle/v3.0.24", - "reference": "637ced9e55158db68455b160c20c9d5b328eda0d", - "shasum": "637ced9e55158db68455b160c20c9d5b328eda0d" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/guzzle/v3.0.37/hyperf-guzzle-v3.0.37.zip", + "reference": "312d15dd1c94e423da3ab959363fa5c42e131c52", + "shasum": "" }, "require": { "guzzlehttp/guzzle": "^6.3|^7.0", @@ -2558,30 +2494,31 @@ "Hyperf\\Guzzle\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Guzzle\\": "tests/" - } - }, "license": [ "MIT" ], "description": "Swoole coroutine handler for guzzle", "keywords": [ - "guzzle", + "Guzzle", "handler", "php", "swoole" - ] + ], + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/http-message", - "version": "v3.0.18", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/http-message.git", + "reference": "0874d23ae88821028bb0a2ac1906a1acd7a9be58" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/http-message/v3.0.18", - "reference": "28398e352b4b6e56e4109b2b40c62de6cafe9a8a", - "shasum": "28398e352b4b6e56e4109b2b40c62de6cafe9a8a" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/http-message/v3.0.37/hyperf-http-message-v3.0.37.zip", + "reference": "0874d23ae88821028bb0a2ac1906a1acd7a9be58", + "shasum": "" }, "require": { "hyperf/codec": "~3.0.0", @@ -2609,11 +2546,6 @@ "Hyperf\\HttpMessage\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\HttpMessage\\": "tests/" - } - }, "license": [ "MIT" ], @@ -2623,16 +2555,22 @@ "hyperf", "php", "swoole" - ] + ], + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/http-server", - "version": "v3.0.24", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/http-server.git", + "reference": "e177b49c181e213c969d69bc2d333295dbab894d" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/http-server/v3.0.24", - "reference": "d786e5324f04baa17812909ab7665cb07f376d3b", - "shasum": "d786e5324f04baa17812909ab7665cb07f376d3b" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/http-server/v3.0.37/hyperf-http-server-v3.0.37.zip", + "reference": "e177b49c181e213c969d69bc2d333295dbab894d", + "shasum": "" }, "require": { "hyperf/codec": "~3.0.0", @@ -2669,11 +2607,6 @@ "Hyperf\\HttpServer\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\HttpServer\\": "tests/" - } - }, "license": [ "MIT" ], @@ -2686,20 +2619,21 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/logger", - "version": "v3.0.20", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/logger.git", + "reference": "08a525e65f48e4b99c00e45d7bf66c77cbaef415" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/logger/v3.0.20", - "reference": "b00476c1fb637559f800dcd0ac759a44335200ea", - "shasum": "b00476c1fb637559f800dcd0ac759a44335200ea" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/logger/v3.0.37/hyperf-logger-v3.0.37.zip", + "reference": "08a525e65f48e4b99c00e45d7bf66c77cbaef415", + "shasum": "" }, "require": { "hyperf/contract": "~3.0.0", @@ -2724,11 +2658,6 @@ "Hyperf\\Logger\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Logger\\": "tests/" - } - }, "license": [ "MIT" ], @@ -2739,20 +2668,21 @@ "logger", "php" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/macroable", - "version": "v3.0.0", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/macroable.git", + "reference": "3bfa6099679b569880572ec1361cdb0fe3dcb8f2" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/macroable/v3.0.0", - "reference": "3785664bd3ae413b9755f7e3529d609962ac4cf4", - "shasum": "3785664bd3ae413b9755f7e3529d609962ac4cf4" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/macroable/v3.0.37/hyperf-macroable-v3.0.37.zip", + "reference": "3bfa6099679b569880572ec1361cdb0fe3dcb8f2", + "shasum": "" }, "require": { "php": ">=7.4" @@ -2768,11 +2698,6 @@ "Hyperf\\Macroable\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Macroable\\": "tests/" - } - }, "license": [ "MIT" ], @@ -2784,24 +2709,20 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/memory", - "version": "v3.0.0", + "version": "v3.0.37", "source": { "type": "git", "url": "https://github.com/hyperf/memory.git", - "reference": "c7217c9b5177562329074d332f9e13b40693bdfe" + "reference": "2cba607e04ff416dad61e8a4c43b8fa8870c7f91" }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/proxy/archive/hyperf/memory/v3.0.0?source=%E5%AE%98%E6%96%B9%E6%BA%90", - "reference": "c7217c9b5177562329074d332f9e13b40693bdfe", + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/memory/v3.0.37/hyperf-memory-v3.0.37.zip", + "reference": "2cba607e04ff416dad61e8a4c43b8fa8870c7f91", "shasum": "" }, "require": { @@ -2832,16 +2753,21 @@ "php", "swoole" ], - "time": "2022-11-01T02:50:54+00:00" + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/model-listener", - "version": "v3.0.18", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/model-listener.git", + "reference": "8aae9f715a1972a921ebc3aca915dd937f79739d" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/model-listener/v3.0.18", - "reference": "2d53cea4d4b1c023bbdc0c5868deedae969c164c", - "shasum": "2d53cea4d4b1c023bbdc0c5868deedae969c164c" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/model-listener/v3.0.37/hyperf-model-listener-v3.0.37.zip", + "reference": "8aae9f715a1972a921ebc3aca915dd937f79739d", + "shasum": "" }, "require": { "hyperf/contract": "~3.0.0", @@ -2867,11 +2793,6 @@ "Hyperf\\ModelListener\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\ModelListener\\": "tests/" - } - }, "license": [ "MIT" ], @@ -2883,24 +2804,20 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/paginator", - "version": "v3.0.18", + "version": "v3.0.37", "source": { "type": "git", "url": "https://github.com/hyperf/paginator.git", - "reference": "5e732c60fb47be062970a2d436e3bee341f15302" + "reference": "aed966d7c1df6b559967b541ebba375dc4c95dea" }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/proxy/archive/hyperf/paginator/v3.0.18?source=%E5%AE%98%E6%96%B9%E6%BA%90", - "reference": "5e732c60fb47be062970a2d436e3bee341f15302", + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/paginator/v3.0.37/hyperf-paginator-v3.0.37.zip", + "reference": "aed966d7c1df6b559967b541ebba375dc4c95dea", "shasum": "" }, "require": { @@ -2938,16 +2855,21 @@ "paginator", "php" ], - "time": "2023-04-26T03:02:31+00:00" + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/pipeline", - "version": "v3.0.16", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/pipeline.git", + "reference": "90f3aa4d4635834c2309c5e208e3961e7f14db39" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/pipeline/v3.0.16", - "reference": "7282ee6775443a25b75f093d68ff8bef7d07ea66", - "shasum": "7282ee6775443a25b75f093d68ff8bef7d07ea66" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/pipeline/v3.0.37/hyperf-pipeline-v3.0.37.zip", + "reference": "90f3aa4d4635834c2309c5e208e3961e7f14db39", + "shasum": "" }, "require": { "php": ">=8.0", @@ -2964,11 +2886,6 @@ "Hyperf\\Pipeline\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Pipeline\\": "tests/" - } - }, "license": [ "MIT" ], @@ -2980,20 +2897,21 @@ "pipeline", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/pool", - "version": "v3.0.18", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/pool.git", + "reference": "0bd9cf0e6e40ca9876d5e851967d5aa195fc30b7" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/pool/v3.0.18", - "reference": "f60ac0b2bd6c7cefdedced75ae781834b17e31ef", - "shasum": "f60ac0b2bd6c7cefdedced75ae781834b17e31ef" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/pool/v3.0.37/hyperf-pool-v3.0.37.zip", + "reference": "0bd9cf0e6e40ca9876d5e851967d5aa195fc30b7", + "shasum": "" }, "require": { "hyperf/contract": "~3.0.0", @@ -3016,11 +2934,6 @@ "Hyperf\\Pool\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Pool\\": "tests/" - } - }, "license": [ "MIT" ], @@ -3032,20 +2945,21 @@ "php", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/process", - "version": "v3.0.22", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/process.git", + "reference": "7e63f9eb1b832ae8d38b7665476d45b2cf97fb94" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/process/v3.0.22", - "reference": "d245ebd64644c1b0e82decdd19bf40eb1f9828fa", - "shasum": "d245ebd64644c1b0e82decdd19bf40eb1f9828fa" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/process/v3.0.37/hyperf-process-v3.0.37.zip", + "reference": "7e63f9eb1b832ae8d38b7665476d45b2cf97fb94", + "shasum": "" }, "require": { "hyperf/contract": "~3.0.0", @@ -3074,11 +2988,6 @@ "Hyperf\\Process\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Process\\": "tests/" - } - }, "license": [ "MIT" ], @@ -3089,23 +2998,24 @@ "php", "process" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/redis", - "version": "v3.0.21", + "version": "v3.0.39", + "source": { + "type": "git", + "url": "https://github.com/hyperf/redis.git", + "reference": "104366a4da9639e148ffc1230c5b61c81cbf6d78" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/redis/v3.0.21", - "reference": "64fad3232502d69e93b759ad19a48656a9439cc0", - "shasum": "64fad3232502d69e93b759ad19a48656a9439cc0" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/redis/v3.0.39/hyperf-redis-v3.0.39.zip", + "reference": "104366a4da9639e148ffc1230c5b61c81cbf6d78", + "shasum": "" }, "require": { - "ext-redis": "*", + "ext-redis": "^5.0|^6.0", "hyperf/contract": "~3.0.0", "hyperf/pool": "~3.0.0", "hyperf/support": "~3.0.0", @@ -3132,11 +3042,6 @@ "Hyperf\\Redis\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Redis\\": "tests/" - } - }, "license": [ "MIT" ], @@ -3148,20 +3053,21 @@ "pool", "redis" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-10-12T13:10:56+00:00" }, { "name": "hyperf/serializer", - "version": "v3.0.0", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/serializer.git", + "reference": "48f6192b320930266f53a030e5d6231cf0b77772" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/serializer/v3.0.0", - "reference": "2f8919fee2b214840b18fb9c6c6b7708d00ce21f", - "shasum": "2f8919fee2b214840b18fb9c6c6b7708d00ce21f" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/serializer/v3.0.37/hyperf-serializer-v3.0.37.zip", + "reference": "48f6192b320930266f53a030e5d6231cf0b77772", + "shasum": "" }, "require": { "hyperf/contract": "~3.0.0", @@ -3186,11 +3092,6 @@ "Hyperf\\Serializer\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Serializer\\": "tests/" - } - }, "license": [ "MIT" ], @@ -3202,20 +3103,21 @@ "swoole", "tappable" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/server", - "version": "v3.0.24", + "version": "v3.0.39", + "source": { + "type": "git", + "url": "https://github.com/hyperf/server.git", + "reference": "b8e305dc7583762a5e3815b1da984e7cf2f13388" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/server/v3.0.24", - "reference": "edb75947918678788441e2748de88856a60a281c", - "shasum": "edb75947918678788441e2748de88856a60a281c" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/server/v3.0.39/hyperf-server-v3.0.39.zip", + "reference": "b8e305dc7583762a5e3815b1da984e7cf2f13388", + "shasum": "" }, "require": { "hyperf/contract": "~3.0.0", @@ -3247,11 +3149,6 @@ "Hyperf\\Server\\": "src/" } }, - "autoload-dev": { - "psr-4": { - "HyperfTest\\Server\\": "tests/" - } - }, "license": [ "MIT" ], @@ -3263,24 +3160,20 @@ "server", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-10-08T15:14:41+00:00" }, { "name": "hyperf/snowflake", - "version": "v3.0.18", + "version": "v3.0.37", "source": { "type": "git", "url": "https://github.com/hyperf/snowflake.git", - "reference": "76d7ef7683c964d17d4cd30815bcb0509428adf3" + "reference": "217435f1bfeea1692417779385dc06d15bfa11ee" }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/proxy/archive/hyperf/snowflake/v3.0.18?source=%E5%AE%98%E6%96%B9%E6%BA%90", - "reference": "76d7ef7683c964d17d4cd30815bcb0509428adf3", + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/snowflake/v3.0.37/hyperf-snowflake-v3.0.37.zip", + "reference": "217435f1bfeea1692417779385dc06d15bfa11ee", "shasum": "" }, "require": { @@ -3315,18 +3208,24 @@ "php", "snowflake" ], - "time": "2023-04-26T03:02:31+00:00" + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/stringable", - "version": "v3.0.31", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/stringable.git", + "reference": "63d7ce080e38e72205a181541abab82dbe84270b" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/stringable/v3.0.31", - "reference": "8559d8a3c4828667d9e2c943a03f6933e703d0c5", - "shasum": "8559d8a3c4828667d9e2c943a03f6933e703d0c5" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/stringable/v3.0.37/hyperf-stringable-v3.0.37.zip", + "reference": "63d7ce080e38e72205a181541abab82dbe84270b", + "shasum": "" }, "require": { + "ext-mbstring": "*", "hyperf/collection": "~3.0.0", "hyperf/conditionable": "~3.0.0", "hyperf/macroable": "~3.0.0", @@ -3345,16 +3244,11 @@ } }, "autoload": { - "psr-4": { - "Hyperf\\Stringable\\": "src/" - }, "files": [ "src/Functions.php" - ] - }, - "autoload-dev": { + ], "psr-4": { - "HyperfTest\\Stringable\\": "tests/" + "Hyperf\\Stringable\\": "src/" } }, "license": [ @@ -3368,20 +3262,21 @@ "stringable", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/support", - "version": "v3.0.24", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/support.git", + "reference": "71eda508f6a8ecea3bdd9be14e8076d748f3567b" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/support/v3.0.24", - "reference": "2b752ac43c21f43f656394ad016260ec6b5325cc", - "shasum": "2b752ac43c21f43f656394ad016260ec6b5325cc" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/support/v3.0.37/hyperf-support-v3.0.37.zip", + "reference": "71eda508f6a8ecea3bdd9be14e8076d748f3567b", + "shasum": "" }, "require": { "hyperf/collection": "~3.0.0", @@ -3402,16 +3297,11 @@ } }, "autoload": { - "psr-4": { - "Hyperf\\Support\\": "src/" - }, "files": [ "src/Functions.php" - ] - }, - "autoload-dev": { + ], "psr-4": { - "HyperfTest\\Support\\": "tests/" + "Hyperf\\Support\\": "src/" } }, "license": [ @@ -3425,20 +3315,21 @@ "support", "swoole" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-21T04:06:36+00:00" }, { "name": "hyperf/tappable", - "version": "v3.0.0", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/tappable.git", + "reference": "00e9c0e2d90920aff60a67ffb122ac1842648a8d" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/tappable/v3.0.0", - "reference": "0d57f5e03f22a1f86a6b9838a6d44352e394b637", - "shasum": "0d57f5e03f22a1f86a6b9838a6d44352e394b637" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/tappable/v3.0.37/hyperf-tappable-v3.0.37.zip", + "reference": "00e9c0e2d90920aff60a67ffb122ac1842648a8d", + "shasum": "" }, "require": { "php": ">=7.4" @@ -3450,16 +3341,11 @@ } }, "autoload": { - "psr-4": { - "Hyperf\\Tappable\\": "src/" - }, "files": [ "src/Functions.php" - ] - }, - "autoload-dev": { + ], "psr-4": { - "HyperfTest\\Tappable\\": "tests/" + "Hyperf\\Tappable\\": "src/" } }, "license": [ @@ -3473,29 +3359,26 @@ "swoole", "tappable" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/translation", - "version": "v3.0.16", + "version": "v3.0.37", "source": { "type": "git", "url": "https://github.com/hyperf/translation.git", - "reference": "2fe511baa79816b14471de466bd665050b8b01f3" + "reference": "bea69dbec3e2f9ea24b272ff7af92962a2a37443" }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/proxy/archive/hyperf/translation/v3.0.16?source=%E5%AE%98%E6%96%B9%E6%BA%90", - "reference": "2fe511baa79816b14471de466bd665050b8b01f3", + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/translation/v3.0.37/hyperf-translation-v3.0.37.zip", + "reference": "bea69dbec3e2f9ea24b272ff7af92962a2a37443", "shasum": "" }, "require": { "hyperf/contract": "~3.0.0", "hyperf/macroable": "~3.0.0", + "hyperf/support": "~3.0.0", "hyperf/utils": "~3.0.0", "php": ">=8.0", "psr/container": "^1.0|^2.0" @@ -3510,12 +3393,12 @@ } }, "autoload": { - "psr-4": { - "Hyperf\\Translation\\": "src/" - }, "files": [ "src/Functions.php" - ] + ], + "psr-4": { + "Hyperf\\Translation\\": "src/" + } }, "license": [ "MIT" @@ -3525,16 +3408,21 @@ "hyperf", "translation" ], - "time": "2023-04-12T04:36:10+00:00" + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/utils", - "version": "v3.0.18", + "version": "v3.0.37", + "source": { + "type": "git", + "url": "https://github.com/hyperf/utils.git", + "reference": "1b8f487ce2290d4d2a2d137c92f10e10e0d8330b" + }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/archive/hyperf/utils/v3.0.18", - "reference": "b725f20b55609b2eae1711eea2be62c316144550", - "shasum": "b725f20b55609b2eae1711eea2be62c316144550" + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/utils/v3.0.37/hyperf-utils-v3.0.37.zip", + "reference": "1b8f487ce2290d4d2a2d137c92f10e10e0d8330b", + "shasum": "" }, "require": { "doctrine/inflector": "^2.0", @@ -3569,16 +3457,11 @@ } }, "autoload": { - "psr-4": { - "Hyperf\\Utils\\": "src/" - }, "files": [ "src/Functions.php" - ] - }, - "autoload-dev": { + ], "psr-4": { - "HyperfTest\\Utils\\": "tests/" + "Hyperf\\Utils\\": "src/" } }, "license": [ @@ -3592,41 +3475,42 @@ "swoole", "utils" ], - "support": { - "issues": "https://github.com/hyperf/hyperf/issues", - "source": "https://github.com/hyperf/hyperf", - "docs": "https://hyperf.wiki" - } + "time": "2023-09-19T01:50:18+00:00" }, { "name": "hyperf/validation", - "version": "v3.0.16", + "version": "v3.0.37", "source": { "type": "git", "url": "https://github.com/hyperf/validation.git", - "reference": "df511f856a93bbdfce39b345f084d812d2c6043d" + "reference": "4d2d9edcdae15203acbdff7f0884481706f277f5" }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/proxy/archive/hyperf/validation/v3.0.16?source=%E5%AE%98%E6%96%B9%E6%BA%90", - "reference": "df511f856a93bbdfce39b345f084d812d2c6043d", + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/validation/v3.0.37/hyperf-validation-v3.0.37.zip", + "reference": "4d2d9edcdae15203acbdff7f0884481706f277f5", "shasum": "" }, "require": { "egulias/email-validator": "^3.0", + "hyperf/collection": "~3.0.0", + "hyperf/conditionable": "~3.0.0", "hyperf/contract": "~3.0.0", "hyperf/database": "~3.0.0", "hyperf/di": "~3.0.0", "hyperf/framework": "~3.0.0", "hyperf/http-server": "~3.0.0", "hyperf/macroable": "~3.0.0", + "hyperf/stringable": "~3.0.0", + "hyperf/support": "~3.0.0", + "hyperf/tappable": "~3.0.0", "hyperf/translation": "~3.0.0", "hyperf/utils": "~3.0.0", "nesbot/carbon": "^2.21", "php": ">=8.0", "psr/container": "^1.0|^2.0", "psr/event-dispatcher": "^1.0", - "psr/http-message": "^1.0" + "psr/http-message": "^1.0|^2.0" }, "type": "library", "extra": { @@ -3650,7 +3534,7 @@ "hyperf", "validation" ], - "time": "2023-04-12T04:36:10+00:00" + "time": "2023-09-19T01:50:18+00:00" }, { "name": "intervention/image", @@ -3981,25 +3865,29 @@ }, { "name": "nesbot/carbon", - "version": "2.68.1", + "version": "2.71.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "4f991ed2a403c85efbc4f23eb4030063fdbe01da" + "reference": "98276233188583f2ff845a0f992a235472d9466a" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/nesbot/carbon/2.68.1/nesbot-carbon-2.68.1.zip", - "reference": "4f991ed2a403c85efbc4f23eb4030063fdbe01da", + "url": "https://mirrors.huaweicloud.com/repository/php/nesbot/carbon/2.71.0/nesbot-carbon-2.71.0.zip", + "reference": "98276233188583f2ff845a0f992a235472d9466a", "shasum": "" }, "require": { "ext-json": "*", "php": "^7.1.8 || ^8.0", + "psr/clock": "^1.0", "symfony/polyfill-mbstring": "^1.0", "symfony/polyfill-php80": "^1.16", "symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0" }, + "provide": { + "psr/clock-implementation": "1.0" + }, "require-dev": { "doctrine/dbal": "^2.0 || ^3.1.4", "doctrine/orm": "^2.7", @@ -4073,7 +3961,7 @@ "type": "tidelift" } ], - "time": "2023-06-20T18:29:04+00:00" + "time": "2023-09-25T11:31:05+00:00" }, { "name": "nikic/fast-route", @@ -4122,16 +4010,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.16.0", + "version": "v4.17.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "19526a33fb561ef417e822e85f08a00db4059c17" + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/nikic/php-parser/v4.16.0/nikic-php-parser-v4.16.0.zip", - "reference": "19526a33fb561ef417e822e85f08a00db4059c17", + "url": "https://mirrors.huaweicloud.com/repository/php/nikic/php-parser/v4.17.1/nikic-php-parser-v4.17.1.zip", + "reference": "a6303e50c90c355c7eeee2c4a8b27fe8dc8fef1d", "shasum": "" }, "require": { @@ -4169,7 +4057,7 @@ "parser", "php" ], - "time": "2023-06-25T14:52:30+00:00" + "time": "2023-08-13T19:53:39+00:00" }, { "name": "nyholm/psr7", @@ -4307,16 +4195,16 @@ }, { "name": "overtrue/socialite", - "version": "4.8.0", + "version": "4.9.0", "source": { "type": "git", "url": "https://github.com/overtrue/socialite.git", - "reference": "e55fdf50f8003be8f03a85a7e5a5b7c5716f4c9a" + "reference": "dcbb1eed948fe036e6de8cdf0b125f5af1bc73fb" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/overtrue/socialite/4.8.0/overtrue-socialite-4.8.0.zip", - "reference": "e55fdf50f8003be8f03a85a7e5a5b7c5716f4c9a", + "url": "https://mirrors.huaweicloud.com/repository/php/overtrue/socialite/4.9.0/overtrue-socialite-4.9.0.zip", + "reference": "dcbb1eed948fe036e6de8cdf0b125f5af1bc73fb", "shasum": "" }, "require": { @@ -4371,7 +4259,7 @@ "type": "github" } ], - "time": "2023-01-10T14:29:55+00:00" + "time": "2023-09-01T11:01:34+00:00" }, { "name": "paragonie/constant_time_encoding", @@ -4663,16 +4551,16 @@ }, { "name": "phpseclib/phpseclib", - "version": "3.0.21", + "version": "3.0.23", "source": { "type": "git", "url": "https://github.com/phpseclib/phpseclib.git", - "reference": "4580645d3fc05c189024eb3b834c6c1e4f0f30a1" + "reference": "866cc78fbd82462ffd880e3f65692afe928bed50" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/phpseclib/phpseclib/3.0.21/phpseclib-phpseclib-3.0.21.zip", - "reference": "4580645d3fc05c189024eb3b834c6c1e4f0f30a1", + "url": "https://mirrors.huaweicloud.com/repository/php/phpseclib/phpseclib/3.0.23/phpseclib-phpseclib-3.0.23.zip", + "reference": "866cc78fbd82462ffd880e3f65692afe928bed50", "shasum": "" }, "require": { @@ -4764,7 +4652,7 @@ "type": "tidelift" } ], - "time": "2023-07-09T15:24:48+00:00" + "time": "2023-09-18T17:22:01+00:00" }, { "name": "psr/cache", @@ -4811,6 +4699,49 @@ ], "time": "2021-02-03T23:26:27+00:00" }, + { + "name": "psr/clock", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/clock.git", + "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d" + }, + "dist": { + "type": "zip", + "url": "https://mirrors.huaweicloud.com/repository/php/psr/clock/1.0.0/psr-clock-1.0.0.zip", + "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Clock\\": "src/" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for reading the clock.", + "homepage": "https://github.com/php-fig/clock", + "keywords": [ + "clock", + "now", + "psr", + "psr-20", + "time" + ], + "time": "2022-11-25T14:36:26+00:00" + }, { "name": "psr/container", "version": "2.0.2", @@ -4906,16 +4837,16 @@ }, { "name": "psr/http-client", - "version": "1.0.2", + "version": "1.0.3", "source": { "type": "git", "url": "https://github.com/php-fig/http-client.git", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31" + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/psr/http-client/1.0.2/psr-http-client-1.0.2.zip", - "reference": "0955afe48220520692d2d09f7ab7e0f93ffd6a31", + "url": "https://mirrors.huaweicloud.com/repository/php/psr/http-client/1.0.3/psr-http-client-1.0.3.zip", + "reference": "bb5906edc1c324c9a05aa0873d40117941e5fa90", "shasum": "" }, "require": { @@ -4950,7 +4881,7 @@ "psr", "psr-18" ], - "time": "2023-04-10T20:12:12+00:00" + "time": "2023-09-23T14:17:50+00:00" }, { "name": "psr/http-factory", @@ -5968,16 +5899,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-ctype/v1.27.0/symfony-polyfill-ctype-v1.27.0.zip", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", + "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-ctype/v1.28.0/symfony-polyfill-ctype-v1.28.0.zip", + "reference": "ea208ce43cbb04af6867b4fdddb1bdbf84cc28cb", "shasum": "" }, "require": { @@ -5992,7 +5923,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6042,20 +5973,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "511a08c03c1960e08a883f4cffcacd219b758354" + "reference": "875e90aeea2777b6f135677f618529449334a612" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-intl-grapheme/v1.27.0/symfony-polyfill-intl-grapheme-v1.27.0.zip", - "reference": "511a08c03c1960e08a883f4cffcacd219b758354", + "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-intl-grapheme/v1.28.0/symfony-polyfill-intl-grapheme-v1.28.0.zip", + "reference": "875e90aeea2777b6f135677f618529449334a612", "shasum": "" }, "require": { @@ -6067,7 +5998,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6119,20 +6050,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "639084e360537a19f9ee352433b84ce831f3d2da" + "reference": "ecaafce9f77234a6a449d29e49267ba10499116d" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-intl-idn/v1.27.0/symfony-polyfill-intl-idn-v1.27.0.zip", - "reference": "639084e360537a19f9ee352433b84ce831f3d2da", + "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-intl-idn/v1.28.0/symfony-polyfill-intl-idn-v1.28.0.zip", + "reference": "ecaafce9f77234a6a449d29e49267ba10499116d", "shasum": "" }, "require": { @@ -6146,7 +6077,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6202,20 +6133,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:30:37+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6" + "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-intl-normalizer/v1.27.0/symfony-polyfill-intl-normalizer-v1.27.0.zip", - "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6", + "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-intl-normalizer/v1.28.0/symfony-polyfill-intl-normalizer-v1.28.0.zip", + "reference": "8c4ad05dd0120b6a53c1ca374dca2ad0a1c4ed92", "shasum": "" }, "require": { @@ -6227,7 +6158,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6282,20 +6213,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" + "reference": "42292d99c55abe617799667f454222c54c60e229" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-mbstring/v1.27.0/symfony-polyfill-mbstring-v1.27.0.zip", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-mbstring/v1.28.0/symfony-polyfill-mbstring-v1.28.0.zip", + "reference": "42292d99c55abe617799667f454222c54c60e229", "shasum": "" }, "require": { @@ -6310,7 +6241,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6361,20 +6292,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-07-28T09:04:16+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "869329b1e9894268a8a61dabb69153029b7a8c97" + "reference": "70f4aebd92afca2f865444d30a4d2151c13c3179" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-php72/v1.27.0/symfony-polyfill-php72-v1.27.0.zip", - "reference": "869329b1e9894268a8a61dabb69153029b7a8c97", + "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-php72/v1.28.0/symfony-polyfill-php72-v1.28.0.zip", + "reference": "70f4aebd92afca2f865444d30a4d2151c13c3179", "shasum": "" }, "require": { @@ -6383,7 +6314,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6433,20 +6364,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-php80/v1.27.0/symfony-polyfill-php80-v1.27.0.zip", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-php80/v1.28.0/symfony-polyfill-php80-v1.28.0.zip", + "reference": "6caa57379c4aec19c0a12a38b59b26487dcfe4b5", "shasum": "" }, "require": { @@ -6455,7 +6386,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6512,20 +6443,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/polyfill-php81", - "version": "v1.27.0", + "version": "v1.28.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a" + "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-php81/v1.27.0/symfony-polyfill-php81-v1.27.0.zip", - "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a", + "url": "https://mirrors.huaweicloud.com/repository/php/symfony/polyfill-php81/v1.28.0/symfony-polyfill-php81-v1.28.0.zip", + "reference": "7581cd600fa9fd681b797d00b02f068e2f13263b", "shasum": "" }, "require": { @@ -6534,7 +6465,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.27-dev" + "dev-main": "1.28-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6587,25 +6518,26 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2023-01-26T09:26:14+00:00" }, { "name": "symfony/psr-http-message-bridge", - "version": "v2.2.0", + "version": "v2.3.1", "source": { "type": "git", "url": "https://github.com/symfony/psr-http-message-bridge.git", - "reference": "28a732c05bbad801304ad5a5c674cf2970508993" + "reference": "581ca6067eb62640de5ff08ee1ba6850a0ee472e" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/symfony/psr-http-message-bridge/v2.2.0/symfony-psr-http-message-bridge-v2.2.0.zip", - "reference": "28a732c05bbad801304ad5a5c674cf2970508993", + "url": "https://mirrors.huaweicloud.com/repository/php/symfony/psr-http-message-bridge/v2.3.1/symfony-psr-http-message-bridge-v2.3.1.zip", + "reference": "581ca6067eb62640de5ff08ee1ba6850a0ee472e", "shasum": "" }, "require": { "php": ">=7.2.5", "psr/http-message": "^1.0 || ^2.0", + "symfony/deprecation-contracts": "^2.5 || ^3.0", "symfony/http-foundation": "^5.4 || ^6.0" }, "require-dev": { @@ -6624,7 +6556,7 @@ "type": "symfony-bridge", "extra": { "branch-alias": { - "dev-main": "2.2-dev" + "dev-main": "2.3-dev" } }, "autoload": { @@ -6670,7 +6602,7 @@ "type": "tidelift" } ], - "time": "2023-04-21T08:40:19+00:00" + "time": "2023-07-26T11:53:26+00:00" }, { "name": "symfony/service-contracts", @@ -7066,16 +6998,16 @@ }, { "name": "tecnickcom/tcpdf", - "version": "6.6.2", + "version": "6.6.5", "source": { "type": "git", "url": "https://github.com/tecnickcom/TCPDF.git", - "reference": "e3cffc9bcbc76e89e167e9eb0bbda0cab7518459" + "reference": "5fce932fcee4371865314ab7f6c0d85423c5c7ce" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/tecnickcom/tcpdf/6.6.2/tecnickcom-tcpdf-6.6.2.zip", - "reference": "e3cffc9bcbc76e89e167e9eb0bbda0cab7518459", + "url": "https://mirrors.huaweicloud.com/repository/php/tecnickcom/tcpdf/6.6.5/tecnickcom-tcpdf-6.6.5.zip", + "reference": "5fce932fcee4371865314ab7f6c0d85423c5c7ce", "shasum": "" }, "require": { @@ -7103,7 +7035,7 @@ ] }, "license": [ - "LGPL-3.0-only" + "LGPL-3.0-or-later" ], "authors": [ { @@ -7129,7 +7061,7 @@ "type": "custom" } ], - "time": "2022-12-17T10:28:59+00:00" + "time": "2023-09-06T15:09:26+00:00" }, { "name": "thenorthmemory/xml", @@ -7258,16 +7190,16 @@ }, { "name": "w7corp/easywechat", - "version": "6.12.1", + "version": "6.12.11", "source": { "type": "git", "url": "https://github.com/w7corp/easywechat.git", - "reference": "7487ea7bec3fce156d49f37d2d486535861ec636" + "reference": "81594e1068dadfb6caf354052689cedb2b6394f8" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/w7corp/easywechat/6.12.1/w7corp-easywechat-6.12.1.zip", - "reference": "7487ea7bec3fce156d49f37d2d486535861ec636", + "url": "https://mirrors.huaweicloud.com/repository/php/w7corp/easywechat/6.12.11/w7corp-easywechat-6.12.11.zip", + "reference": "81594e1068dadfb6caf354052689cedb2b6394f8", "shasum": "" }, "require": { @@ -7277,7 +7209,6 @@ "ext-openssl": "*", "ext-simplexml": "*", "ext-sodium": "*", - "monolog/monolog": "^2.2|^3.0", "nyholm/psr7": "^1.5", "nyholm/psr7-server": "^1.0", "overtrue/socialite": "^3.5.4|^4.0.1", @@ -7349,22 +7280,22 @@ "type": "github" } ], - "time": "2023-06-14T13:26:31+00:00" + "time": "2023-09-19T14:05:21+00:00" } ], "packages-dev": [ { "name": "composer/pcre", - "version": "3.1.0", + "version": "3.1.1", "source": { "type": "git", "url": "https://github.com/composer/pcre.git", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2" + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/composer/pcre/3.1.0/composer-pcre-3.1.0.zip", - "reference": "4bff79ddd77851fe3cdd11616ed3f92841ba5bd2", + "url": "https://mirrors.huaweicloud.com/repository/php/composer/pcre/3.1.1/composer-pcre-3.1.1.zip", + "reference": "00104306927c7a0919b4ced2aaa6782c1e61a3c9", "shasum": "" }, "require": { @@ -7417,20 +7348,20 @@ "type": "tidelift" } ], - "time": "2022-11-17T09:50:14+00:00" + "time": "2023-10-11T07:11:09+00:00" }, { "name": "composer/semver", - "version": "3.3.2", + "version": "3.4.0", "source": { "type": "git", "url": "https://github.com/composer/semver.git", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9" + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/composer/semver/3.3.2/composer-semver-3.3.2.zip", - "reference": "3953f23262f2bff1919fc82183ad9acb13ff62c9", + "url": "https://mirrors.huaweicloud.com/repository/php/composer/semver/3.4.0/composer-semver-3.4.0.zip", + "reference": "35e8d0af4486141bc745f23a29cc2091eb624a32", "shasum": "" }, "require": { @@ -7492,7 +7423,7 @@ "type": "tidelift" } ], - "time": "2022-04-01T19:23:25+00:00" + "time": "2023-08-31T09:50:34+00:00" }, { "name": "composer/xdebug-handler", @@ -7554,96 +7485,23 @@ ], "time": "2022-02-25T21:32:43+00:00" }, - { - "name": "doctrine/annotations", - "version": "2.0.1", - "source": { - "type": "git", - "url": "https://github.com/doctrine/annotations.git", - "reference": "e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f" - }, - "dist": { - "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/doctrine/annotations/2.0.1/doctrine-annotations-2.0.1.zip", - "reference": "e157ef3f3124bbf6fe7ce0ffd109e8a8ef284e7f", - "shasum": "" - }, - "require": { - "doctrine/lexer": "^2 || ^3", - "ext-tokenizer": "*", - "php": "^7.2 || ^8.0", - "psr/cache": "^1 || ^2 || ^3" - }, - "require-dev": { - "doctrine/cache": "^2.0", - "doctrine/coding-standard": "^10", - "phpstan/phpstan": "^1.8.0", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", - "symfony/cache": "^5.4 || ^6", - "vimeo/psalm": "^4.10" - }, - "suggest": { - "php": "PHP 8.0 or higher comes with attributes, a native replacement for annotations" - }, - "type": "library", - "autoload": { - "psr-4": { - "Doctrine\\Common\\Annotations\\": "lib/Doctrine/Common/Annotations" - } - }, - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Docblock Annotations Parser", - "homepage": "https://www.doctrine-project.org/projects/annotations.html", - "keywords": [ - "annotations", - "docblock", - "parser" - ], - "time": "2023-02-02T22:02:53+00:00" - }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.19.1", + "version": "v3.35.1", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "14772488aa1f31bd7ed767c390b96841ca687435" + "reference": "ec1ccc264994b6764882669973ca435cf05bab08" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/friendsofphp/php-cs-fixer/v3.19.1/friendsofphp-php-cs-fixer-v3.19.1.zip", - "reference": "14772488aa1f31bd7ed767c390b96841ca687435", + "url": "https://mirrors.huaweicloud.com/repository/php/friendsofphp/php-cs-fixer/v3.35.1/friendsofphp-php-cs-fixer-v3.35.1.zip", + "reference": "ec1ccc264994b6764882669973ca435cf05bab08", "shasum": "" }, "require": { "composer/semver": "^3.3", "composer/xdebug-handler": "^3.0.3", - "doctrine/annotations": "^2", - "doctrine/lexer": "^2 || ^3", "ext-json": "*", "ext-tokenizer": "*", "php": "^7.4 || ^8.0", @@ -7660,6 +7518,7 @@ "symfony/stopwatch": "^5.4 || ^6.0" }, "require-dev": { + "facile-it/paraunit": "^1.3 || ^2.0", "justinrainbow/json-schema": "^5.2", "keradus/cli-executor": "^2.0", "mikey179/vfsstream": "^1.6.11", @@ -7670,8 +7529,6 @@ "phpspec/prophecy": "^1.16", "phpspec/prophecy-phpunit": "^2.0", "phpunit/phpunit": "^9.5", - "phpunitgoodpractices/polyfill": "^1.6", - "phpunitgoodpractices/traits": "^1.9.2", "symfony/phpunit-bridge": "^6.2.3", "symfony/yaml": "^5.4 || ^6.0" }, @@ -7714,7 +7571,7 @@ "type": "github" } ], - "time": "2023-06-24T17:16:35+00:00" + "time": "2023-10-12T13:47:26+00:00" }, { "name": "hamcrest/hamcrest-php", @@ -7764,22 +7621,24 @@ }, { "name": "hyperf/devtool", - "version": "v3.0.16", + "version": "v3.0.37", "source": { "type": "git", "url": "https://github.com/hyperf/devtool.git", - "reference": "818acbd00bb4976c1175a57606d58bdaf964d6a3" + "reference": "eb3af1d8ee1f8e8d2f969c05dbfb34c50f51de8d" }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/proxy/archive/hyperf/devtool/v3.0.16?source=%E5%AE%98%E6%96%B9%E6%BA%90", - "reference": "818acbd00bb4976c1175a57606d58bdaf964d6a3", + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/devtool/v3.0.37/hyperf-devtool-v3.0.37.zip", + "reference": "eb3af1d8ee1f8e8d2f969c05dbfb34c50f51de8d", "shasum": "" }, "require": { + "hyperf/code-parser": "~3.0.0", "hyperf/command": "~3.0.0", "hyperf/contract": "~3.0.0", "hyperf/di": "~3.0.0", + "hyperf/support": "~3.0.0", "hyperf/utils": "~3.0.0", "php": ">=8.0" }, @@ -7808,30 +7667,35 @@ "php", "swoole" ], - "time": "2023-04-11T07:57:32+00:00" + "time": "2023-09-19T01:54:28+00:00" }, { "name": "hyperf/testing", - "version": "v3.0.16", + "version": "v3.0.38", "source": { "type": "git", "url": "https://github.com/hyperf/testing.git", - "reference": "f35d779b87b911202a607d33cd0dc800089aa1ad" + "reference": "4a87f5ccaf85814c75b928f44aa5c8ec71d1539d" }, "dist": { "type": "zip", - "url": "https://hyperf-cloud-composer.pkg.coding.net/limingxinleo/proxy/proxy/archive/hyperf/testing/v3.0.16?source=%E5%AE%98%E6%96%B9%E6%BA%90", - "reference": "f35d779b87b911202a607d33cd0dc800089aa1ad", + "url": "https://mirrors.huaweicloud.com/repository/php/hyperf/testing/v3.0.38/hyperf-testing-v3.0.38.zip", + "reference": "4a87f5ccaf85814c75b928f44aa5c8ec71d1539d", "shasum": "" }, "require": { + "hyperf/codec": "~3.0.0", + "hyperf/collection": "~3.0.0", "hyperf/contract": "~3.0.0", + "hyperf/coroutine": "~3.0.0", "hyperf/http-message": "~3.0.0", "hyperf/http-server": "~3.0.0", + "hyperf/support": "~3.0.0", "hyperf/utils": "~3.0.0", "php": ">=8.0", "phpunit/phpunit": "^9.5", - "psr/container": "^1.0|^2.0" + "psr/container": "^1.0|^2.0", + "symfony/http-foundation": "^5.4|^6.0" }, "bin": [ "co-phpunit" @@ -7856,41 +7720,37 @@ "swoole", "testing" ], - "time": "2023-04-12T04:36:10+00:00" + "time": "2023-09-30T11:21:49+00:00" }, { "name": "mockery/mockery", - "version": "1.6.2", + "version": "1.6.6", "source": { "type": "git", "url": "https://github.com/mockery/mockery.git", - "reference": "13a7fa2642c76c58fa2806ef7f565344c817a191" + "reference": "b8e0bb7d8c604046539c1115994632c74dcb361e" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/mockery/mockery/1.6.2/mockery-mockery-1.6.2.zip", - "reference": "13a7fa2642c76c58fa2806ef7f565344c817a191", + "url": "https://mirrors.huaweicloud.com/repository/php/mockery/mockery/1.6.6/mockery-mockery-1.6.6.zip", + "reference": "b8e0bb7d8c604046539c1115994632c74dcb361e", "shasum": "" }, "require": { "hamcrest/hamcrest-php": "^2.0.1", "lib-pcre": ">=7.0", - "php": "^7.4 || ^8.0" + "php": ">=7.3" }, "conflict": { "phpunit/phpunit": "<8.0" }, "require-dev": { - "phpunit/phpunit": "^8.5 || ^9.3", - "psalm/plugin-phpunit": "^0.18", - "vimeo/psalm": "^5.9" + "phpunit/phpunit": "^8.5 || ^9.6.10", + "psalm/plugin-phpunit": "^0.18.4", + "symplify/easy-coding-standard": "^11.5.0", + "vimeo/psalm": "^4.30" }, "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.6.x-dev" - } - }, "autoload": { "files": [ "library/helpers.php", @@ -7907,12 +7767,20 @@ { "name": "Pádraic Brady", "email": "padraic.brady@gmail.com", - "homepage": "http://blog.astrumfutura.com" + "homepage": "https://github.com/padraic", + "role": "Author" }, { "name": "Dave Marshall", "email": "dave.marshall@atstsolutions.co.uk", - "homepage": "http://davedevelopment.co.uk" + "homepage": "https://davedevelopment.co.uk", + "role": "Developer" + }, + { + "name": "Nathanael Esayeas", + "email": "nathanael.esayeas@protonmail.com", + "homepage": "https://github.com/ghostwriter", + "role": "Lead Developer" } ], "description": "Mockery is a simple yet flexible PHP mock object framework", @@ -7929,7 +7797,7 @@ "test double", "testing" ], - "time": "2023-06-07T09:07:52+00:00" + "time": "2023-08-09T00:03:52+00:00" }, { "name": "myclabs/deep-copy", @@ -8088,16 +7956,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.21", + "version": "1.10.38", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5" + "reference": "5302bb402c57f00fb3c2c015bac86e0827e4b691" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/phpstan/phpstan/1.10.21/phpstan-phpstan-1.10.21.zip", - "reference": "b2a30186be2e4d97dce754ae4e65eb0ec2f04eb5", + "url": "https://mirrors.huaweicloud.com/repository/php/phpstan/phpstan/1.10.38/phpstan-phpstan-1.10.38.zip", + "reference": "5302bb402c57f00fb3c2c015bac86e0827e4b691", "shasum": "" }, "require": { @@ -8138,20 +8006,20 @@ "type": "tidelift" } ], - "time": "2023-06-21T20:07:58+00:00" + "time": "2023-10-06T14:19:14+00:00" }, { "name": "phpunit/php-code-coverage", - "version": "9.2.27", + "version": "9.2.29", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1" + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/phpunit/php-code-coverage/9.2.27/phpunit-php-code-coverage-9.2.27.zip", - "reference": "b0a88255cb70d52653d80c890bd7f38740ea50d1", + "url": "https://mirrors.huaweicloud.com/repository/php/phpunit/php-code-coverage/9.2.29/phpunit-php-code-coverage-9.2.29.zip", + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", "shasum": "" }, "require": { @@ -8210,7 +8078,7 @@ "type": "github" } ], - "time": "2023-07-26T13:44:30+00:00" + "time": "2023-09-19T04:57:46+00:00" }, { "name": "phpunit/php-file-iterator", @@ -8435,16 +8303,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.10", + "version": "9.6.13", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a6d351645c3fe5a30f5e86be6577d946af65a328" + "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/phpunit/phpunit/9.6.10/phpunit-phpunit-9.6.10.zip", - "reference": "a6d351645c3fe5a30f5e86be6577d946af65a328", + "url": "https://mirrors.huaweicloud.com/repository/php/phpunit/phpunit/9.6.13/phpunit-phpunit-9.6.13.zip", + "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be", "shasum": "" }, "require": { @@ -8459,7 +8327,7 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpunit/php-code-coverage": "^9.2.13", + "phpunit/php-code-coverage": "^9.2.28", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", "phpunit/php-text-template": "^2.0.3", @@ -8528,7 +8396,7 @@ "type": "tidelift" } ], - "time": "2023-07-10T04:04:23+00:00" + "time": "2023-09-19T05:39:22+00:00" }, { "name": "sebastian/cli-parser", @@ -9416,16 +9284,16 @@ }, { "name": "swoole/ide-helper", - "version": "5.0.3", + "version": "5.1.0", "source": { "type": "git", "url": "https://github.com/swoole/ide-helper.git", - "reference": "4b6e615cb27c251b6248b8bd9501edbd02a45c18" + "reference": "07692fa8f1bb8eac828410acd613ea5877237b09" }, "dist": { "type": "zip", - "url": "https://mirrors.huaweicloud.com/repository/php/swoole/ide-helper/5.0.3/swoole-ide-helper-5.0.3.zip", - "reference": "4b6e615cb27c251b6248b8bd9501edbd02a45c18", + "url": "https://mirrors.huaweicloud.com/repository/php/swoole/ide-helper/5.1.0/swoole-ide-helper-5.1.0.zip", + "reference": "07692fa8f1bb8eac828410acd613ea5877237b09", "shasum": "" }, "type": "library", @@ -9439,7 +9307,7 @@ } ], "description": "IDE help files for Swoole.", - "time": "2023-04-28T22:20:18+00:00" + "time": "2023-10-05T04:52:59+00:00" }, { "name": "symfony/event-dispatcher", diff --git a/config/autoload/server.php b/config/autoload/server.php index 56f6afb..da29ba9 100644 --- a/config/autoload/server.php +++ b/config/autoload/server.php @@ -37,6 +37,7 @@ return [ Constant::OPTION_MAX_REQUEST => 100000, Constant::OPTION_SOCKET_BUFFER_SIZE => 2 * 1024 * 1024, Constant::OPTION_BUFFER_OUTPUT_SIZE => 2 * 1024 * 1024, + Constant::OPTION_PACKAGE_MAX_LENGTH => 5 * 1024 * 1024, // 接收数据包的最大长度 ], 'callbacks' => [ Event::ON_WORKER_START => [Hyperf\Framework\Bootstrap\WorkerStartCallback::class, 'onWorkerStart'], diff --git a/config/config.php b/config/config.php index 3197055..f412388 100644 --- a/config/config.php +++ b/config/config.php @@ -11,6 +11,7 @@ declare(strict_types=1); */ use Hyperf\Contract\StdoutLoggerInterface; use Psr\Log\LogLevel; +use function Hyperf\Support\env; return [ 'app_name' => env('APP_NAME', 'gdxz'), @@ -45,6 +46,8 @@ return [ "inquiry_refund_notify_url" => env('PATIENT_WECHAT_INQUIRY_REFUND_NOTIFY_URL', 'callback/wxpay/inquiry/refund'), "product_pay_notify_url" => env('PATIENT_WECHAT_PRODUCT_PAY_NOTIFY_URL', 'callback/wxpay/product/success'), "product_refund_notify_url" => env('PATIENT_WECHAT_PRODUCT_REFUND_NOTIFY_URL', 'callback/wxpay/product/refund'), + "detection_pay_notify_url" => env('PATIENT_WECHAT_DETECTION_PAY_NOTIFY_URL', 'callback/wxpay/detection/success'), + "detection_refund_notify_url" => env('PATIENT_WECHAT_DETECTION_REFUND_NOTIFY_URL', 'callback/wxpay/detection/refund'), ], "pharmacist" => [ "app_id" => env('DOCTOR_WECHAT_APP_ID', 'wxc83296720404aa7b'), @@ -109,4 +112,8 @@ return [ "api_url" => env('LOGISTICS_APP_URL', 'https://poll.kuaidi100.com/poll/query.do'), "salt" => env('LOGISTICS_SALT', 'gdxz2023.d'), ], + 'tencent_map' => [ // 腾讯地图 + "secret" => env('TENCENT_MAP_SECRET', 'RDQBZ-SDQ6Z-GKRX5-TG7P5-R2LN5-BWFCH'), + "key" => env('TENCENT_MAP_KEY', '6tZo4VootrcGOuYqRX9aoGdtAmuSNXd4') + ], ]; diff --git a/config/routes.php b/config/routes.php index 47dd9f2..ba62ff5 100644 --- a/config/routes.php +++ b/config/routes.php @@ -13,6 +13,7 @@ declare(strict_types=1); use App\Controller\AreaController; use App\Controller\BasicDataController; use App\Controller\CallBackController; +use App\Controller\DetectionController; use App\Controller\DoctorAccountController; use App\Controller\DoctorAuthController; use App\Controller\IndexController; @@ -265,6 +266,44 @@ Router::addGroup('/patient', function () { Router::get('/lowest-price', [InquiryController::class, 'getInquiryLowestPrice']); }); + // 检测 + Router::addGroup('/detection', function () { + // 创建检测订单 + Router::post('', [DetectionController::class, 'addDetectionOrder'], + [ + 'middleware' => [LockRequestMiddleware::class] // 锁定重复请求 + ] + ); + + // 获取患者进行中的检测订单 + Router::get('', [DetectionController::class, 'getDetectionOrderFirst']); + + // 绑定检测管 + Router::put('/bind/{order_detection_id:\d+}', [DetectionController::class, 'bindDetectionTube']); + + // 获取检测机构合作医生列表 + Router::get('/doctor', [DetectionController::class, 'getDetectionDoctorList']); + + // 检测项目 + Router::addGroup('/project', function () { + // 获取合作公司检测项目列表 + Router::get('', [DetectionController::class, 'getDetectionProjectList']); + + // 获取合作公司检测项目详情 + Router::get('/{detection_project_id:\d+}', [DetectionController::class, 'getDetectionProject']); + + // 获取检测项目用途列表 + Router::get('/purpose', [DetectionController::class, 'getDetectionProjectPurposeList']); + }); + + // 创建检测问诊订单 + Router::post('/inquiry/{order_detection_id:\d+}', [DetectionController::class, 'addDetectionInquiryOrder'], + [ + 'middleware' => [LockRequestMiddleware::class] // 锁定重复请求 + ] + ); + }); + // 医生数据 Router::addGroup('/doctor', function () { // 获取医生列表-问诊 @@ -410,6 +449,24 @@ Router::addGroup('/patient', function () { Router::delete('/{order_prescription_id:\d+}', [PatientOrderController::class, 'deletePatientPrescriptionOrder']); }); + // 检测订单 + Router::addGroup('/detection', function () { + // 获取患者检测订单列表 + Router::get('', [PatientOrderController::class, 'getPatientDetectionOrderList']); + + // 获取患者检测订单详情 + Router::get('/{order_no}', [PatientOrderController::class, 'getPatientDetectionOrderInfo']); + + // 删除检测订单 + Router::delete('/{order_detection_id:\d+}', [PatientOrderController::class, 'deletePatientDetectionOrder']); + + // 取消检测订单 + Router::put('/cancel/{order_detection_id:\d+}', [PatientOrderController::class, 'putCancelPatientDetectionOrder']); + + // 检测订单取消支付 + Router::put('/cancel-pay/{order_detection_id:\d+}', [PatientOrderController::class, 'putPatientDetectionOrderCancelPay']); + }); + // 获取患者订单支付数据 Router::get('/pay', [PatientOrderController::class, 'getPatientOrderPayInfo']); @@ -535,10 +592,13 @@ Router::addGroup('/basic', function () { Router::get('/search', [BasicDataController::class, 'getDiseaseIcdSearch']); }); - // 搜索商品 + // 商品 Router::addGroup('/product', function () { // 搜索商品 Router::get('/search', [BasicDataController::class, 'getProductSearch']); + + // 获取商品数据-分页 + Router::get('', [BasicDataController::class, 'getProductPage']); }); // 获取民族数据 @@ -552,6 +612,9 @@ Router::addGroup('/basic', function () { // 获取热门搜索关键词 Router::get('/keyword/search', [BasicDataController::class, 'getHotSearchKeyword']); + + // 获取检测疾病分类列表 + Router::get('/detection/disease', [BasicDataController::class, 'getDetectionDiseaseList']); }); // 获取医生评价 @@ -578,6 +641,7 @@ Router::addGroup('/callback', function () { // 退款回调 Router::post('/refund', [CallBackController::class, 'wxPayInquiryRefundCallBack']); }); + // 药品 Router::addGroup('/product', function () { // 支付成功回调 @@ -586,6 +650,15 @@ Router::addGroup('/callback', function () { // 退款回调 Router::post('/refund', [CallBackController::class, 'wxPayProductRefundCallBack']); }); + + // 检测 + Router::addGroup('/detection', function () { + // 支付成功回调 + Router::post('/success', [CallBackController::class, 'wxPayDetectionSuccessCallBack']); + + // 退款回调 + Router::post('/refund', [CallBackController::class, 'wxPayDetectionRefundCallBack']); + }); }); // im回调 @@ -599,6 +672,12 @@ Router::addGroup('/callback', function () { // 快递订阅查询 Router::post('', [CallBackController::class, 'LogisticsCallBack']); }); + + // 检测 + Router::addGroup('/detection', function () { + // 检测所结果回调 + Router::post('', [CallBackController::class, 'DetectionResultCallBack']); + }); }); // 用户 @@ -611,6 +690,18 @@ Router::addGroup('/user', function () { // 退出登陆 Router::put('/loginout', [UserController::class, 'putLoginout']); + + // 上报用户地址 + Router::post('/location', [UserController::class, 'postLocation']); + + // 获取用户地址 + Router::get('/location', [UserController::class, 'getLocation']); + + // 获取用户配置 + Router::get('/system', [UserController::class, 'getUserSystem']); + + // 修改用户配置 + Router::put('/system', [UserController::class, 'putUserSystem']); }); // 获取患者问诊病例 @@ -625,6 +716,9 @@ Router::addGroup('/test', function () { // 模拟退款 // Router::get('/refund', [TestController::class, 'refund']); + // 设置坐班医生 + Router::get('/doctor', [TestController::class, 'setDoctor']); + }); // 地址管理 @@ -664,6 +758,9 @@ Router::addGroup('/inquiry', function () { // 结束问诊 Router::put('/finish/{order_inquiry_id:\d+}', [InquiryController::class, 'putFinishInquiry']); + + // 获取患者最后一条问诊订单id + Router::get('/last', [InquiryController::class, 'getPatientLastInquiryId']); }); // 获取弹窗数据 diff --git a/extend/Alibaba/Dysms.php b/extend/Alibaba/Dysms.php index 29cd577..a5e566a 100644 --- a/extend/Alibaba/Dysms.php +++ b/extend/Alibaba/Dysms.php @@ -74,6 +74,11 @@ class Dysms public static function sendSms(string $phone_numbers,array $template_param,string $template_code,string $scene_desc = ""): void { try { + $app_env = config('app_env','dev'); + if ($app_env == "dev"){ + return; + } + $config = config("alibaba.dysms"); $client = self::createClient($config['accessKey'], $config['accessKeySecret']); diff --git a/extend/Alibaba/Oss.php b/extend/Alibaba/Oss.php index 092c3d2..2f744f4 100644 --- a/extend/Alibaba/Oss.php +++ b/extend/Alibaba/Oss.php @@ -110,13 +110,9 @@ class Oss public function getCusTomObjectToRAM(string $filename,string $style = "image/resize"): string { try { -// $download_file = "./runtime/aaa.jpg"; - - $ossClient = $this->createClient(); $options = array( OssClient::OSS_PROCESS => $style, -// OssClient::OSS_FILE_DOWNLOAD => $download_file, ); $object = $filename; diff --git a/extend/Detection/Base.php b/extend/Detection/Base.php new file mode 100644 index 0000000..8314228 --- /dev/null +++ b/extend/Detection/Base.php @@ -0,0 +1,103 @@ +container = ApplicationContext::getContainer(); + $this->client = $this->container->get(Client::class); + + // 获取检测机构数据 + $params = array(); + $params['detection_organ_id'] = $detection_organ_id; + $basic_detection_organ = BasicDetectionOrgan::getOne($params); + if (!empty($basic_detection_organ)){ + if (!empty($basic_detection_organ['app_id'])){ + $this->app_id = $basic_detection_organ['app_id']; + } + + if (!empty($basic_detection_organ['app_secret'])){ + $this->secret = $basic_detection_organ['app_secret']; + } + + $app_env = config("app_env","dev"); + if ($app_env == "dev"){ + if (!empty($basic_detection_organ['request_dev_url'])){ + $this->request_url = $basic_detection_organ['request_dev_url']; + } + }else{ + if (!empty($basic_detection_organ['request_prod_url'])){ + $this->request_url = $basic_detection_organ['request_prod_url']; + } + } + } + } + + + /** + * 请求封装 + * @param string $sign + * @param $path + * @param array $arg 请求参数 + * @return array + * @throws GuzzleException + */ + protected function httpRequest(string $sign,$path,array $arg = []): array + { + $option = [ + "headers" => [ + "source" => $sign + ] + ]; + + if (!empty($option)){ + $arg = array_merge($arg,$option); + } + + // 打印使用 + $l = $arg; + unset($l['json']['pictureOfDetectionTube']); + + Log::getInstance("请求参数")->info(json_encode($l,JSON_UNESCAPED_UNICODE)); + $response = $this->client->post($path, $arg); + + if ($response->getStatusCode() != '200'){ + // 请求失败 + throw new BusinessException($response->getBody()->getContents()); + } + + $body = json_decode($response->getBody(),true); + if (empty($body)){ + // 返回值为空 + throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); + } + + return $body; + } +} \ No newline at end of file diff --git a/extend/Detection/Wy.php b/extend/Detection/Wy.php new file mode 100644 index 0000000..0927481 --- /dev/null +++ b/extend/Detection/Wy.php @@ -0,0 +1,208 @@ +app_id) || empty($this->secret) || empty($this->request_url)){ + throw new BusinessException("缺少签名数据"); + } + + $time = date('Ymd'); + return md5($this->app_id . $this->secret . $time); + } + + /** + * 上报数据 + * @param array|object $order_detection + */ + public function report(string $order_detection_id) + { + $params = array(); + $params['order_detection_id'] = $order_detection_id; + $order_detection = OrderDetection::getOne($params); + if (empty($order_detection)){ + throw new BusinessException("检测订单数据错误"); + } + + // 获取检测订单病例数据 + $params = array(); + $params['order_detection_id'] = $order_detection['order_detection_id']; + $order_detection_case = OrderDetectionCase::getOne($params); + if (empty($order_detection_case)){ + throw new BusinessException("病例数据错误"); + } + + // 获取家庭成员数据 + $params = array(); + $params['family_id'] = $order_detection['family_id']; + $patient_family = PatientFamily::getOne($params); + if (empty($patient_family)){ + throw new BusinessException("患者家庭成员数据错误"); + } + + // 获取患者地址 + $params = array(); + $params['user_id'] = $order_detection['user_id']; + $user_location = UserLocation::getOne($params); + if (!empty($user_location)){ + $address = $user_location['province'] . $user_location['city'] . $user_location['county'] . $user_location['address']; + } + + // 获取医生数据 + $params = array(); + $params['doctor_id'] = $order_detection['doctor_id']; + $user_doctor = UserDoctor::getOne($params); + if (empty($user_doctor)){ + throw new BusinessException("医生数据错误"); + } + + // 获取医院数据 + $params = array(); + $params['hospital_id'] = $user_doctor['hospital_id']; + $hospital = Hospital::getOne($params); + if (empty($hospital)){ + throw new BusinessException("医院数据错误"); + } + + // 获取检测项目数据 + $params = array(); + $params['detection_project_id'] = $order_detection['detection_project_id']; + $detection_project = DetectionProject::getOne($params); + if (empty($detection_project)){ + throw new BusinessException("检测数据错误"); + } + + // 获取检测用途数据 + $params = array(); + $params['purpose_id'] = $order_detection['purpose_id']; + $detection_project_purpose = DetectionProjectPurpose::getOne($params); + if (empty($detection_project_purpose)){ + throw new BusinessException("检测数据错误"); + } + + // 获取用户数据 + $params = array(); + $params['user_id'] = $order_detection['user_id']; + $user = User::getOne($params); + if (empty($user)){ + throw new BusinessException("用户数据错误"); + } + + // 处理检测管图片 + $oss = new Oss(); + + $pics = []; + if (!empty($order_detection['detection_pic'])){ + $detection_pics = explode(',',$order_detection['detection_pic']); + foreach ($detection_pics as $key => $value){ + // 去除用户签名图片第一个/ oss不识别 + $value = substr($value, 1, strlen($value) - 1); + + $pic = $oss->getObjectToRAM($value); + if (empty($pic)){ + throw new BusinessException("检测管图片错误"); + } + + $pic = base64_encode($pic); + if (!$pic) { + throw new BusinessException("检测管图片下载失败"); + } + + $pics[$key]['pictureNo'] = $key + 1; // 图片序号 + $pics[$key]['pictureName'] = "检测管图片"; // 图片名称 + $pics[$key]['pictureInfo'] = $pic; // 对图片进行base64后的编码 + } + } + + + // 获取签名 + $sign = $this->getSign(); + + // 获取回调地址 + $app_env = \Hyperf\Config\config("app_env",'dev'); + if ($app_env == "prod"){ + $callback_url = env('DOMAIN_NAME_PROD','https://prod.hospital.applets.igandanyiyuan.com/'); + }else{ + $callback_url = env('DOMAIN_NAME_DEV','https://dev.hospital.applets.igandanyiyuan.com/'); + } + + $arg = array(); + $arg['appId'] = $this->app_id; + $arg['orderCode'] = $order_detection['detection_no']; // 订单编号 + $arg['orderTime'] = date('Y-m-d H:i:s',strtotime($order_detection['created_at'])); // 订单时间 + $arg['userPatientRelationships'] = $patient_family['relation']; // 操作用户与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 ) + $arg['patientName'] = $order_detection['patient_name']; // 患者姓名 + $arg['patientSex'] = $order_detection['patient_sex']; // 患者性别(0:未知 1:男 2:女) + $arg['patientAge'] = $order_detection['patient_age']; // 患者年龄 + $arg['patientNationality'] = $order_detection_case['nation_name']; // 患者民族 + $arg['patientPastMedicalHistory'] = $order_detection_case['detection_disease_class_names']; // 患者既往病史 + $arg['patientCardNo'] = $patient_family['id_number']; // 患者身份证号 + $arg['patientPhone'] = $user['mobile']; // 患者手机号 + $arg['patientAddress'] = $address ?? ""; // 患者住址(非必填) + $arg['detectBarCode'] = $order_detection['detection_bar_code']; // 检测条形码 + $arg['pictureOfDetectionTube'] = $pics; // 检测管图片数组 + $arg['hospitalName'] = $hospital['hospital_name']; // 医院名称(送检单位) + $arg['doctorName'] = $user_doctor['user_name']; // 医生名称 + $arg['sendSampleDate'] = date('Y-m-d'); // 送检日期(yyyy-MM-dd) + $arg['projectName'] = $detection_project['detection_project_name']; // 检测项目名称 + $arg['projectPurpose'] = $detection_project_purpose['purpose_name']; // 检测项目用途名称 + $arg['payTime'] = $order_detection['pay_time']; // 支付时间 + $arg['payAmount'] = $order_detection['payment_amount_total']; // 支付金额 + $arg['reportUrl'] = $callback_url . "callback/detection"; // 推送报告的回调地址 + + $option = [ + "json" => $arg + ]; + + $path = $this->request_url . "api/sdInternet/v1/externalData/saveOrder"; + try { + $response = $this->httpRequest($sign,$path,$option); + if (empty($response)){ + // 返回值错误为空 + throw new BusinessException(""); + } + + if (!isset($response['code'])){ + throw new BusinessException("上报数据返回值错误"); + } + + if ($response['code'] != 1){ + if (!isset($response['msg'])){ + throw new BusinessException("上报数据返回值错误"); + } + + if (empty($response['msg'])){ + throw new BusinessException("上报数据返回值错误"); + } + throw new BusinessException($response['msg']); + } + } catch (GuzzleException $e) { + throw new BusinessException($e->getMessage()); + } + } +} \ No newline at end of file diff --git a/extend/Tencent/map/Location.php b/extend/Tencent/map/Location.php new file mode 100644 index 0000000..b455569 --- /dev/null +++ b/extend/Tencent/map/Location.php @@ -0,0 +1,98 @@ +container = ApplicationContext::getContainer(); + $this->client = $this->container->get(Client::class); + } + + /** + * 计算签名 + * @param string $path + * @param array $query + * @return string + */ + private function getSign(string $path,array $query): string + { + ksort($query); + + // 拼接请求参数 + $queryString = urldecode(http_build_query($query)); + + // 拼接签名字符串 + $signatureStr = $path . '?' . $queryString . config("tencent_map.key"); + + // 计算签名,取MD5的小写形式 + $sig = md5($signatureStr); + + // 将签名添加到参数中 + $query['sig'] = $sig; + return $path . '?' . http_build_query($query); + } + /** + * 逆地址解析-根据经纬度获取地址 + * @param string $lon 经度,范围为 -180~180,负数表示西经 + * @param string $lat 纬度,范围为 -90~90,负数表示南纬 + * @return array + */ + public function getLocation(string $lon,string $lat): array + { + $query = [ + "key" => config("tencent_map.secret"), + "location" => $lat . "," . $lon, + ]; + + $path = "https://apis.map.qq.com" . $this->getSign("/ws/geocoder/v1",$query); + try { + $response = $this->client->get($path); + if ($response->getStatusCode() != '200') { + // 请求失败 + throw new BusinessException($response->getBody()->getContents()); + } + $body = json_decode($response->getBody(), true); + if (empty($body)) { + // 返回值为空 + throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); + } + + if ($body['status'] != 0){ + throw new BusinessException(HttpEnumCode::getMessage(HttpEnumCode::SERVER_ERROR)); + } + + if (empty($body['result'])){ + return []; + } + + return $body['result']; + } catch (GuzzleException $e) { + throw new BusinessException($e->getMessage()); + } + } +} \ No newline at end of file diff --git a/extend/TencentIm/Account.php b/extend/TencentIm/Account.php index 7640af2..2a539fc 100644 --- a/extend/TencentIm/Account.php +++ b/extend/TencentIm/Account.php @@ -36,7 +36,7 @@ class Account extends Base $path = $this->config['base_url'] . $this->version . "/im_open_login_svc/account_import?" . $this->buildRequestParams(); return $this->postRequest($path,$options); - }catch (\Exception $e) { + }catch (\Throwable $e) { throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR); } } @@ -74,7 +74,7 @@ class Account extends Base } return true; - }catch (\Exception $e) { + }catch (\Throwable $e) { throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR); } } diff --git a/extend/Wechat/Wechat.php b/extend/Wechat/Wechat.php index d995513..1ee160e 100644 --- a/extend/Wechat/Wechat.php +++ b/extend/Wechat/Wechat.php @@ -344,7 +344,7 @@ class Wechat } /** - * 生成UrlScheme + * 生成UrlLink * @throws NotFoundExceptionInterface * @throws RedirectionExceptionInterface * @throws ContainerExceptionInterface @@ -353,14 +353,14 @@ class Wechat * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ - public function createUrlScheme(array $options): array|string + public function createUrlLink(array $options): array|string { try { $this->createApp($this->config['app_id'], $this->config['secret']); $client = $this->createClient($this->config['app_id'], $this->config['secret']); - $response = $client->postJson('wxa/generatescheme', $options); + $response = $client->postJson('wxa/generate_urllink', $options); if ($response->isFailed()) { // 出错了,处理异常 @@ -382,7 +382,7 @@ class Wechat } /** - * 获取UrlScheme + * 获取UrlLink * @throws NotFoundExceptionInterface * @throws RedirectionExceptionInterface * @throws ContainerExceptionInterface @@ -391,14 +391,14 @@ class Wechat * @throws TransportExceptionInterface * @throws ServerExceptionInterface */ - public function getUrlScheme(array $options): array|string + public function getUrlLink(array $options): array|string { try { $this->createApp($this->config['app_id'], $this->config['secret']); $client = $this->createClient($this->config['app_id'], $this->config['secret']); - $response = $client->postJson('/wxa/queryscheme', $options); + $response = $client->postJson('wxa/query_urllink', $options); if ($response->isFailed()) { // 出错了,处理异常 diff --git a/extend/Wechat/WechatPay.php b/extend/Wechat/WechatPay.php index 0cea2a6..897f07d 100644 --- a/extend/Wechat/WechatPay.php +++ b/extend/Wechat/WechatPay.php @@ -28,7 +28,7 @@ class WechatPay /** * @param string $user_type 用户类型(1:患者端 2:专家端 3:药师端) - * @param int $order_type 订单类型(1:问诊订单 2:药品订单) + * @param int $order_type 订单类型(1:问诊订单 2:药品订单 3:检测订单) */ public function __construct(string $user_type,int $order_type) { @@ -46,7 +46,7 @@ class WechatPay throw new BusinessException("系统配置错误", HttpEnumCode::SERVER_ERROR); } - if (!in_array($order_type,[1,2])){ + if (!in_array($order_type,[1,2,3])){ throw new BusinessException("订单类型错误", HttpEnumCode::SERVER_ERROR); } @@ -60,6 +60,11 @@ class WechatPay $this->refund_notify_url = $this->config['product_refund_notify_url']; } + if ($order_type == 3){ + $this->pay_notify_url = $this->config['detection_pay_notify_url']; + $this->refund_notify_url = $this->config['detection_refund_notify_url']; + } + $app_env = config('app_env','dev'); if ($app_env == "prod"){ $this->domain_name = env('DOMAIN_NAME_PROD','https://prod.hospital.applets.igandanyiyuan.com/'); @@ -122,11 +127,12 @@ class WechatPay * @param string $out_trade_no 商户系统内部订单号 * @param int $total 支付金额(实际金额x100) * @param string $openid + * @param string $description 备注 * @return array * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ - public function getJsapiPrepayId(string $out_trade_no,int $total,string $openid): array + public function getJsapiPrepayId(string $out_trade_no,int $total,string $openid,string $description): array { $app = $this->createApp(); @@ -134,7 +140,7 @@ class WechatPay "mchid" => $this->pay_config['mch_id'], // <---- 商户号 "out_trade_no" => $out_trade_no, // 商户系统内部订单号 "appid" => $this->config['app_id'], - "description" => "问诊服务", + "description" => $description, "notify_url" => $this->domain_name . $this->pay_notify_url, "amount" => [ "total" => $total,//订单总金额,单位为分。