12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- namespace App\Listeners;
- use App\Events\AuthRefundTip;
- use EasyWeChat\Factory;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Support\Facades\Log;
- class AuthRefundTipListeners
- {
- protected $templateId;
- protected $url;
- /**
- * Create the event listener.
- *
- * @return void
- */
- public function __construct()
- {
- //退货提醒
- $this->templateId='8yrOrbG91C30LJapcBgQLINY3Lq9CZuAVbEsQMPcpnE';
- $this->url='';
- }
- /**
- * Handle the event.
- *
- * @param TipSend $event
- * @return void
- */
- public function handle(AuthRefundTip $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);
- }
- }
- }
|