getTemplateCode($templateId); if (!$templateId) { return $this->setError('Template number does not exist'); } $tempid = Db::name('template_message')->where(['type' => 0, 'tempkey' => $templateId, 'status' => 1])->value('tempid'); if (!$tempid) { return $this->setError('Template ID does not exist'); } if (!$this->openId) { return $this->setError('Openid does not exist'); } try { $res = MiniProgramService::sendSubscribeTemlate($this->openId, $tempid, $data, $this->toUrl); $this->clear(); return $res; } catch (\Throwable $e) { $this->isLog() && Log::error('发送给openid为:' . $this->openId . '小程序订阅消息失败,模板id为:' . $tempid . ';错误原因为:' . $e->getMessage()); return $this->setError($e->getMessage()); } } public function delete(string $templateId) { // TODO: Implement delete() method. } public function add(string $shortId) { // TODO: Implement add() method. } public function list() { // TODO: Implement list() method. } }