合并dev
This commit is contained in:
commit
9a03cb3962
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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消息-问诊已完成
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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消息-医生未接诊
|
||||
|
||||
@ -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; // 重回队列
|
||||
}
|
||||
}
|
||||
|
||||
288
app/Amqp/Consumer/DetectionCompleteDelayDirectConsumer.php
Normal file
288
app/Amqp/Consumer/DetectionCompleteDelayDirectConsumer.php
Normal file
@ -0,0 +1,288 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Consumer;
|
||||
|
||||
use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\DetectionCompleteDelayDirectProducer;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\DetectionProject;
|
||||
use App\Model\OrderDetection;
|
||||
use App\Model\OrderDetectionCase;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\PatientFamily;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Services\ImService;
|
||||
use App\Services\InquiryService;
|
||||
use App\Services\MessagePush;
|
||||
use App\Utils\Log;
|
||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\Amqp\Annotation\Consumer;
|
||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use PhpAmqpLib\Message\AMQPMessage;
|
||||
|
||||
#[Consumer(nums: 1)]
|
||||
class DetectionCompleteDelayDirectConsumer extends ConsumerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
use ConsumerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected ?string $queue = 'detection.complete.delay.queue';
|
||||
|
||||
protected string $type = Type::DIRECT; //Type::FANOUT;
|
||||
|
||||
protected string|array $routingKey = 'DetectionComplete';
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance("queue-DetectionComplete")->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;
|
||||
}
|
||||
}
|
||||
80
app/Amqp/Consumer/DoctorNotYetInquiryDelayDirectConsumer.php
Normal file
80
app/Amqp/Consumer/DoctorNotYetInquiryDelayDirectConsumer.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Consumer;
|
||||
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Services\MessagePush;
|
||||
use App\Utils\Log;
|
||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\Amqp\Annotation\Consumer;
|
||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use PhpAmqpLib\Message\AMQPMessage;
|
||||
|
||||
/**
|
||||
* 医生xx时间未接诊提醒
|
||||
*/
|
||||
#[Consumer(nums: 1)]
|
||||
class DoctorNotYetInquiryDelayDirectConsumer extends ConsumerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
use ConsumerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected ?string $queue = 'doctor.not.uet.inquiry.delay.queue';
|
||||
|
||||
protected string $type = Type::DIRECT; //Type::FANOUT;
|
||||
|
||||
protected string|array $routingKey = 'DoctorNotYetInquiry';
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance("queue-DoctorNotYetInquiry")->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;
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
|
||||
31
app/Amqp/Producer/DetectionCompleteDelayDirectProducer.php
Normal file
31
app/Amqp/Producer/DetectionCompleteDelayDirectProducer.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Producer;
|
||||
|
||||
use Hyperf\Amqp\Annotation\Producer;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerMessage;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
|
||||
/**
|
||||
* 检测订单自动完成延迟队列
|
||||
* 当接收到检测报告时,如当时患者-医生存在问诊中订单,则加入此延迟队列,等待问诊结束后,检测订单才会接收
|
||||
*/
|
||||
#[Producer]
|
||||
class DetectionCompleteDelayDirectProducer extends ProducerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected string $type = Type::DIRECT;
|
||||
|
||||
protected string|array $routingKey = 'DetectionComplete';
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->payload = $data;
|
||||
}
|
||||
}
|
||||
30
app/Amqp/Producer/DoctorNotYetInquiryDelayDirectProducer.php
Normal file
30
app/Amqp/Producer/DoctorNotYetInquiryDelayDirectProducer.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Producer;
|
||||
|
||||
use Hyperf\Amqp\Annotation\Producer;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerMessage;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
|
||||
/**
|
||||
* 医生xx时间未接诊提醒
|
||||
*/
|
||||
#[Producer]
|
||||
class DoctorNotYetInquiryDelayDirectProducer extends ProducerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected string $type = Type::DIRECT;
|
||||
|
||||
protected string|array $routingKey = 'DoctorNotYetInquiry';
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->payload = $data;
|
||||
}
|
||||
}
|
||||
@ -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){
|
||||
|
||||
123
app/Command/editDoctorInquiryConfigCommand.php
Normal file
123
app/Command/editDoctorInquiryConfigCommand.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Model\DoctorInquiryConfig;
|
||||
use App\Model\SystemInquiryConfig;
|
||||
use App\Model\UserDoctor;
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
#[Command]
|
||||
class editDoctorInquiryConfigCommand extends HyperfCommand
|
||||
{
|
||||
public function __construct(protected ContainerInterface $container)
|
||||
{
|
||||
parent::__construct('editDoctorInquiryConfig:command');
|
||||
}
|
||||
|
||||
public function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->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('结束');
|
||||
}
|
||||
}
|
||||
@ -170,6 +170,8 @@ function inquiryTypeToString(int|string $inquiry_type): string
|
||||
$result = "公益问诊";
|
||||
} elseif ($inquiry_type == 4) {
|
||||
$result = "问诊购药";
|
||||
} elseif ($inquiry_type == 5) {
|
||||
$result = "检测问诊";
|
||||
} else {
|
||||
$result = "未知";
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
122
app/Controller/DetectionController.php
Normal file
122
app/Controller/DetectionController.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Request\DetectionRequest;
|
||||
use App\Request\UserRequest;
|
||||
use App\Services\DetectionService;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class DetectionController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* 获取合作公司检测项目列表
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function getDetectionProjectList(): ResponseInterface
|
||||
{
|
||||
$detectionService = new DetectionService();
|
||||
$data = $detectionService->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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Amqp\Producer\PrescriptionDistributePhProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Model\OrderPrescriptionIcd;
|
||||
use App\Model\OrderPrescriptionProduct;
|
||||
|
||||
73
app/Model/BasicCompany.php
Normal file
73
app/Model/BasicCompany.php
Normal file
@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
|
||||
/**
|
||||
* @property int $company_id 主键id
|
||||
* @property string $company_name 公司名称
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class BasicCompany extends Model
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'basic_company';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['company_id', 'company_name', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "company_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->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);
|
||||
}
|
||||
}
|
||||
83
app/Model/BasicDetectionOrgan.php
Normal file
83
app/Model/BasicDetectionOrgan.php
Normal file
@ -0,0 +1,83 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $detection_organ_id 主键id
|
||||
* @property int $company_id 合作公司id
|
||||
* @property string $detection_organ_name 检测机构名称
|
||||
* @property string $app_id key
|
||||
* @property string $app_secret 秘钥
|
||||
* @property int $status 状态(1:正常 2:删除)
|
||||
* @property string $request_dev_url 测试请求地址
|
||||
* @property string $request_prod_url 正式请求地址
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class BasicDetectionOrgan extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'basic_detection_organ';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['detection_organ_id', 'company_id', 'detection_organ_name', 'app_id', 'app_secret', 'status', 'request_dev_url', 'request_prod_url', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "detection_organ_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->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);
|
||||
}
|
||||
|
||||
}
|
||||
82
app/Model/DetectionProject.php
Normal file
82
app/Model/DetectionProject.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $detection_project_id 主键id
|
||||
* @property string $detection_project_title 检测项目标题
|
||||
* @property string $detection_project_name 检测项目名称
|
||||
* @property int $company_id 合作公司id
|
||||
* @property string $detection_project_price 检测价格
|
||||
* @property int $detection_time 检测时间(小时)
|
||||
* @property string $img_path 内容图片地址
|
||||
* @property string $informed_consent_form 知情同意书
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class DetectionProject extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'detection_project';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['detection_project_id', 'detection_project_title', 'detection_project_name', 'company_id', 'detection_project_price', 'detection_time', 'img_path', 'informed_consent_form', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "detection_project_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->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);
|
||||
}
|
||||
}
|
||||
77
app/Model/DetectionProjectPurpose.php
Normal file
77
app/Model/DetectionProjectPurpose.php
Normal file
@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $purpose_id 主键id
|
||||
* @property int $detection_project_id 检测项目id
|
||||
* @property string $purpose_name 用途名称
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class DetectionProjectPurpose extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'detection_project_purpose';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['purpose_id', 'detection_project_id', 'purpose_name', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "purpose_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->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);
|
||||
}
|
||||
}
|
||||
80
app/Model/DiseaseClassDetection.php
Normal file
80
app/Model/DiseaseClassDetection.php
Normal file
@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $id 主键id
|
||||
* @property int $detection_project_id 检测项目id
|
||||
* @property string $name 疾病分类名称
|
||||
* @property int $status 状态(1:正常 2:删除)
|
||||
* @property int $enable 是否启用(1:是 2:否)
|
||||
* @property int $sort 排序值(越小排序越往前)
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class DiseaseClassDetection extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'disease_class_detection';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['id', 'detection_project_id', 'name', 'status', 'enable', 'sort', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->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);
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
168
app/Model/OrderDetection.php
Normal file
168
app/Model/OrderDetection.php
Normal file
@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Builder;
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $order_detection_id 主键id
|
||||
* @property int $user_id 用户id-患者
|
||||
* @property int $patient_id 患者id
|
||||
* @property int $doctor_id 医生id
|
||||
* @property int $family_id 家庭成员id(就诊用户)
|
||||
* @property int $detection_project_id 检测项目id
|
||||
* @property int $purpose_id 检测项目用途id
|
||||
* @property int $detection_organ_id 检测机构id
|
||||
* @property int $order_inquiry_id 问诊-订单id(检测完成后,会生成此字段)
|
||||
* @property int $detection_status 检测订单状态(1:待支付 2:待绑定 3:检测中 4:检测完成 5:已取消)
|
||||
* @property int $is_delete 删除状态(0:否 1:是)
|
||||
* @property int $detection_refund_status 检测订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
* @property int $detection_pay_channel 支付渠道(1:小程序支付 2:微信扫码支付 3:模拟支付)
|
||||
* @property int $detection_pay_status 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
* @property string $detection_no 系统订单编号
|
||||
* @property string $escrow_trade_no 第三方支付流水号
|
||||
* @property string $amount_total 订单金额
|
||||
* @property string $coupon_amount_total 优惠卷总金额
|
||||
* @property string $payment_amount_total 实际付款金额
|
||||
* @property string $pay_time 支付时间
|
||||
* @property string $cancel_time 订单取消时间
|
||||
* @property int $cancel_reason 取消订单原因(1:主动取消 2:客服取消 3:支付超时)
|
||||
* @property string $cancel_remarks 取消订单备注(自动添加)
|
||||
* @property string $patient_name 患者姓名-就诊人
|
||||
* @property string $patient_name_mask 患者姓名-就诊人(掩码)
|
||||
* @property int $patient_sex 患者性别-就诊人(0:未知 1:男 2:女)
|
||||
* @property int $patient_age 患者年龄-就诊人
|
||||
* @property string $detection_bar_code 检测条码
|
||||
* @property string $detection_pic 检测管图片(逗号分隔)
|
||||
* @property string $detection_time 上传检测时间
|
||||
* @property string $detection_result_pdf 检测结果
|
||||
* @property string $detection_result_date 检测结果时间
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderDetection extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_detection';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_detection_id', 'user_id', 'patient_id', 'doctor_id', 'family_id', 'detection_project_id', 'purpose_id', 'detection_organ_id', 'order_inquiry_id', 'detection_status', 'is_delete', 'detection_refund_status', 'detection_pay_channel', 'detection_pay_status', 'detection_no', 'escrow_trade_no', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'pay_time', 'cancel_time', 'cancel_reason', 'cancel_remarks', 'patient_name', 'patient_name_mask', 'patient_sex', 'patient_age', 'detection_bar_code', 'detection_pic', 'detection_time', 'detection_result_pdf', 'detection_result_date', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_detection_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->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();
|
||||
}
|
||||
}
|
||||
87
app/Model/OrderDetectionCase.php
Normal file
87
app/Model/OrderDetectionCase.php
Normal file
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $detection_case_id 主键id
|
||||
* @property int $order_detection_id 订单-检测id
|
||||
* @property int $family_id 家庭成员id
|
||||
* @property int $doctor_id 医生id(检测医生)
|
||||
* @property int $relation 与患者关系(1:本人 2:父母 3:爱人 4:子女 5:亲戚 6:其他 )
|
||||
* @property string $name 患者名称
|
||||
* @property int $sex 患者性别(0:未知 1:男 2:女)
|
||||
* @property int $age 患者年龄
|
||||
* @property int $nation_id 民族
|
||||
* @property string $nation_name 民族名称
|
||||
* @property string $detection_disease_class_ids 疾病id-检测-逗号分隔
|
||||
* @property string $detection_disease_class_names 疾病名称-检测-逗号分隔
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderDetectionCase extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_detection_case';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['detection_case_id', 'order_detection_id', 'family_id', 'doctor_id', 'relation', 'name', 'sex', 'age', 'nation_id', 'nation_name', 'detection_disease_class_ids', 'detection_disease_class_names', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "detection_case_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->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);
|
||||
}
|
||||
|
||||
}
|
||||
84
app/Model/OrderDetectionRefund.php
Normal file
84
app/Model/OrderDetectionRefund.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $detection_refund_id 主键id
|
||||
* @property int $order_detection_id 订单-检测id
|
||||
* @property int $patient_id 患者id
|
||||
* @property string $detection_no 系统订单编号
|
||||
* @property string $detection_refund_no 系统退款编号
|
||||
* @property string $refund_id 第三方退款单号
|
||||
* @property int $detection_refund_status 检测订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
* @property string $refund_total 退款金额
|
||||
* @property string $refund_reason 退款原因
|
||||
* @property string $success_time 退款成功时间
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderDetectionRefund extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_detection_refund';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['detection_refund_id', 'order_detection_id', 'patient_id', 'detection_no', 'detection_refund_no', 'refund_id', 'detection_refund_status', 'refund_total', 'refund_reason', 'success_time', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "detection_refund_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->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);
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
82
app/Model/OrderSystem.php
Normal file
82
app/Model/OrderSystem.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $system_id 主键id
|
||||
* @property string $system_name 配置名称
|
||||
* @property string $system_remarks 配置备注
|
||||
* @property int $system_status 配置状态(1:开启 2:关闭)
|
||||
* @property string $system_permission 事件标识
|
||||
* @property int $is_sms 是否需要短信通知(0:否 1:是)
|
||||
* @property string $sms_mobile 短信通知手机号
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class OrderSystem extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'order_system';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['system_id', 'system_name', 'system_remarks', 'system_status', 'system_permission', 'is_sms', 'sms_mobile', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "family_id";
|
||||
|
||||
/**
|
||||
* 获取数据-单
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -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
|
||||
|
||||
@ -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";
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
82
app/Model/UserLocation.php
Normal file
82
app/Model/UserLocation.php
Normal file
@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $user_location_id 主键id
|
||||
* @property int $user_id 用户id
|
||||
* @property string $lon 经度,范围为 -180~180,负数表示西经
|
||||
* @property string $lat 纬度,范围为 -90~90,负数表示南纬
|
||||
* @property string $province 省份
|
||||
* @property string $city 城市
|
||||
* @property string $county 区县
|
||||
* @property string $address 详细地址
|
||||
* @property string $create_time 创建时间
|
||||
* @property string $update_time 更新时间
|
||||
*/
|
||||
class UserLocation extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'user_location';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['user_location_id', 'user_id', 'lon', 'lat', 'province', 'city', 'county', 'address', 'create_time', 'update_time'];
|
||||
|
||||
protected string $primaryKey = "user_location_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->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);
|
||||
}
|
||||
}
|
||||
98
app/Model/UserSystem.php
Normal file
98
app/Model/UserSystem.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
|
||||
|
||||
use Hyperf\Database\Model\Collection;
|
||||
use Hyperf\Snowflake\Concern\Snowflake;
|
||||
|
||||
/**
|
||||
* @property int $user_system_id 主键id
|
||||
* @property int $user_id 用户id
|
||||
* @property int $is_accept_im_message_push 是否接受im消息推送(0:否 1:是)
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
*/
|
||||
class UserSystem extends Model
|
||||
{
|
||||
use Snowflake;
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*/
|
||||
protected ?string $table = 'user_system';
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['user_system_id', 'user_id', 'is_accept_im_message_push', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "user_system_id";
|
||||
|
||||
/**
|
||||
* 获取信息-单条
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return object|null
|
||||
*/
|
||||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||||
{
|
||||
return self::where($params)->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);
|
||||
}
|
||||
|
||||
}
|
||||
@ -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),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
88
app/Request/DetectionRequest.php
Normal file
88
app/Request/DetectionRequest.php
Normal file
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
|
||||
class DetectionRequest extends FormRequest
|
||||
{
|
||||
protected array $scenes = [
|
||||
'addDetectionOrder' => [ // 创建检测订单
|
||||
'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' => "请选择城市",
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -42,6 +42,10 @@ class InquiryRequest extends FormRequest
|
||||
'getPatientInquiryCase' => [ // 获取患者问诊病例
|
||||
'order_inquiry_id',
|
||||
],
|
||||
'getPatientLastInquiryId' => [ // 获取患者最后一条问诊订单id
|
||||
'patient_id',
|
||||
'doctor_id',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@ -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),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -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',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -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',
|
||||
|
||||
@ -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),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
@ -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'];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
981
app/Services/DetectionService.php
Normal file
981
app/Services/DetectionService.php
Normal file
@ -0,0 +1,981 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer;
|
||||
use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer;
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\Area;
|
||||
use App\Model\BasicCompany;
|
||||
use App\Model\BasicDetectionOrgan;
|
||||
use App\Model\BasicNation;
|
||||
use App\Model\DetectionProject;
|
||||
use App\Model\DetectionProjectPurpose;
|
||||
use App\Model\DiseaseClassDetection;
|
||||
use App\Model\OrderDetection;
|
||||
use App\Model\OrderDetectionCase;
|
||||
use App\Model\OrderDetectionRefund;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\PatientFamily;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserLocation;
|
||||
use App\Utils\Log;
|
||||
use App\Utils\PcreMatch;
|
||||
use Extend\Detection\Wy;
|
||||
use Extend\Wechat\WechatPay;
|
||||
use Hyperf\Amqp\Producer;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Hyperf\Snowflake\IdGeneratorInterface;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
|
||||
class DetectionService extends BaseService
|
||||
{
|
||||
/**
|
||||
* 获取合作公司检测项目列表
|
||||
* @return array
|
||||
*/
|
||||
public function getDetectionProjectList(): array
|
||||
{
|
||||
$company_id = $this->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);
|
||||
}
|
||||
}
|
||||
@ -722,7 +722,7 @@ class DoctorAuthService extends BaseService
|
||||
}
|
||||
|
||||
if (empty($doctor_info_data)) {
|
||||
return success();
|
||||
return fail(HttpEnumCode::HTTP_ERROR,"请您修改后再提交");
|
||||
}
|
||||
|
||||
Db::beginTransaction();
|
||||
|
||||
@ -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次");
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -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();
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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;
|
||||
|
||||
@ -1,911 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Services;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\OrderInquiry;
|
||||
use App\Model\OrderProduct;
|
||||
use App\Model\PatientFamily;
|
||||
use App\Model\Product;
|
||||
use App\Model\UserCaCert;
|
||||
use App\Model\HospitalDepartmentCustom;
|
||||
use App\Model\OrderInquiryCase;
|
||||
use App\Model\OrderPrescription;
|
||||
use App\Model\OrderPrescriptionIcd;
|
||||
use App\Model\OrderPrescriptionProduct;
|
||||
use App\Model\OrderProductItem;
|
||||
use App\Model\User;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserDoctorInfo;
|
||||
use App\Model\UserPharmacist;
|
||||
use App\Model\UserPharmacistInfo;
|
||||
use App\Utils\Log;
|
||||
use Extend\Alibaba\Oss;
|
||||
use Extend\Ca\Ca;
|
||||
use Extend\Ca\CaOffline;
|
||||
use Extend\Ca\CaOnline;
|
||||
use Extend\Prescription\Prescription;
|
||||
use Hyperf\Contract\LengthAwarePaginatorInterface;
|
||||
use Hyperf\Utils\WaitGroup;
|
||||
use Intervention\Image\ImageManager;
|
||||
use Swoole\Coroutine\Channel;
|
||||
use TCPDF;
|
||||
|
||||
class OrderPrescriptionService_1 extends BaseService
|
||||
{
|
||||
/**
|
||||
* 获取医生是否存在被驳回处方
|
||||
* @param string $doctor_id 医生id
|
||||
* @return bool
|
||||
*/
|
||||
public function getDoctorExistsAuditFail(string $doctor_id): bool
|
||||
{
|
||||
$params = array();
|
||||
$params['doctor_id'] = $doctor_id;
|
||||
$params['pharmacist_audit_status'] = 2;// 处方审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||
$params['platform_audit_status'] = 1;// 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||
$params['is_delete'] = 0;// 是否删除(0:否 1:是)
|
||||
return OrderPrescription::getExists($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取药师待审核处方-分页
|
||||
* @param string $pharmacist_id 药师id
|
||||
* @param int $pharmacist_audit_status 药师审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||
* @param int $platform_audit_status
|
||||
* @param string|int $page
|
||||
* @param string|int $per_page
|
||||
* @return array
|
||||
*/
|
||||
public function getPharmacistWaitAuditPage(string $pharmacist_id, int $pharmacist_audit_status, int $platform_audit_status, string|int $page = 1, string|int $per_page = 10): array
|
||||
{
|
||||
$params = array();
|
||||
$params['pharmacist_id'] = $pharmacist_id;
|
||||
if ($pharmacist_audit_status == 0 && $platform_audit_status == 0){
|
||||
$params['prescription_status'] = 1; // 处方状态(1:待审核 2:待使用 3:已失效 4:已使用)
|
||||
}
|
||||
$params['pharmacist_audit_status'] = $pharmacist_audit_status; // 药师审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||
$params['platform_audit_status'] = $platform_audit_status; // 处方平台审核状态(0:审核中 1:审核成功 2:审核驳回)
|
||||
|
||||
return OrderPrescription::getPage($params, ['*'], $page, $per_page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取处方中开方药品
|
||||
* @param string|int $order_prescription_id
|
||||
* @return array
|
||||
*/
|
||||
public function getproductList(string|int $order_prescription_id): array
|
||||
{
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_prescription_id;
|
||||
$order_prescription_products = OrderPrescriptionProduct::getLimit($params);
|
||||
if (empty($order_prescription_products)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$result = [];
|
||||
|
||||
foreach ($order_prescription_products as $order_prescription_product) {
|
||||
$data = array();
|
||||
$data['product_id'] = $order_prescription_product['product_id'];
|
||||
$data['prescription_product_num'] = $order_prescription_product['prescription_product_num'];
|
||||
$data['product_name'] = $order_prescription_product['product_name'] ?? "";
|
||||
$data['product_spec'] = $order_prescription_product['product_spec'] ?? "";
|
||||
$data['single_unit'] = $order_prescription_product['single_unit'] ?? "";
|
||||
$data['single_use'] = $order_prescription_product['single_use'] ?? "";
|
||||
$data['packaging_unit'] = $order_prescription_product['packaging_unit'] ?? "";
|
||||
$data['frequency_use'] = $order_prescription_product['frequency_use'] ?? "";
|
||||
$data['available_days'] = $order_prescription_product['available_days'] ?? 0;
|
||||
|
||||
$result[] = $data;
|
||||
}
|
||||
|
||||
unset($order_product_items);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取患者某一状态下的处方数量
|
||||
* @param string $patient_id 患者id
|
||||
* @param int $prescription_status 处方状态(1:待审核 2:待使用 3:已失效 4:已使用)
|
||||
* @return int
|
||||
*/
|
||||
public function getPatientPrescriptionWithStatus(string $patient_id, int $prescription_status): int
|
||||
{
|
||||
$params = array();
|
||||
$params['patient_id'] = $patient_id;
|
||||
$params['prescription_status'] = $prescription_status;
|
||||
$params['pharmacist_audit_status'] = 1;
|
||||
return OrderPrescription::getCount($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 开具处方
|
||||
* 医生-正常开具
|
||||
* 药师-先开具药师处方,再开具医院签章
|
||||
* @param string $order_prescription_id
|
||||
* @param string $user_id
|
||||
* @return array
|
||||
*/
|
||||
public function openPrescription(string $order_prescription_id, 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['user_id'] = $user['user_id'];
|
||||
if ($user['user_type'] == 2) {
|
||||
$user_doctor_info = UserDoctorInfo::getOne($params);
|
||||
if (empty($user_doctor_info)) {
|
||||
throw new BusinessException("用户数据错误");
|
||||
}
|
||||
|
||||
$user_sign_image_path = $user_doctor_info['sign_image'];
|
||||
$user_entity_id = "491925054435950592";
|
||||
} else {
|
||||
$user_pharmacist_info = UserPharmacistInfo::getOne($params);
|
||||
if (empty($user_pharmacist_info)) {
|
||||
throw new BusinessException("用户数据错误");
|
||||
}
|
||||
|
||||
$user_sign_image_path = $user_pharmacist_info['sign_image'];
|
||||
$user_entity_id = $user['user_id'];
|
||||
|
||||
$hospital_sign_image_path = "basic/file/hospital_signature.png";
|
||||
$hospital_entity_id = "5345345461";
|
||||
}
|
||||
|
||||
if (empty($user_sign_image_path) || empty($user_entity_id)) {
|
||||
throw new BusinessException("无签名图片/用户唯一标识");
|
||||
}
|
||||
|
||||
// 去除第一个/ oss不识别
|
||||
$sign_image_path = substr($user_sign_image_path, 1, strlen($user_sign_image_path) - 1);
|
||||
|
||||
// 获取处方数据
|
||||
$params = array();
|
||||
$params['order_prescription_id'] = $order_prescription_id;
|
||||
$order_prescription = OrderPrescription::getOne($params);
|
||||
if (empty($order_prescription)) {
|
||||
throw new BusinessException("处方数据错误");
|
||||
}
|
||||
|
||||
if (empty($order_prescription['doctor_created_time'])) {
|
||||
throw new BusinessException("医生开方日期错误");
|
||||
}
|
||||
|
||||
// 检测处方图片
|
||||
if ($user['user_type'] == 3 && empty($order_prescription['prescription_img'])) {
|
||||
throw new BusinessException("处方图片错误");
|
||||
}
|
||||
|
||||
// 创建协程客户端
|
||||
$wg = new WaitGroup();
|
||||
|
||||
// 创建通道
|
||||
$channel = new Channel();
|
||||
|
||||
$wg->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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -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);
|
||||
|
||||
@ -42,6 +42,8 @@ class PatientFamilyService extends BaseService
|
||||
'card_name_mask',
|
||||
'sex',
|
||||
'age',
|
||||
'nation_id',
|
||||
'nation_name',
|
||||
];
|
||||
$patient_familys = PatientFamilyModel::getList($params, $field);
|
||||
|
||||
|
||||
@ -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'];
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +52,10 @@ class SafeService extends BaseService
|
||||
// 名片
|
||||
$dir = $dir . 'card/';
|
||||
break;
|
||||
case 4:
|
||||
// 检测管
|
||||
$dir = $dir . 'detection/';
|
||||
break;
|
||||
|
||||
default:
|
||||
// code...
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -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", // 检测所结果回调
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@ -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/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1488
composer.lock
generated
1488
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@ -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'],
|
||||
|
||||
@ -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')
|
||||
],
|
||||
];
|
||||
|
||||
@ -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']);
|
||||
});
|
||||
|
||||
// 获取弹窗数据
|
||||
|
||||
@ -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']);
|
||||
|
||||
@ -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;
|
||||
|
||||
103
extend/Detection/Base.php
Normal file
103
extend/Detection/Base.php
Normal file
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace Extend\Detection;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\BasicDetectionOrgan;
|
||||
use App\Utils\Log;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\Context\ApplicationContext;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use \Hyperf\Config\config;
|
||||
|
||||
/**
|
||||
* 对接检测所
|
||||
*/
|
||||
class Base
|
||||
{
|
||||
#[Inject]
|
||||
protected ContainerInterface $container;
|
||||
|
||||
#[Inject]
|
||||
protected Client $client;
|
||||
|
||||
protected string $app_id;
|
||||
protected string $secret; // 秘钥
|
||||
protected string $request_url; // 请求地址
|
||||
|
||||
public function __construct(string $detection_organ_id)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
208
extend/Detection/Wy.php
Normal file
208
extend/Detection/Wy.php
Normal file
@ -0,0 +1,208 @@
|
||||
<?php
|
||||
|
||||
namespace Extend\Detection;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use App\Model\DetectionProject;
|
||||
use App\Model\DetectionProjectPurpose;
|
||||
use App\Model\Hospital;
|
||||
use App\Model\OrderDetection;
|
||||
use App\Model\OrderDetectionCase;
|
||||
use App\Model\PatientFamily;
|
||||
use App\Model\User;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserLocation;
|
||||
use App\Utils\Log;
|
||||
use Extend\Alibaba\Oss;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
|
||||
/**
|
||||
* 微远检测所
|
||||
*/
|
||||
class Wy extends Base
|
||||
{
|
||||
/**
|
||||
* 获取签名
|
||||
* @return string
|
||||
*/
|
||||
public function getSign(): string
|
||||
{
|
||||
if (empty($this->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());
|
||||
}
|
||||
}
|
||||
}
|
||||
98
extend/Tencent/map/Location.php
Normal file
98
extend/Tencent/map/Location.php
Normal file
@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
namespace Extend\Tencent\map;
|
||||
|
||||
use App\Constants\HttpEnumCode;
|
||||
use App\Exception\BusinessException;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\Utils\ApplicationContext;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use function \Hyperf\Config\config;
|
||||
/**
|
||||
* 腾讯地图
|
||||
*/
|
||||
class Location
|
||||
{
|
||||
#[Inject]
|
||||
protected ContainerInterface $container;
|
||||
|
||||
#[Inject]
|
||||
protected Client $client;
|
||||
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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()) {
|
||||
// 出错了,处理异常
|
||||
|
||||
@ -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,//订单总金额,单位为分。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user