target = $target; $this->message = $message; } /** * 执行任务 */ public function handle(WechatBotApiService $apiService): void { if (empty($this->target)) { Log::warning('WechatBot: Target is empty, skipping message dispatch.'); return; } // 所有的触发开关判断(如百家乐、管理员上线等)已经提前在 WechatNotificationService 中拦截判断过了。 // 所以能进入到这个任务的消息,都是明确需要发送的。 try { $apiService->sendTextMessage($this->target, $this->message); } catch (\Exception $e) { Log::error('WechatBot: Failed to send message in queue', [ 'target' => $this->target, 'message' => $this->message, 'error' => $e->getMessage(), ]); } } }