* @version : HUOSDK 8.0 */ namespace api\sdk\controller\v8; use api\common\controller\V2ApiBaseController; use huo\controller\app\App; use huo\controller\common\CommonFunc; use huo\controller\game\Game; use huo\controller\member\Oauth; use huo\controller\notice\Notice; use huoIdentify\controller\Online; use think\Config; use think\Session; class AppController extends V2ApiBaseController { public function _initialize() { parent::_initialize(); } /** * app启动(激活) * http://doc.1tsdk.com/138?page_id=2896 * 【域名】/v8/app/startup */ public function startup() { // TODO: wuyonghong 2018/1/19 先校验请求参数 // $result = $this->validate($this->rq_data, 'App.startup'); // if ($result !== true) { // $this->error($result); // } $_game_rq = $this->setGameData(); $_channel_rq = $this->setChannelData(); $_device_rq = $this->setDeviceData(); $_game_class = new Game(); $_rdata['up'] = $_game_class->getUpInfo($_game_rq, $_channel_rq); $_notice_class = new Notice(); $_rdata['notice'] = $_notice_class->getNotice($_game_rq, $_channel_rq, $_device_rq); $_rdata['hb_time'] = CommonFunc::getHeartbeatTime(); //获取心跳时长 $_rdata['user_token'] = session_id(); $_rdata['toggle'] = 1;// TODO: wuyonghong 2018/4/24 需要添加函数 $_rdata['agentgame'] = $_channel_rq->getAgentGame(); $_rdata['oauth_list'] = (new Oauth())->getOauthConf(); Session::set('open_cnt', $this->rq_data['open_cnt']); Session::set('app_id', $_game_rq->getHAppId(), 'app'); /* Modified by guxiannong BEGIN 2018/8/1 ISSUES:5842 买量系统 */ /*通过agent_id获取投放平台id*/ $_tf_base_class = new \huolib\promotion\Base(); $_Platform_id = $_tf_base_class->getPlatformId($_game_rq->getAppleId(), $_channel_rq->getAgentId()); $_params['mem_id'] = 0; $_params['ver_id'] = $_game_rq->getAppVer(); //$this->getVal($_data, 'client_id', 0); $_params['app_id'] = $_game_rq->getHAppId();// $this->getVal($_data, 'app_id', 0); $_params['agentname'] = $_rdata['agentgame']; $_params['agent_id'] = $_channel_rq->getAgentId(); $_params['device_id'] = $_device_rq->getDeviceId(); $_params['mac'] = $_device_rq->getMac(); $_params['userua'] = $_device_rq->getUserua(); $_params['local_ip'] = $_device_rq->getIp(); $_params['create_time'] = time(); $_params['ip'] = $this->request->ip(); $_params['idfa'] = $_params['device_id']; $_os = $_device_rq->getOs(); $_params['from'] = ($_os == 'ios') ? 4 : (($_os == 'android') ? 3 : 3);//get_val($_data, 'from', 3); /*今日头条*/ if (1 == Config::get('config.G_TOUTIAO_EN') && 4 == $_Platform_id) { $_toutiao_class = new \huolib\promotion\toutiao(); /*是否推广白名单*/ $_tt_while = $_toutiao_class->isWhile($_params['from'], $_params['device_id'], $_params['idfa']); if (1 == $this->rq_data['open_cnt'] || $_tt_while) { $_re = $_toutiao_class->install($_params); if ($_re) { } } } /*百度信息流*/ if (1 == Config::get('config.G_BAIDU_EN') && 1 == $_Platform_id) { $_baidu_class = new \huolib\promotion\Baidu(); /*是否推广白名单*/ $_bd_while = $_baidu_class->isWhile($_params['from'], $_params['device_id'], $_params['idfa']); if (1 == $this->rq_data['open_cnt'] || $_bd_while) { $_re = $_baidu_class->install($_params); if ($_re) { } } } /*uc*/ if (1 == Config::get('config.G_UC_EN') && 7 == $_Platform_id) { $_uc_class = new \huolib\promotion\Uc(); /*是否推广白名单*/ $_uc_while = $_uc_class->isWhile($_params['from'], $_params['device_id'], $_params['idfa']); if (1 == $this->rq_data['open_cnt'] || $_uc_while) { $_re = $_uc_class->install($_params); if ($_re) { } } } /* Modified by guxiannong END 2018/8/1 ISSUES:5842 买量系统 */ $this->success(lang('SUCCESS'), $_rdata); } /** * SDK事件上报 * http://doc.1tsdk.com/138?page_id=2951 * 【域名】/v8/app/event */ public function event() { $_game_rq = $this->setGameData(); $_channel_rq = $this->setChannelData(); $_device_rq = $this->setDeviceData(); $_event_rq = $this->setEventData(); $_app_class = new App(); $_rs = $_app_class->insertLog($_event_rq, $_game_rq, $_channel_rq, $_device_rq); if (false !== $_rs) { $this->success(lang('SUCCESS')); } $this->error(lang('ERROR')); } /** * APP心跳 * http://doc.1tsdk.com/138?page_id=2898 * 【域名】/v8/app/heartbeat */ public function heartbeat() { $_game_rq = $this->setGameData(); $_channel_rq = $this->setChannelData(); $_device_rq = $this->setDeviceData(); $_mem_rq = $this->setMemData(); $_app_class = new App(); $_app_class->insertHeartLog($_game_rq, $_channel_rq, $_device_rq, $_mem_rq); //$_msg_class = new Message(); //$_param = $this->request->param(); $_mem_id = $this->mem_id; //$_rdata['msg_cnt'] = $_msg_class->getCnt($_param, $_mem_id); $_rdata['msg_cnt'] = 0; /* Modified by chenbingling BEGIN 2019/11/28 ISSUES:10837 新增实名认证信息处理 */ $_online_class = (new Online($_game_rq->getHAppId(), $_mem_id, $_device_rq->getDeviceId())); $_rdata['url'] = $_online_class->heartOnline(); $_time_left = $_online_class->getTimeLeft(); $_rdata = array_merge($_rdata, $_time_left); //Log::error(['心跳', $_rdata, $_mem_id]); /* END 2019/11/28 ISSUES:10837 新增实名认证信息处理*/ // /* Modified by chenbingling BEGIN 2019/11/28 ISSUES:10837 新增实名认证信息处理 */ // $_online_class = (new Online($_game_rq->getHAppId(), $_mem_id, $_device_rq->getDeviceId())); // /* Modified by ouzhongfu BEGIN 2020/4/2 ISSUES:11786 游戏需要实名充值的,充值的时候弹出,其他操作不再弹。 */ //// $_rdata['url'] = $_online_class->heartOnline(); // $_rdata['url'] = ''; // /* END 2020/4/2 ISSUES:11786 */ // $_time_left = $_online_class->getTimeLeft(); // $_rdata = array_merge($_rdata, $_time_left); // //Log::error(['心跳', $_rdata, $_mem_id]); // /* END 2019/11/28 ISSUES:10837 新增实名认证信息处理*/ $this->success(lang('SUCCESS'), $_rdata); } /** * APP奔溃 * http://doc.1tsdk.com/138?page_id=2897 * 【域名】/v8/app/crash */ public function crash() { $_game_rq = $this->setGameData(); $_channel_rq = $this->setChannelData(); $_device_rq = $this->setDeviceData(); $_crash_rq = $this->setCrashData(); $_app_class = new App(); $_rs = $_app_class->insertCrashLog($_crash_rq, $_game_rq, $_channel_rq, $_device_rq); if (false !== $_rs) { $this->success(lang('SUCCESS')); } $this->error(lang('ERROR')); } }