OrderPayListener.php 968 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Listeners;
  3. use App\Events\OrderPayEvent;
  4. use Illuminate\Queue\Listener;
  5. use Illuminate\Support\Facades\Log;
  6. class OrderPayListener {
  7. protected $template_id;
  8. protected $url;
  9. //注册完成 再次提交注册信息后 提示邀请人
  10. public function __construct()
  11. {
  12. $this->template_id='3PGRr84zGsleaJYLqQjgr6G9XAmCLjC2YmardI6RBAo';
  13. $this->url='';
  14. }
  15. public function handle(OrderPayEvent $event)
  16. {
  17. try{
  18. $data=$event->data;
  19. $openid=$data['openid'];
  20. $app=app('wechat.official_account');
  21. $app->template_message->send([
  22. 'touser' => $openid,
  23. 'template_id' => $this->template_id,
  24. 'url' => $this->url,
  25. 'data' => $data['data']
  26. ]);
  27. }catch (\Exception $exception){
  28. Log::error('发送模板消息出错,出错内容为'.$exception);
  29. }
  30. }
  31. }