CancelOrderListener.php 969 B

123456789101112131415161718192021222324252627282930313233343536
  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. }
  15. public function handle(CancelOrderEvent $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. }