<?php
/*
 本代码由 口号帮 创建
 创建时间 2019-05-08 16:22:09
 技术支持 口号帮 
 严禁反编译、逆向等任何形式的侵权行为，违者将追究法律责任
*/

namespace App\Handler;use App\Models\Message;use Illuminate\Support\Facades\Log;use Illuminate\Support\Facades\Redis;use JPush\Client as JPush;class JPushMessage{public $push;public function setPushKey($config){$AA_A_="is_array";$P2gAC0=$AA_A_($config);$P2g0=!$P2gAC0;if($P2g0)goto P2gBodyx2;goto P2gNextx2;P2gBodyx2:$jpush_config=json_decode($config,true);goto P2gx1;P2gNextx2:$jpush_config=$config;P2gx1:$key=$jpush_config['app_key'];$secret=$jpush_config['master_secret'];$P2g0=new JPush($key,$secret);$client=$P2g0;$this->push=$client->push();}public function allPlatformSend($platform,$msgid,$push_config){$this->setPushKey($push_config['config']);Log::info($push_config['config']);$P2g0='push:message:now:message_id_' . $msgid;$key=$P2g0;if(Redis::exists($key))goto P2gBodyx4;goto P2gNextx4;P2gBodyx4:$con=Redis::get($key);$con=json_decode($con,true);goto P2gx3;P2gNextx4:$con=Message::where(['id'=>$msgid])->first(['id','title','content','redirect_model','redirect_model_detail']);P2gx3:Log::info('极光测试：'.$msgid.'---');$pusher=$this->push;$pusher->setPlatform($platform);$pusher->addAllAudience();$pusher->iosNotification(['title'=>$con['title'],'body'=>$con['content']],array('badge'=>'1','extras'=>array('redirect_type'=>$con['redirect_model'],'redirect_url'=>$con['redirect_model_detail'],'id'=>$msgid),));$pusher->androidNotification($con['content'],array('title'=>$con['title'],'extras'=>array('redirect_type'=>$con['redirect_model'],'redirect_url'=>$con['redirect_model_detail'],'id'=>$msgid),));$response=$pusher->send();Log::info(json_encode($response));$P2g0=$response['http_code']==200;if($P2g0)goto P2gBodyx6;goto P2gNextx6;P2gBodyx6:return '1';goto P2gx5;P2gNextx6:return '0';P2gx5:}public function setCustomPush($platform,$msgid,$push_config,$push_id){$this->setPushKey($push_config['config']);Log::info('--自定义推送--'.$msgid);Log::info('--自定义设备id--'.$push_id);Log::info($push_config['config']);$P2g0='push:message:now:message_id_' . $msgid;$key=$P2g0;if(Redis::exists($key))goto P2gBodyx8;goto P2gNextx8;P2gBodyx8:$con=Redis::get($key);$con=json_decode($con,true);goto P2gx7;P2gNextx8:$con=Message::find($msgid,['id','title','content','redirect_model','redirect_model_detail']);P2gx7:Log::info('message--'.json_encode($con));$response=$this->push->setPlatform($platform)->addRegistrationId($push_id)->iosNotification(['title'=>$con['title'],'body'=>$con['content']],array('category'=>'jiguang','badge'=>'1','extras'=>array('redirect_type'=>$con['redirect_model'],'redirect_url'=>$con['redirect_model_detail'],'id'=>$msgid),))->androidNotification($con['content'],array('title'=>$con['title'],'extras'=>array('redirect_type'=>$con['redirect_model'],'redirect_url'=>$con['redirect_model_detail'],'id'=>$msgid),))->send();Log::info(json_encode($response));$P2g0=$response['http_code']==200;if($P2g0)goto P2gBodyxa;goto P2gNextxa;P2gBodyxa:Message::where(['id'=>$msgid])->increment('send_counts');goto P2gx9;P2gNextxa:return '0';P2gx9:}}
?>