team_id = $team_id; $this->user = $user; } /** * Execute the job. * * @return void */ public function handle() { \Log::info("群id".$this->team_id."发送模板消息"); $logs = UserTeam::with('user')->whereHas("user")->where("user_id", "<>", $this->user->id)->where("team_id",$this->team_id)->get(); foreach ($logs as $log) { if ($log->user->wechat->official_openid) { $data['touser'] = $log->user->wechat->official_openid; $data['template_id'] = config('wechat.tpls.start_message_notice'); $data['url'] = ''; $data['miniprogram'] = [ 'appid'=> config('wechat.mini_program.app_id'), 'pagepath'=>'/pages/tabBar/news' ]; $data['data'] = [ 'keyword1' => date('Y-m-d H:i:s'), 'keyword2' => "您有新的群消息", ]; SendTemplateMsg::dispatch($data)->onQueue('template_message'); } } } }