1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace App\Listeners;
- use App\Events\WithdrawalEndEvent;
- use EasyWeChat\Factory;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Support\Facades\Log;
- class WithdrawalEndListener
- {
- protected $templateId;
- protected $url;
- public function __construct()
- {
- $this->templateId='T7v9IU5OahMKrnQ7Wq9UxEKffnir96oE4UMbasO6bbo';
- // $this->url='http://weidian.jiuweiyun.cn/web/user';
- $this->url='https://weidian.cliu.cc/web/user';
- }
- public function handle(WithdrawalEvent $event)
- {
- try{
- $data=$event->data;
- $openid=$data['openid'];
- $config=config('wechat.official_account.daweiboshi');
- $app = Factory::officialAccount($config);
- $app->template_message->send([
- 'touser' => $openid,
- 'template_id' => $this->templateId,
- 'url' => $this->url,
- 'data' => $data['data']
- ]);
- }catch (\Exception $exception){
- Log::error('发送模板消息出错,出错内容为'.$exception);
- }
- }
- }
|