修改im消息推送问题

This commit is contained in:
wucongxing 2023-08-29 17:49:04 +08:00
parent b593520857
commit 3e8562641e
4 changed files with 140 additions and 98 deletions

View File

@ -62,7 +62,7 @@ class DetectionCompleteDelayDirectConsumer extends ConsumerMessage
return Result::DROP; return Result::DROP;
} }
if (!empty($order_detection['detection_result_pdf'])){ if (empty($order_detection['detection_result_pdf'])){
Log::getInstance("queue-DetectionComplete")->error("无检测报告数据"); Log::getInstance("queue-DetectionComplete")->error("无检测报告数据");
return Result::DROP; return Result::DROP;
} }
@ -173,9 +173,6 @@ class DetectionCompleteDelayDirectConsumer extends ConsumerMessage
return Result::DROP; return Result::DROP;
} }
// 回填问诊订单id
$order_detection['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
// 增加患者问诊病例 // 增加患者问诊病例
$data = array(); $data = array();
$data['user_id'] = $order_detection['user_id']; $data['user_id'] = $order_detection['user_id'];
@ -230,14 +227,20 @@ class DetectionCompleteDelayDirectConsumer extends ConsumerMessage
); );
// 发送IM消息-检测报告结果 // 发送IM消息-检测报告结果
$imService->detectionTestReport( $data = [
$order_detection, "order_inquiry_id" => $order_inquiry['order_inquiry_id'],
$user_doctor['user_id'], "inquiry_type" => $order_inquiry['inquiry_type'],
$order_detection['user_id'], "detection_no" => $order_detection['detection_no'],
$order_detection_case['detection_disease_class_names'], "patient_name" => $order_detection['patient_name'],
$detection_project['detection_project_name'], "patient_sex" => $order_detection['patient_sex'],
$order_inquiry['inquiry_type'] "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(); Db::commit();
}catch (\Throwable $e){ }catch (\Throwable $e){
@ -249,14 +252,20 @@ class DetectionCompleteDelayDirectConsumer extends ConsumerMessage
// 发送消息 // 发送消息
try { try {
// 发送IM消息-检测报告结果-文字 // 发送IM消息-检测报告结果-文字
$imService->detectionTestReportStr( $data = [
$order_detection, "order_inquiry_id" => $order_inquiry['order_inquiry_id'],
$user_doctor['user_name'], "inquiry_type" => $order_inquiry['inquiry_type'],
$detection_project['detection_project_name'], "detection_no" => $order_detection['detection_no'],
$user_doctor['user_id'], "doctor_name" => $user_doctor['user_name'],
$order_detection['user_id'], "patient_name" => $order_detection['patient_name'],
$order_inquiry['inquiry_type'] "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 = new MessagePush($order_detection['user_id']);

View File

@ -1724,17 +1724,37 @@ class CallBackController extends AbstractController
$params['order_detection_id'] = $order_detection['order_detection_id']; $params['order_detection_id'] = $order_detection['order_detection_id'];
OrderDetection::editOrderDetection($params,$data); OrderDetection::editOrderDetection($params,$data);
$order_detection['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
// 发送IM消息-检测报告结果 // 发送IM消息-检测报告结果
$imService->detectionTestReport( $data = [
$order_detection, "order_inquiry_id" => $order_inquiry['order_inquiry_id'],
$user_doctor['user_id'], "inquiry_type" => $order_inquiry['inquiry_type'],
$order_detection['user_id'], "detection_no" => $order_detection['detection_no'],
$order_detection_case['detection_disease_class_names'], "patient_name" => $order_inquiry['patient_name'],
$detection_project['detection_project_name'], "patient_sex" => $order_inquiry['patient_sex'],
$order_inquiry['inquiry_type'] "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(); return $this->detectionResultSuccessReturn();
}else{ }else{
@ -1780,9 +1800,6 @@ class CallBackController extends AbstractController
return $this->detectionResultFailReturn("问诊订单创建失败"); return $this->detectionResultFailReturn("问诊订单创建失败");
} }
// 回填问诊订单id
$order_detection['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
// 增加患者问诊病例 // 增加患者问诊病例
$data = array(); $data = array();
$data['user_id'] = $order_detection['user_id']; $data['user_id'] = $order_detection['user_id'];
@ -1834,14 +1851,36 @@ class CallBackController extends AbstractController
); );
// 发送IM消息-检测报告结果 // 发送IM消息-检测报告结果
$imService->detectionTestReport( $data = [
$order_detection, "order_inquiry_id" => $order_inquiry['order_inquiry_id'],
$user_doctor['user_id'], "inquiry_type" => $order_inquiry['inquiry_type'],
$order_detection['user_id'], "detection_no" => $order_detection['detection_no'],
$order_detection_case['detection_disease_class_names'], "patient_name" => $order_detection['patient_name'],
$detection_project['detection_project_name'], "patient_sex" => $order_detection['patient_sex'],
$order_inquiry['inquiry_type'] "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(); Db::commit();
} catch (\Throwable $e) { } catch (\Throwable $e) {
@ -1851,16 +1890,6 @@ class CallBackController extends AbstractController
} }
try { try {
// 发送IM消息-检测报告结果-文字
$imService->detectionTestReportStr(
$order_detection,
$user_doctor['user_name'],
$detection_project['detection_project_name'],
$user_doctor['user_id'],
$order_detection['user_id'],
$order_inquiry['inquiry_type']
);
// 患者-新报告生成通知 // 患者-新报告生成通知
$MessagePush = new MessagePush($order_detection['user_id']); $MessagePush = new MessagePush($order_detection['user_id']);
$MessagePush->patientDetectionResultNotice($order_detection['order_detection_id']); $MessagePush->patientDetectionResultNotice($order_detection['order_detection_id']);

View File

@ -677,9 +677,6 @@ class DetectionService extends BaseService
return fail(); return fail();
} }
// 回填问诊订单id
$order_detection['order_inquiry_id'] = $order_inquiry['order_inquiry_id'];
// 增加患者问诊病例 // 增加患者问诊病例
$data = array(); $data = array();
$data['user_id'] = $order_detection['user_id']; $data['user_id'] = $order_detection['user_id'];
@ -732,24 +729,36 @@ class DetectionService extends BaseService
); );
// 发送IM消息-检测报告结果 // 发送IM消息-检测报告结果
$imService->detectionTestReport( $data = [
$order_detection, "order_inquiry_id" => $order_inquiry['order_inquiry_id'],
$user_doctor['user_id'], "inquiry_type" => $order_inquiry['inquiry_type'],
$order_detection['user_id'], "detection_no" => $order_detection['detection_no'],
$order_detection_case['detection_disease_class_names'], "patient_name" => $order_detection['patient_name'],
$detection_project['detection_project_name'], "patient_sex" => $order_detection['patient_sex'],
$order_inquiry['inquiry_type'] "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消息-检测报告结果-文字 // 发送IM消息-检测报告结果-文字
$imService->detectionTestReportStr( $data = [
$order_detection, "order_inquiry_id" => $order_inquiry['order_inquiry_id'],
$user_doctor['user_name'], "inquiry_type" => $order_inquiry['inquiry_type'],
$detection_project['detection_project_name'], "detection_no" => $order_detection['detection_no'],
$user_doctor['user_id'], "doctor_name" => $user_doctor['user_name'],
$order_detection['user_id'], "patient_name" => $order_detection['patient_name'],
$order_inquiry['inquiry_type'] "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(); Db::commit();
}catch (\Throwable $e){ }catch (\Throwable $e){

View File

@ -665,42 +665,37 @@ class ImService extends BaseService
/** /**
* 糖组检测报告 * 糖组检测报告
* @param array|object $order_detection 检测订单数据 * @param array $data
* @param string $doctor_user_id 医生user_id
* @param string $patient_user_id 患者user_id
* @param string $disease_class_names 疾病数据
* @param string $detection_project_name
* @param string|int $inquiry_type
* @return void * @return void
*/ */
public function detectionTestReport(array|object $order_detection,string $doctor_user_id, string $patient_user_id,string $disease_class_names,string $detection_project_name,string|int $inquiry_type): void public function detectionTestReport(array $data): void
{ {
try { try {
// 发送消息 // 发送消息
$cloud_custom_data = array(); $cloud_custom_data = array();
$cloud_custom_data['order_inquiry_id'] = (string)$order_detection['order_inquiry_id']; $cloud_custom_data['order_inquiry_id'] = (string)$data['order_inquiry_id'];
$cloud_custom_data['is_system'] = 1; $cloud_custom_data['is_system'] = 1;
$cloud_custom_data['inquiry_type'] = $inquiry_type; // 订单类型1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测) $cloud_custom_data['inquiry_type'] = $data['inquiry_type']; // 订单类型1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
$cloud_custom_data['message_rounds'] = 0; $cloud_custom_data['message_rounds'] = 0;
$cloud_custom_data['order_no'] = $order_detection['detection_no']; $cloud_custom_data['order_no'] = $data['detection_no'];
$cloud_custom_data['patient_family_data']['patient_name'] = $order_detection['patient_name']; $cloud_custom_data['patient_family_data']['patient_name'] = $data['patient_name'];
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_detection['patient_sex']; $cloud_custom_data['patient_family_data']['patient_sex'] = $data['patient_sex'];
$cloud_custom_data['patient_family_data']['patient_age'] = $order_detection['patient_age']; $cloud_custom_data['patient_family_data']['patient_age'] = $data['patient_age'];
// 消息内容 // 消息内容
$message_content_data = array(); $message_content_data = array();
$message_content_data['message_type'] = 10; $message_content_data['message_type'] = 10;
$message_content_data['title'] = $detection_project_name; $message_content_data['title'] = $data['detection_project_name'];
$message_content_data['desc'] = ""; $message_content_data['desc'] = "";
$message_content_data['data']['order_no'] = (string)$order_detection['detection_no']; $message_content_data['data']['order_no'] = (string)$data['detection_no'];
$message_content_data['data']['disease_class_names'] = $disease_class_names; $message_content_data['data']['disease_class_names'] = $data['disease_class_names'];
$message_content_data['data']['detection_link'] = addAliyunOssWebsite($order_detection['detection_result_pdf']);// 检测结果链接oss $message_content_data['data']['detection_link'] = addAliyunOssWebsite($data['detection_result_pdf']);// 检测结果链接oss
$message_content_data['data']['message_path'] = "/pages/checkOrderDetail/checkOrderDetail?order_detection_id=" . $order_detection['detection_no']; // 跳转地址(小程序内页) $message_content_data['data']['message_path'] = "/pages/checkOrderDetail/checkOrderDetail?order_detection_id=" . $data['detection_no']; // 跳转地址(小程序内页)
$message_content = [ $message_content = [
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE), 'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
]; ];
$this->sendMessage($patient_user_id,$doctor_user_id, $message_content, "TIMCustomElem", $cloud_custom_data); $this->sendMessage($data['patient_user_id'],$data['doctor_user_id'], $message_content, "TIMCustomElem", $cloud_custom_data);
} catch (\Throwable $e) { } catch (\Throwable $e) {
throw new BusinessException($e->getMessage()); throw new BusinessException($e->getMessage());
@ -717,25 +712,25 @@ class ImService extends BaseService
* @param string|int $inquiry_type * @param string|int $inquiry_type
* @return void * @return void
*/ */
public function detectionTestReportStr(array|object $order_detection,string $doctor_name,string $detection_project_name,string $doctor_user_id, string $patient_user_id,string|int $inquiry_type): void public function detectionTestReportStr(array $data): void
{ {
try { try {
// 消息内容 // 消息内容
$cloud_custom_data = array(); $cloud_custom_data = array();
$cloud_custom_data['order_inquiry_id'] = (string)$order_detection['order_inquiry_id']; $cloud_custom_data['order_inquiry_id'] = (string)$data['order_inquiry_id'];
$cloud_custom_data['is_system'] = 1; $cloud_custom_data['is_system'] = 1;
$cloud_custom_data['inquiry_type'] = $inquiry_type; // 订单类型1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测) $cloud_custom_data['inquiry_type'] = $data['inquiry_type']; // 订单类型1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
$cloud_custom_data['message_rounds'] = 0; $cloud_custom_data['message_rounds'] = 0;
$cloud_custom_data['order_no'] = $order_detection['detection_no']; $cloud_custom_data['order_no'] = $data['detection_no'];
$cloud_custom_data['patient_family_data']['patient_name'] = $order_detection['patient_name']; $cloud_custom_data['patient_family_data']['patient_name'] = $data['patient_name'];
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_detection['patient_sex']; $cloud_custom_data['patient_family_data']['patient_sex'] = $data['patient_sex'];
$cloud_custom_data['patient_family_data']['patient_age'] = $order_detection['patient_age']; $cloud_custom_data['patient_family_data']['patient_age'] = $data['patient_age'];
$message_content = [ $message_content = [
'Text' => $doctor_name . "医生您好,您给我开具的【" . $detection_project_name . "】检测项目报告已经出来啦,请您抽空查看报告并做一下解读,谢谢。", 'Text' => $data['doctor_name'] . "医生您好,您给我开具的【" . $data['detection_project_name'] . "】检测项目报告已经出来啦,请您抽空查看报告并做一下解读,谢谢。",
]; ];
$this->sendMessage($patient_user_id,$doctor_user_id, $message_content, "TIMTextElem", $cloud_custom_data); $this->sendMessage($data['patient_user_id'],$data['doctor_user_id'], $message_content, "TIMTextElem", $cloud_custom_data);
} catch (\Throwable $e) { } catch (\Throwable $e) {
throw new BusinessException($e->getMessage()); throw new BusinessException($e->getMessage());