12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace App\Listeners;
- use App\Events\AgentAuditEvent;
- use App\Events\AgentAuditServiceEvent;
- use App\Models\User;
- use App\Models\Warea;
- use Illuminate\Queue\Listener;
- use Illuminate\Support\Facades\Log;
- class AgentAuditServiceListener {
- protected $template_id;
- protected $url;
- //认证审核通知 通知上级 和 邀请人 审核结果
- public function __construct()
- {
- $this->template_id='ibTVb5-mUemyjvLYgQnYI6jpqFh_xQBtzLCb1xOQblQ';
- $this->url='http://admin.app.jiuweiyun.cn/#/team/zhengwei';
- }
- /**
- * Handle the event.
- *
- * @param AgentAuditServiceListener $event
- * @return void
- */
- public function handle(AgentAuditServiceEvent $event)
- {
- try{
- $data=$event->data;
- $id=$data['id'];
- $app=app('wechat.official_account');
- $phone=Warea::where('id',$id)->value('phone');
- $user=User::where('mobile',$phone)->first();
- if ($user->openid){
- $app->template_message->send([
- 'touser' => $user->openid,
- 'template_id' => $this->template_id,
- 'url' => $this->url,
- 'data' => $data['data']
- ]);
- }
- }catch (\Exception $exception){
- Log::error('发送模板消息出错,出错内容为'.$exception);
- }
- }
- }
|