diff --git a/app/Amqp/Consumer/AssignDoctorConsumer.php b/app/Amqp/Consumer/AssignDoctorConsumer.php index 95743f7..6e4cd5f 100644 --- a/app/Amqp/Consumer/AssignDoctorConsumer.php +++ b/app/Amqp/Consumer/AssignDoctorConsumer.php @@ -211,7 +211,7 @@ class AssignDoctorConsumer extends ConsumerMessage $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(); diff --git a/app/Controller/CallBackController.php b/app/Controller/CallBackController.php index 33c5606..2509afb 100644 --- a/app/Controller/CallBackController.php +++ b/app/Controller/CallBackController.php @@ -2,6 +2,7 @@ namespace App\Controller; +use App\Amqp\Producer\AssignDoctorDelayDirectProducer; use App\Amqp\Producer\AssignDoctorProducer; use App\Constants\DoctorTitleCode; use App\Constants\HttpEnumCode; @@ -143,10 +144,11 @@ class CallBackController extends AbstractController $data = array(); $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; - $message = new AssignDoctorProducer($data); - $producer = ApplicationContext::getContainer()->get(Producer::class); - $result = $producer->produce($message); - if (!$result) { + $message = new AssignDoctorDelayDirectProducer($data); + $message->setDelayMs(1000 * 5); + $producer = $this->container->get(Producer::class); + $res = $producer->produce($message); + if (!$res) { Log::getInstance()->info("加入分配医生队列失败"); return $server->serve(); } diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index fc28c85..5d04530 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -2,6 +2,7 @@ namespace App\Controller; +use App\Amqp\Producer\AssignDoctorDelayDirectProducer; use App\Amqp\Producer\AssignDoctorProducer; use App\Amqp\Producer\AutoCompleteInquiryDelayDirectProducer; use App\Amqp\Producer\AutoFinishInquiryDelayDirectProducer; @@ -325,46 +326,13 @@ class TestController extends AbstractController } public function test_15(){ + $data = array(); + $data['order_inquiry_id'] = 1; - $wg = new \Hyperf\Utils\WaitGroup(); - $channel = new Channel(); - $wg->add(2); + $message = new AssignDoctorDelayDirectProducer($data); + $message->setDelayMs(1000 * 10); + $producer = $this->container->get(Producer::class); + $res = $producer->produce($message); - co(function () use ($wg,$channel) { - defer(function() use ($wg) { - dump("执行了defer"); - $wg->done(); - }); - - dump("执行了协程1"); - }); - - co(function () use ($wg,$channel) { - defer(function() use ($wg) { - dump("执行了defer"); - $wg->done(); - }); - - dump("执行了协程2"); - }); - - - - - - $wg->wait(); - - $res = $channel->isEmpty(); - if ($res){ - dump("存在异常"); - } - - $res = $channel->close(); - dump($res); - - $a = $wg->count(); - dump($a); - - dump("执行完毕"); } } \ No newline at end of file diff --git a/app/Services/InquiryService.php b/app/Services/InquiryService.php index c39330c..18371cd 100644 --- a/app/Services/InquiryService.php +++ b/app/Services/InquiryService.php @@ -1303,7 +1303,8 @@ class InquiryService extends BaseService $redis->incr($redis_key); } catch (\Exception $e) { - throw new BusinessException("检测问诊订单执行退款次数失败:" . $e->getMessage()); + Log::getInstance()->error("检测问诊订单执行退款次数失败:" . $e->getMessage()); + return false; } return true; diff --git a/app/Services/PatientOrderService.php b/app/Services/PatientOrderService.php index 310f394..2594732 100644 --- a/app/Services/PatientOrderService.php +++ b/app/Services/PatientOrderService.php @@ -2,6 +2,7 @@ namespace App\Services; +use App\Amqp\Producer\AssignDoctorDelayDirectProducer; use App\Amqp\Producer\AssignDoctorProducer; use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer; use App\Constants\DoctorTitleCode; @@ -852,10 +853,11 @@ class PatientOrderService extends BaseService $data = array(); $data['order_inquiry_id'] = $order_inquiry['order_inquiry_id']; - $message = new AssignDoctorProducer($data); - $producer = ApplicationContext::getContainer()->get(Producer::class); - $result = $producer->produce($message); - if (!$result) { + $message = new AssignDoctorDelayDirectProducer($data); + $message->setDelayMs(1000 * 5); + $producer = $this->container->get(Producer::class); + $res = $producer->produce($message); + if (!$res) { Db::rollBack(); return fail(HttpEnumCode::HTTP_ERROR, "分配医生失败"); }