AgentAuditListener.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Listeners;
  3. use App\Events\AgentAuditEvent;
  4. use Illuminate\Queue\Listener;
  5. use Illuminate\Support\Facades\Log;
  6. class AgentAuditListener {
  7. protected $template_id;
  8. protected $url;
  9. //认证审核通知 通知上级 和 邀请人 审核结果
  10. public function __construct()
  11. {
  12. $this->template_id='ibTVb5-mUemyjvLYgQnYI6jpqFh_xQBtzLCb1xOQblQ';
  13. $this->url='http://api.app.cliu.cc/api/gzh';
  14. }
  15. /**
  16. * Handle the event.
  17. *
  18. * @param WechatMessageEvent $event
  19. * @return void
  20. */
  21. public function handle(AgentAuditEvent $event)
  22. {
  23. Log::error(1);
  24. Log::error(json_encode($event));
  25. try{
  26. $data=$event->data;
  27. $openid=$data['openid'];
  28. $app=app('wechat.official_account');
  29. $app->template_message->send([
  30. 'touser' => $openid,
  31. 'template_id' => $this->template_id,
  32. 'url' => $this->url,
  33. 'data' => $data['data']
  34. ]);
  35. }catch (\Exception $exception){
  36. Log::error('发送模板消息出错,出错内容为'.$exception);
  37. }
  38. }
  39. }