CancelOrderListener.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace App\Listeners;
  3. use App\Events\CancelOrderEvent;
  4. use Illuminate\Queue\Listener;
  5. use Illuminate\Support\Facades\Log;
  6. class CancelOrderListener {
  7. protected $template_id;
  8. protected $url;
  9. //支付
  10. public function __construct()
  11. {
  12. $this->template_id='Q3c9olbC-A9Un_uzNwwTrf1tY9YUD7B-mCndlB_td1c';
  13. // $this->url='http://weidian.jiuweiyun.cn/web/user';
  14. $this->url='https://weidian.cliu.cc/web/user';
  15. }
  16. public function handle(CancelOrderEvent $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. }