From 0b994330d54baf10379699df3216dbcb4951954d Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Tue, 16 Jan 2024 16:42:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8C=BB=E7=94=9F=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E8=A7=86=E9=A2=91=E9=A2=84=E7=BA=A6=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SendVideoNoticeDelayDirectConsumer.php | 2 ++ app/Services/InquiryService.php | 30 +++++++++++-------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/app/Amqp/Consumer/SendVideoNoticeDelayDirectConsumer.php b/app/Amqp/Consumer/SendVideoNoticeDelayDirectConsumer.php index 66222bc..9b31c8a 100644 --- a/app/Amqp/Consumer/SendVideoNoticeDelayDirectConsumer.php +++ b/app/Amqp/Consumer/SendVideoNoticeDelayDirectConsumer.php @@ -176,6 +176,8 @@ class SendVideoNoticeDelayDirectConsumer extends ConsumerMessage Log::getInstance("queue-SendVideoNotice")->error("修改失败"); return Result::ACK; } + + Db::commit(); }catch (\Throwable $e){ Db::rollBack(); Log::getInstance("queue-SendVideoNotice")->error($e->getMessage()); diff --git a/app/Services/InquiryService.php b/app/Services/InquiryService.php index 153ed01..e3be4d2 100644 --- a/app/Services/InquiryService.php +++ b/app/Services/InquiryService.php @@ -49,6 +49,7 @@ use Hyperf\Redis\Redis; use Hyperf\Snowflake\IdGeneratorInterface; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; +use SebastianBergmann\CodeCoverage\TestIdMissingException; /** * 问诊 @@ -1325,7 +1326,7 @@ class InquiryService extends BaseService $order_inquiry_id = $this->request->input('order_inquiry_id'); $reservation_time = $this->request->input('reservation_time'); - // 检测问诊时间 + // 检测预约时间 if (time() >= strtotime($reservation_time)){ return fail(HttpEnumCode::HTTP_ERROR, "预约时间须大于当前时间"); } @@ -1364,9 +1365,9 @@ class InquiryService extends BaseService // 问诊结束时间 $complete_time = strtotime($order_inquiry['reception_time']) + $system_inquiry_config['duration'] * 60 - 10 * 60; - // 检测问诊结束时间 - if (time() >= $complete_time){ - return fail(HttpEnumCode::HTTP_ERROR, "已无法设置/修改视频时间,可立即发起视频"); + // 检测问诊结束时间 预约时间不可超出视频问诊结束时间 + if (strtotime($reservation_time) >= $complete_time){ + return fail(HttpEnumCode::HTTP_ERROR, "预约时间不可超出视频问诊结束时间"); } // 获取是否已经预约 @@ -1389,7 +1390,6 @@ class InquiryService extends BaseService $is_reservation = true; } - // 创建订单 Db::beginTransaction(); try { @@ -1466,14 +1466,18 @@ class InquiryService extends BaseService $sendSmsService = new SendSmsService($user['mobile']); $sendSmsService->noticePatientVideoTime($user_doctor['user_name'],$reservation_time); - // 增加延迟队列通知-视频问诊即将开始 - $time = strtotime($reservation_time) - 4*60; - $message = new SendVideoNoticeDelayDirectProducer($data); - $message->setDelayMs(1000 * $time); - $producer = $this->container->get(Producer::class); - $res = $producer->produce($message); - if (!$res) { - return fail(HttpEnumCode::SERVER_ERROR, "设置失败"); + // 增加延迟队列通知-视频问诊即将开始-时间大于5分钟 + $time = strtotime($reservation_time) - 5*60; + if ($time > time()){ + $data = array(); + $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; + $message = new SendVideoNoticeDelayDirectProducer($data); + $message->setDelayMs(1000 * (strtotime($reservation_time) - time())); + $producer = $this->container->get(Producer::class); + $res = $producer->produce($message); + if (!$res) { + return fail(HttpEnumCode::SERVER_ERROR, "设置失败"); + } } }catch (\Throwable $e){ Log::getInstance("InquiryService-addDoctorGiveInquiryOrder")->error($e->getMessage());