Commit c81f753e authored by 王源's avatar 王源
Browse files

添加自动发送模板消息方法

parent 78564e78
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -53,17 +53,34 @@ class MessageHandler
     * @param $content
     * @throws HttpResponseException
     */
    public function sendText($receiverIds, $content, $sendUserId = null)
    public function sendText($receiverIds, $content)
    {
        $application = $this->config->get('app_name');
        if (!$application) {
            throw new HttpResponseException("请设置应用名app_name");
        }
        $receiverIds = is_array($receiverIds) ? $receiverIds : [$receiverIds];
        $sendUserId =$sendUserId ?: Auth::id();
        $sendUserId = Auth::id();
        $this->messageService->send($receiverIds, $application, 0, $sendUserId, [], $content);
    }

    /**
     * 自动发送模板消息
     * @param $receiverIds
     * @param $templateId
     * @param array $replace
     * @throws HttpResponseException
     */
    public function sendAutoTemp($receiverIds, $templateId, $replace = [])
    {
        $application = $this->config->get('app_name');
        if (!$application) {
            throw new HttpResponseException("请设置应用名app_name");
        }
        $receiverIds = is_array($receiverIds) ? $receiverIds : [$receiverIds];
        $this->messageService->send($receiverIds, $application, $templateId, 0, $replace);
    }

    /**
     * 定时任务专用 发送文本消息
     * @param $receiverIds