orderId,'处方订单生成通知用户支付订阅消息发送队列 start'); $t = \Yii::$app->db->beginTransaction(); try { $this->setRequest(); $Prescription = Prescription::find()->where([ 'id' => $this->orderId ])->with(['user','doctorInfo','userPatient'])->one(); if (!$Prescription||!$Prescription->user||!$Prescription->doctorInfo) { throw new Exception('处方不存在或已取消'); } $result = WechatService::getInstance()->app->subscribe_message->send([ 'touser' => $Prescription->user->openid, 'template_id' => \Yii::$app->params['template']['user']['prescription_created'], 'page' => 'subPackages/my/myrecord-detail?id='.$Prescription->id.'&no='.$Prescription->prescription_no, 'data' => [ 'name1' => [ 'value' => $Prescription->userPatient->name, ], 'thing2' => [ 'value' => $Prescription->clinical_diagnose, ], 'name4' => [ 'value' => $Prescription->doctorInfo->name, ], 'time9' => [ 'value' => date('Y-m-d H:i:s',$Prescription->created_at), ], 'thing11' => [ 'value' => '医生已为您开具处方,请尽快前往支付!', ] ] ]); if(isset($result['errcode']) && $result['errcode']){ throw new Exception('发送失败,失败原因:'.$result['errmsg']); } PrescriptionLog::saveLog($this->orderId,'处方订单生成通知用户支付订阅消息发送队列 end'); } catch (\Exception $exception) { $t->rollBack(); PrescriptionLog::saveLog($this->orderId,'处方订单生成通知用户支付订阅消息发送队列异常:'.$exception->getMessage()); return; } } }