1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace App\Listeners;
- use App\Events\OrderPayEvent;
- use Illuminate\Queue\Listener;
- use Illuminate\Support\Facades\Log;
- class OrderPayListener {
- protected $template_id;
- protected $url;
- //注册完成 再次提交注册信息后 提示邀请人
- public function __construct()
- {
- $this->template_id='3PGRr84zGsleaJYLqQjgr6G9XAmCLjC2YmardI6RBAo';
- $this->url='http://api.app.cliu.cc/api/gzh';
- }
- public function handle(OrderPayEvent $event)
- {
- try{
- $data=$event->data;
- $openid=$data['openid'];
- $app=app('wechat.official_account');
- $app->template_message->send([
- 'touser' => $openid,
- 'template_id' => $this->template_id,
- 'url' => $this->url,
- 'data' => $data['data']
- ]);
- }catch (\Exception $exception){
- Log::error('发送模板消息出错,出错内容为'.$exception);
- }
- }
- }
|