HelpOrderListener.php 1022 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. $this->url='https://weidian.cliu.cc/web/user';
  15. }
  16. public function handle(HelpOrderEvent $event)
  17. {
  18. try{
  19. $data=$event->data;
  20. $openid=$data['openid'];
  21. $app=app('wechat.official_account.daweiboshi');
  22. $app->template_message->send([
  23. 'touser' => $openid,
  24. 'template_id' => $this->template_id,
  25. 'url' => $this->url,
  26. 'data' => $data['data']
  27. ]);
  28. }catch (\Exception $exception){
  29. Log::error('发送模板消息出错,出错内容为'.$exception);
  30. }
  31. }
  32. }