$open_id, 'template_id' => $subscribe_id->value, 'page' => 'pagesA/card/index', 'data' => [ 'thing1' => ['value' => $patient_name], 'time2' => ['value' => date('Y-m-d H:i')], 'thing3' => ['value' => '您已绑定成功,可以进行线上线下就医服务。'], ], 'miniprogram_state' => config('custom.mini_program_message_state') ]; $message = self::getSendMessageJob()->insertMessageJobs(0, $relate_patient_id, Type::SINGLE_SUBSCRIBE, $subscribe_id, $data, ''); SendWeChatMessageJob::dispatch($message); } /** * 发送解绑患者订阅消息 * @param string $open_id * @param int $relate_patient_id * @param string $patient_name * @param string $inpatient_id 住院号 * @param string $patient_id 门诊号 * @return void */ public function sendUnbindPatientSubscribeMessage(string $open_id, int $relate_patient_id, string $patient_name, string $inpatient_id, string $patient_id): void { $subscribe_id = SubscribeId::PATIENT_UNBIND_SUCCESS; $data = [ 'touser' => $open_id, 'template_id' => $subscribe_id->value, 'page' => '', 'data' => [ 'thing1' => ['value' => $patient_name], 'time2' => ['value' => date('Y-m-d H:i')], 'thing3' => ['value' => '已解除绑定关系,无法使用线上线下就医服务'], 'character_string5' => ['value' => $inpatient_id], 'character_string6' => ['value' => $patient_id], ], 'miniprogram_state' => config('custom.mini_program_message_state') ]; $message = self::getSendMessageJob()->insertMessageJobs(0, $relate_patient_id, Type::SINGLE_SUBSCRIBE, $subscribe_id, $data); SendWeChatMessageJob::dispatch($message); } /** * 发送就诊提醒消息 * @param RegistrationRecord $record * @return void */ public function sendAppointmentReminderMessage(RegistrationRecord $record): void { $order = &$record->order; $subscribe_id = SubscribeId::VISIT_REMIND; $visit_time = $record->visit_date . ' '. $record->begin_time . '~'. $record->end_time; $data = [ 'touser' => $order->open_id, 'template_id' => $subscribe_id->value, 'page' => 'pagesA/register/regRecord', 'data' => [ 'name1' => ['value' => $order->patient_name], 'time7' => ['value' => $visit_time], 'thing10' => ['value' => $record->dept_name. '('. $record->doctor_name. ')'], 'thing6' => ['value' => $record->dept_location], 'thing5' => ['value' => '请准时前往医院就诊。'], ], 'miniprogram_state' => config('custom.mini_program_message_state') ]; $message = self::getSendMessageJob()->insertMessageJobs($order->id, $order->relate_patient_id, Type::SINGLE_SUBSCRIBE, $subscribe_id, $data, ''); SendWeChatMessageJob::dispatch($message); } /** * 发送挂号成功订阅消息 * @param OrderModel $order * @return void */ public function sendRegistrationSuccessMessage(OrderModel $order): void { // 重新强关联,避免缓存 $order->load('registrationRecord'); $record = &$order->registrationRecord; $subscribe_id = SubscribeId::REGISTRATION_SUCCESS; $visit_time = $record->visit_date . ' '. $record->begin_time . '~'. $record->end_time; $data = [ 'touser' => $order->open_id, 'template_id' => $subscribe_id->value, 'page' => 'pagesA/register/regRecord', 'data' => [ 'thing5' => ['value' => $record->dept_name], 'thing17' => ['value' => $record->dept_location], 'character_string15' => ['value' => $visit_time], 'thing19' => ['value' => $record->doctor_name], 'amount13' => ['value' => ($order->fee / 100). '元'], ], 'miniprogram_state' => config('custom.mini_program_message_state') ]; $message = self::getSendMessageJob()->insertMessageJobs($order->id, $order->relate_patient_id, Type::SINGLE_SUBSCRIBE, $subscribe_id, $data, ''); SendWeChatMessageJob::dispatch($message); } /** * 发送挂号失败订阅消息 * @param OrderModel $order * @return void */ public function sendRegistrationFailureMessage(OrderModel $order): void { // 重新强关联,避免缓存 $order->load('registrationRecord'); $record = &$order->registrationRecord; $subscribe_id = SubscribeId::REGISTRATION_FAILURE; $visit_time = $record->visit_date . ' '. $record->begin_time . '~'. $record->end_time; $data = [ 'touser' => $order->open_id, 'template_id' => $subscribe_id->value, 'page' => 'pagesA/register/regRecord', 'data' => [ 'thing2' => ['value' => $record->dept_name], 'thing3' => ['value' => $record->doctor_name], 'name1' => ['value' => $order->patient_name], 'time4' => ['value' => $visit_time], 'amount13' => ['value' => ($order->fee / 100). '元'], ], 'miniprogram_state' => config('custom.mini_program_message_state') ]; $message = self::getSendMessageJob()->insertMessageJobs($order->id, $order->relate_patient_id, Type::SINGLE_SUBSCRIBE, $subscribe_id, $data, ''); SendWeChatMessageJob::dispatch($message); } /** * 发送取消预约挂号消息 * @param OrderModel $order * @return void */ public function sendRegistrationCancelMessage(OrderModel $order): void { // 重新强关联,避免缓存 $order->load('registrationRecord'); $record = &$order->registrationRecord; $subscribe_id = SubscribeId::REGISTRATION_CANCEL; $visit_time = $record->visit_date . ' '. $record->begin_time . '~'. $record->end_time; $data = [ 'touser' => $order->open_id, 'template_id' => $subscribe_id->value, 'page' => 'pagesA/register/regRecord', 'data' => [ 'thing1' => ['value' => $order->patient_name], 'thing2' => ['value' => $record->dept_name], 'thing3' => ['value' => $record->doctor_name], 'time4' => ['value' => $visit_time], 'thing5' => ['value' => '已成功取消预约,如有需要请重新预约。'], ], 'miniprogram_state' => config('custom.mini_program_message_state') ]; $message = self::getSendMessageJob()->insertMessageJobs(0, $order->relate_patient_id, Type::SINGLE_SUBSCRIBE, $subscribe_id, $data, ''); SendWeChatMessageJob::dispatch($message); } /** * 发送门诊缴费成功消息 * @param OrderModel $order * @return void */ public function sendOutpatientPaymentSuccessMessage(OrderModel $order): void { // 重新强关联,避免缓存 $order->load('outpatientPaymentRecord'); $record = &$order->outpatientPaymentRecord; $extra_info = json_decode($record->extra_info, true); $subscribe_id = SubscribeId::OUTPATIENT_PAYMENT_SUCCESS; $data = [ 'touser' => $order->open_id, 'template_id' => $subscribe_id->value, 'page' => 'pagesA/outpatient/outPayList', 'data' => [ 'amount6' => ['value' => ($order->fee / 100). '元'], 'character_string7' => ['value' => $order->order_id], 'thing12' => ['value' => $extra_info['confirm_response']['phyAddress']], 'thing17' => ['value' => $order->patient->patient_number], 'thing9' => ['value' => '门诊缴费'], ], 'miniprogram_state' => config('custom.mini_program_message_state') ]; $message = self::getSendMessageJob()->insertMessageJobs($order->id, $order->relate_patient_id, Type::SINGLE_SUBSCRIBE, $subscribe_id, $data, ''); SendWeChatMessageJob::dispatch($message); } /** * 发送门诊缴费失败消息 * @param OrderModel $order * @return void */ public function sendOutpatientPaymentFailureMessage(OrderModel $order): void { // $order->load('outpatientPaymentRecord'); // $record = &$order->outpatientPaymentRecord; $subscribe_id = SubscribeId::OUTPATIENT_PAYMENT_FAILURE; $data = [ 'touser' => $order->open_id, 'template_id' => $subscribe_id->value, 'page' => '', 'data' => [ 'character_string1' => ['value' => $order->order_id], 'thing2' => ['value' => '门诊缴费'], 'name3' => ['value' => $order->patient_name], 'amount4' => ['value' => ($order->fee / 100). '元'], 'date6' => ['value' => date('Y-m-d')], ], 'miniprogram_state' => config('custom.mini_program_message_state') ]; $message = self::getSendMessageJob()->insertMessageJobs($order->id, $order->relate_patient_id, Type::SINGLE_SUBSCRIBE, $subscribe_id, $data, ''); SendWeChatMessageJob::dispatch($message); } // --------------------- 主动触发 订阅消息 --------------------- /** * 发送医生停诊提醒消息 -- his触发 * @param PatientModel $patient * @param string $reg_date 挂号日期 * @param string $begin_time 挂号开始时间段 * @param string $end_time 挂号结束时间段 * @param string $dept_name 科室名称 * @param string $doctor_name 医生名称 * @param string $tips 温馨提示信息 * @return void */ public function sendRegistrationStopRemindMessage(PatientModel $patient, string $reg_date, string $begin_time, string $end_time, string $dept_name, string $doctor_name, string $tips_message): void { $subscribe_id = SubscribeId::REGISTRATION_STOP_REMIND; $data = [ 'touser' => $patient->open_id, 'template_id' => $subscribe_id->value, 'page' => '', 'data' => [ 'thing17' => ['value' => $patient->name], 'time10' => ['value' => $reg_date. ' '. $begin_time . '~'. $end_time],// 就诊时段 'character_string11' => ['value' => $patient->patient_number], 'thing15' => ['value' => $dept_name. '('. $doctor_name. ')'], // 科室医生 'thing1' => ['value' => $tips_message ?: '您预约的就诊医生已停诊,费用已原路退回。'],// 温馨提示 ], 'miniprogram_state' => config('custom.mini_program_message_state') ]; $message = self::getSendMessageJob()->insertMessageJobs(0, 0, Type::SINGLE_SUBSCRIBE, $subscribe_id, $data, ''); SendWeChatMessageJob::dispatch($message); } /** * 发送待缴费提醒消息 -- his触发 * @param PatientModel $patient 患者名称 * @param string $dept_name 科室名称 * @param string $fee 费用金额 * @param string $fee_type 费用类型 * @param string $tips_message 提示消息,20个字内 * @return void */ public function sendPendingPaymentRemindMessage(PatientModel $patient, string $dept_name, string $fee, string $fee_type, string $tips_message): void { $subscribe_id = SubscribeId::OUTPATIENT_PENDING_PAYMENT_REMIND; $data = [ 'touser' => $patient->open_id, 'template_id' => $subscribe_id->value, 'page' => 'pagesA/outpatient/outPayList', 'data' => [ 'name1' => ['value' => $patient->name], 'thing3' => ['value' => $dept_name], 'amount5' => ['value' => $fee. '元'], 'thing7' => ['value' => $tips_message], 'thing6' => ['value' => $fee_type], ], 'miniprogram_state' => config('custom.mini_program_message_state') ]; $message = self::getSendMessageJob()->insertMessageJobs(0, 0, Type::SINGLE_SUBSCRIBE, $subscribe_id, $data, ''); SendWeChatMessageJob::dispatch($message); } /** * 发送报告发布提醒消息 -- his触发 * @param PatientModel $patient * @param int $report_type 报告类型 1 检验 2检查 * @param string $item_name 检查/检验项目名称 * @param string $report_time 检查/检验时间 * @param string $report_serial_no 报告流水号 * @param string $dept_name 科室名称 * @param string $remark 备注 * @return void */ public function sendReportReleaseRemindMessage(PatientModel $patient, int $report_type, string $item_name, string $report_time, string $report_serial_no, string $dept_name, string $remark = ''): void { if($report_type === 1) { $subscribe_id = SubscribeId::INSPECT_REPORT_RELEASE_REMIND; $page = ''; $data = [ 'phrase2' => ['value' => $patient->name], 'thing3' => ['value' => $item_name], // 检验项目 'date5' => ['value' => date('Y-m-d H:i:s', strtotime($report_time))], // 检验时间 'character_string8' => ['value' => $report_serial_no], // 报告流水号 'thing10' => ['value' => $dept_name], // 科室 ]; } else { $subscribe_id = SubscribeId::CHECK_REPORT_RELEASE_REMIND; $page = ''; $data = [ 'thing3' => ['value' => $patient->name], 'thing2' => ['value' => $item_name], // 检查项目 'time3' => ['value' => date('Y-m-d H:i:s', strtotime($report_time))], // 报告时间 'thing4' => ['value' => $remark ?: '您的检查报告已出,请点击查看。'], // 备注 ]; } $data = [ 'touser' => $patient->open_id, 'template_id' => $subscribe_id->value, 'page' => $page, 'data' => $data, 'miniprogram_state' => config('custom.mini_program_message_state') ]; $message = self::getSendMessageJob()->insertMessageJobs(0, 0, Type::SINGLE_SUBSCRIBE, $subscribe_id, $data, ''); SendWeChatMessageJob::dispatch($message); } }