HelpOrderListener.php 965 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace App\Listeners;
  3. use App\Events\HelpOrderEvent;
  4. use Illuminate\Queue\Listener;
  5. use Illuminate\Support\Facades\Log;
  6. class HelpOrderListener {
  7. protected $template_id;
  8. protected $url;
  9. //支付
  10. public function __construct()
  11. {
  12. $this->template_id='RPqc9Rhdv6LtEu-z41BkvNPJ0j6PjnztvX84jqYMG9g';
  13. $this->url='http://weidian.jiuweiyun.cn/web/user';
  14. }
  15. public function handle(HelpOrderEvent $event)
  16. {
  17. try{
  18. $data=$event->data;
  19. $openid=$data['openid'];
  20. $app=app('wechat.official_account.daweiboshi');
  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. }