message_data = $message_data; } /** * Execute the job. * * @return void */ public function handle() { try { $this->send($this->message_data['user_id_list'], $this->message_data['msg_title']); } catch (\Exception $e) { Log::info('job_error', '订阅消息通知推送队列失败', ['data' => $this->message_data, 'error' => $e->getMessage()]); } } /** * 公众号消息订阅推送 * * */ private function send($user_id_list, $msg_title = '') { $EmployeeModel = new EmployeeModel(); $user_list = $EmployeeModel->whereIn('id',$user_id_list)->where([['open_subscribe', '=', 0], ['status', '=', 1]])->select(['openid'])->select(); if(empty($user_list)) return true; $data = [ 'thing1' => $msg_title, 'thing2' => '您有一条新的违规待处理通知要处理,请及时查看', 'time7' => strtotime(time(), 'Y:m:d H:i:s'), 'phrase9' => '待处理', ]; foreach ($user_list as $value) { $params = [ 'touser' => $value['openid'], 'template_id' => 't559Iagds7Av-YcqwIpeAaS5gt7LuOKuIBDvVKlyfm8', 'url' => '', 'data' => $data, ]; //发送模板消息 $result = Official::sendSubscription($params); } // 告知结果 return json_send(['code' => 'success', 'msg' => '成功', 'path' => '']); } public function failed(\Throwable $exception) { Log::info('job_error', '订阅消息通知推送队列完全失败', ['data' => $this->message_data, 'error' => $exception]); } }