From 249c585724bd8bff0d4a970cc034cf64a029d51e Mon Sep 17 00:00:00 2001 From: wucongxing <815046773@qq.com> Date: Mon, 27 Mar 2023 18:21:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=A4=84=E6=96=B9=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consumer/SendStationMessageConsumer.php | 114 ++++++++++++------ app/Services/OrderPrescriptionService.php | 4 +- app/Services/UserDoctorService.php | 2 +- 3 files changed, 81 insertions(+), 39 deletions(-) diff --git a/app/Amqp/Consumer/SendStationMessageConsumer.php b/app/Amqp/Consumer/SendStationMessageConsumer.php index 65a5342..1718826 100644 --- a/app/Amqp/Consumer/SendStationMessageConsumer.php +++ b/app/Amqp/Consumer/SendStationMessageConsumer.php @@ -10,6 +10,7 @@ use App\Model\OrderInquiry; use App\Model\User; use App\Services\ImService; use App\Utils\Log; +use GuzzleHttp\Exception\GuzzleException; use Hyperf\Amqp\Result; use Hyperf\Amqp\Annotation\Consumer; use Hyperf\Amqp\Message\ConsumerMessage; @@ -21,6 +22,12 @@ use PhpAmqpLib\Message\AMQPMessage; #[Consumer(exchange: 'amqp.direct', routingKey: 'SendStationMessage', queue: 'send.station.message.queue',nums: 1)] class SendStationMessageConsumer extends ConsumerMessage { + /** + * @param $data + * @param AMQPMessage $message + * @return string + * @throws GuzzleException + */ public function consumeMessage($data, AMQPMessage $message): string { Log::getInstance()->info("开始执行 站内消息推送 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE)); @@ -78,11 +85,8 @@ class SendStationMessageConsumer extends ConsumerMessage $ImService->sendMessage("", $user['user_id'], $message_content, "TIMCustomElem", $cloud_custom_data); - // 新增通知消息表 - - - - + // 新增成功通知消息表 + $this->saveMessageNotice($user->toArray(),$data); Log::getInstance()->info("站内消息推送成功"); $this->saveSuccessPushLog($user['user_type'],$data['sub_data']); @@ -91,6 +95,9 @@ class SendStationMessageConsumer extends ConsumerMessage Log::getInstance()->error("站内消息推送执行失败:" . $e->getMessage()); $this->saveErrorPushLog($user['user_type'],$data,$e->getMessage()); + + // 新增失败通知消息表 + $this->saveMessageNotice($user->toArray(),$data,0,$e->getMessage()); } return Result::ACK; @@ -180,34 +187,71 @@ class SendStationMessageConsumer extends ConsumerMessage } } -// private function saveMessageNotice(){ -// $notice_data = array(); -// $notice_data['user_id'] = $user['user_id']; -// $notice_data['user_type'] = $user['user_type']; -// $notice_data['notice_type'] = $data['notice_type']; -// if (isset($data['notice_system_type'])){ -// $notice_data['notice_system_type'] = $data['notice_system_type'] ; -// } -// -// $notice_data['read_status'] = 0; -// -// if (isset($data['inquiry_type'])){ -// $notice_data['inquiry_type'] = $data['inquiry_type'] ; -// } -// -// if (isset($data['from_name'])){ -// $notice_data['from_name'] = $data['from_name'] ; -// } -// -// $notice_data['notice_title'] = $data['notice_title'] ; -// $notice_data['notice_send_time'] = date('Y-m-d H:i:s',time()); -// -// if (isset($data['notice_content'])){ -// $notice_data['notice_content'] = $data['notice_content'] ; -// } -// -// if (isset($data['notice_content'])){ -// $notice_data['notice_content'] = $data['notice_content'] ; -// } -// } + /** + * 新增通知消息表 + * @param array $user + * @param array $push_data + * @param string $send_fail_reason + * @param int $send_status + * @return void + */ + private function saveMessageNotice(array $user,array $push_data,int $send_status = 1,string $send_fail_reason = ""): void + { + + $notice_data = array(); + $notice_data['user_id'] = $user['user_id']; + $notice_data['user_type'] = $user['user_type']; + $notice_data['notice_type'] = $push_data['notice_type']; + if (isset($push_data['notice_system_type'])){ + $notice_data['notice_system_type'] = $push_data['notice_system_type'] ; + } + + $notice_data['read_status'] = 0; + + if (isset($push_data['inquiry_type'])){ + $notice_data['inquiry_type'] = $push_data['inquiry_type'] ; + } + + if (isset($push_data['from_name'])){ + $notice_data['from_name'] = $push_data['from_name'] ; + } + + $notice_data['notice_title'] = $push_data['notice_title'] ; + $notice_data['notice_send_time'] = date('Y-m-d H:i:s',time()); + + if (isset($push_data['notice_content'])){ + $notice_data['notice_content'] = $push_data['notice_content'] ; + } + + if (isset($push_data['notice_content'])){ + $notice_data['notice_content'] = $push_data['notice_content'] ; + } + + $notice_data['send_status'] = $send_status; + $notice_data['send_fail_reason'] = $send_fail_reason; + if (isset($push_data['button_type'])){ + $notice_data['button_type'] = $push_data['button_type'] ; + } + + if (isset($push_data['link_type'])){ + $notice_data['link_type'] = $push_data['link_type'] ; + } + + if (isset($push_data['link_params'])){ + $notice_data['link_params'] = $push_data['link_params'] ; + } + + if (isset($push_data['show_type'])){ + $notice_data['show_type'] = $push_data['show_type']; + } + + if (isset($push_data['show_params'])){ + $notice_data['show_params'] = $push_data['show_params']; + } + + $message_notice = MessageNotice::addMessageNotice($notice_data); + if (empty($message_notice)){ + Log::getInstance()->error("站内消息推送成功,记录通知消息表失败:" . json_encode($notice_data,JSON_UNESCAPED_UNICODE)); + } + } } diff --git a/app/Services/OrderPrescriptionService.php b/app/Services/OrderPrescriptionService.php index 7160cf6..cba8af9 100644 --- a/app/Services/OrderPrescriptionService.php +++ b/app/Services/OrderPrescriptionService.php @@ -45,14 +45,12 @@ class OrderPrescriptionService extends BaseService /** * 获取处方中开方药品 - * @param string|int $order_inquiry_id * @param string|int $order_prescription_id * @return array */ - public function getproductList(string|int $order_inquiry_id, string|int $order_prescription_id): array + public function getproductList(string|int $order_prescription_id): array { $params = array(); - $params['order_inquiry_id'] = $order_inquiry_id; $params['order_prescription_id'] = $order_prescription_id; $order_prescription_products = OrderPrescriptionProduct::getLimit($params); if (empty($order_prescription_products)) { diff --git a/app/Services/UserDoctorService.php b/app/Services/UserDoctorService.php index af7c109..2f48f3d 100644 --- a/app/Services/UserDoctorService.php +++ b/app/Services/UserDoctorService.php @@ -939,7 +939,7 @@ class UserDoctorService extends BaseService // 订单-商品订单列表 $OrderPrescriptionService = new OrderPrescriptionService(); - $order_prescription_product = $OrderPrescriptionService->getproductList($order_inquiry_id, $order_prescription_id); + $order_prescription_product = $OrderPrescriptionService->getproductList($order_prescription_id); // 获取处方关联疾病表 $fields = [