新增检测回调、修改自动完成订单、新增im推送、

This commit is contained in:
2023-08-09 11:27:56 +08:00
parent 00937e9154
commit 3bb279ab57
9 changed files with 402 additions and 28 deletions
+32 -17
View File
@@ -15,6 +15,7 @@ use App\Model\OrderDetection;
use App\Model\OrderDetectionCase;
use App\Model\OrderDetectionRefund;
use App\Model\PatientFamily;
use App\Model\ReportDetection;
use App\Model\UserDoctor;
use App\Model\UserLocation;
use App\Utils\Log;
@@ -493,7 +494,10 @@ class DetectionService extends BaseService
return success($order_detection['detection_no']);
}
// 绑定检测管
/**
* 绑定检测管
* @return array
*/
public function bindDetectionTube(): array
{
$user_info = $this->request->getAttribute("userInfo") ?? [];
@@ -502,10 +506,6 @@ class DetectionService extends BaseService
$request_params = $this->request->all();
if (count($request_params['detection_pic']) < 1){
return fail(HttpEnumCode::HTTP_ERROR,"请上传检测管图片");
}
$params = array();
$params['patient_id'] = $user_info['client_user_id'];
$params['order_detection_id'] = $order_detection_id;
@@ -527,24 +527,39 @@ class DetectionService extends BaseService
return fail(HttpEnumCode::HTTP_ERROR,"请勿重复绑定");
}
if (!empty($order_detection['detection_pic'])){
if (!empty($order_detection['detection_pic']) && !empty($request_params['detection_pic'])){
return fail(HttpEnumCode::HTTP_ERROR,"请勿重复绑定");
}
// 处理检测管图片
$detection_pic = implode(',', $request_params['detection_pic']);
$detection_pic = PcreMatch::pregRemoveOssWebsite($detection_pic);
if (!empty($request_params['detection_pic'])){
$detection_pic = implode(',', $request_params['detection_pic']);
$detection_pic = PcreMatch::pregRemoveOssWebsite($detection_pic);
}
$data = array();
$data['detection_pic'] = $detection_pic;
$data['detection_bar_code'] = $request_params['detection_bar_code'];
$data['detection_status'] = 3;
$params = array();
$params['order_detection_id'] = $order_detection_id;
$res = OrderDetection::editOrderDetection($params,$data);
if (!$res){
return fail(HttpEnumCode::HTTP_ERROR,"绑定失败");
Db::beginTransaction();
try {
// 修改检测订单
$data = array();
$data['detection_pic'] = $detection_pic ?? "";
$data['detection_bar_code'] = $request_params['detection_bar_code'];
$data['detection_status'] = 3;
$params = array();
$params['order_detection_id'] = $order_detection_id;
$res = OrderDetection::editOrderDetection($params,$data);
if (!$res){
Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR,"绑定失败");
}
// 上报数据
Db::commit();
}catch (\Exception $e){
Db::rollBack();
return fail(HttpEnumCode::HTTP_ERROR, $e->getMessage());
}
return success();
+67
View File
@@ -662,4 +662,71 @@ class ImService extends BaseService
throw new BusinessException($e->getMessage());
}
}
/**
* 糖组检测报告
* @param array|object $order_detection 检测订单数据
* @param string $doctor_user_id 医生user_id
* @param string $patient_user_id 患者user_id
* @param string $disease_class_names 疾病数据
* @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): void
{
try {
// 发送消息
$cloud_custom_data = array();
$cloud_custom_data['is_system'] = 1;
$cloud_custom_data['inquiry_type'] = 5; // 订单类型(1:专家问诊 2:快速问诊 3:公益问诊 4:问诊购药 5:检测)
$cloud_custom_data['message_rounds'] = 0;
$cloud_custom_data['order_no'] = $order_detection['order_no'];
$cloud_custom_data['patient_family_data']['patient_name'] = $order_detection['patient_name'];
$cloud_custom_data['patient_family_data']['patient_sex'] = $order_detection['patient_sex'];
$cloud_custom_data['patient_family_data']['patient_age'] = $order_detection['patient_age'];
// 消息内容
$message_content_data = array();
$message_content_data['message_type'] = 10;
$message_content_data['title'] = $detection_project_name;
$message_content_data['desc'] = "";
$message_content_data['data']['order_no'] = (string)$order_detection['order_no'];
$message_content_data['data']['disease_class_names'] = $disease_class_names;
$message_content_data['data']['message_path'] = "/pages/checkOrderDetail/checkOrderDetail?order_detection_id=" . $order_detection['detection_no']; // 跳转地址(小程序内页)
$message_content = [
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
];
$this->sendMessage($patient_user_id,$doctor_user_id, $message_content, "TIMCustomElem", $cloud_custom_data);
} catch (\Exception $e) {
throw new BusinessException($e->getMessage());
}
}
/**
* 糖组检测报告-文字
* @param array|object $doctor_name 医生名称
* @param string $detection_project_name 检测项目名称
* @param string $doctor_user_id 医生user_id
* @param string $patient_user_id 患者user_id
* @param string $disease_class_names 疾病数据
* @return void
*/
public function detectionTestReportStr(string $doctor_name,string $detection_project_name,string $doctor_user_id, string $patient_user_id,string $disease_class_names): void
{
try {
// 消息内容
$message_content_data = array();
$message_content_data['Text'] = $doctor_name . "医生您好,我在您那里开具的【" . $detection_project_name . "】服务,报告单已出,请您查看报告并详细的做一下解读,谢谢医生。";
$message_content = [
'Data' => json_encode($message_content_data, JSON_UNESCAPED_UNICODE),
];
$this->sendMessage($patient_user_id,$doctor_user_id, $message_content, "TIMTextElem", []);
} catch (\Exception $e) {
throw new BusinessException($e->getMessage());
}
}
}
+65 -4
View File
@@ -1394,7 +1394,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 {
// 获取问诊订单处方数据
@@ -2232,14 +2232,14 @@ class MessagePush extends BaseService
}
/**
* 患者-订单取消成功通知
* 患者-检测订单取消成功通知
* 订阅
* @param string $order_detection_id
* @return void
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function patientCancelOrderSuccess(string $order_detection_id): void
public function patientCancelDetectionOrderSuccess(string $order_detection_id): void
{
try {
// 获取检测订单
@@ -2263,7 +2263,7 @@ class MessagePush extends BaseService
$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['order_detection_id'];
$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'],// 服务项目
@@ -2286,4 +2286,65 @@ class MessagePush extends BaseService
Log::getInstance("MessagePush")->error("错误:加入推送队列失败" . $e->getMessage());
}
}
// 患者-新报告生成通知
// 订阅发送失败发送短信
public function patientDetectionResultNotice(string $order_detection_id){
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;
}
// 订阅
$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" => $order_detection['patient_name'],// 报告名称
"time3" => (string)$detection_project['detection_project_name'],// 生成时间
"thing9" => date('Y年m月d日 H:i'),// 就诊人
"thing4" => $order_detection['payment_amount_total'],// 单位名称-检测所名称
"thing8" => "订单取消成功,支付金额将立即原路退回。",// 测评结果
];
// 短信
$sms_data = array();
$sms_data['template_code'] = "SMS_271905264";
$sms_data['scene_desc'] = "您为{$this->order_inquiry['patient_name']}患者开具的电子处方药师审核不通过,请尽快前往微信小程序“处方管理”中查看原因,并重开处方。模版code:SMS_271905264";
$sms_data['phone'] = $this->user['mobile'];
$sms_data['user_id'] = $this->user['user_id'];
$template_param = array();
$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 (\Exception $e) {
Log::getInstance("MessagePush")->error("错误:加入站内推送队列失败" . $e->getMessage());
}
}
}
+4 -4
View File
@@ -196,11 +196,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'])) {
@@ -1861,7 +1861,7 @@ class PatientOrderService extends BaseService
try {
// 推送患者-订单取消成功通知
$MessagePush = new MessagePush($order_detection['user_id']);
$MessagePush->patientCancelOrderSuccess($order_detection['order_detection_id']);
$MessagePush->patientCancelDetectionOrderSuccess($order_detection['order_detection_id']);
} catch (\Exception $e) {
return success();
}