AppController.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <?php
  2. /**
  3. * AppController.php UTF-8
  4. * 游戏入口
  5. *
  6. * @date : 2017/11/15 17:21
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : wuyonghong <wyh@huosdk.com>
  10. * @version : HUOSDK 8.0
  11. */
  12. namespace api\sdk\controller\v8;
  13. use api\common\controller\V2ApiBaseController;
  14. use huo\controller\app\App;
  15. use huo\controller\common\CommonFunc;
  16. use huo\controller\game\Game;
  17. use huo\controller\member\Oauth;
  18. use huo\controller\notice\Notice;
  19. use huoIdentify\controller\Online;
  20. use think\Config;
  21. use think\Session;
  22. class AppController extends V2ApiBaseController {
  23. public function _initialize() {
  24. parent::_initialize();
  25. }
  26. /**
  27. * app启动(激活)
  28. * http://doc.1tsdk.com/138?page_id=2896
  29. * 【域名】/v8/app/startup
  30. */
  31. public function startup() {
  32. // TODO: wuyonghong 2018/1/19 先校验请求参数
  33. // $result = $this->validate($this->rq_data, 'App.startup');
  34. // if ($result !== true) {
  35. // $this->error($result);
  36. // }
  37. $_game_rq = $this->setGameData();
  38. $_channel_rq = $this->setChannelData();
  39. $_device_rq = $this->setDeviceData();
  40. $_game_class = new Game();
  41. $_rdata['up'] = $_game_class->getUpInfo($_game_rq, $_channel_rq);
  42. $_notice_class = new Notice();
  43. $_rdata['notice'] = $_notice_class->getNotice($_game_rq, $_channel_rq, $_device_rq);
  44. $_rdata['hb_time'] = CommonFunc::getHeartbeatTime(); //获取心跳时长
  45. $_rdata['user_token'] = session_id();
  46. $_rdata['toggle'] = 1;// TODO: wuyonghong 2018/4/24 需要添加函数
  47. $_rdata['agentgame'] = $_channel_rq->getAgentGame();
  48. $_rdata['oauth_list'] = (new Oauth())->getOauthConf();
  49. Session::set('open_cnt', $this->rq_data['open_cnt']);
  50. Session::set('app_id', $_game_rq->getHAppId(), 'app');
  51. /* Modified by guxiannong BEGIN 2018/8/1 ISSUES:5842 买量系统 */
  52. /*通过agent_id获取投放平台id*/
  53. $_tf_base_class = new \huolib\promotion\Base();
  54. $_Platform_id = $_tf_base_class->getPlatformId($_game_rq->getAppleId(), $_channel_rq->getAgentId());
  55. $_params['mem_id'] = 0;
  56. $_params['ver_id'] = $_game_rq->getAppVer(); //$this->getVal($_data, 'client_id', 0);
  57. $_params['app_id'] = $_game_rq->getHAppId();// $this->getVal($_data, 'app_id', 0);
  58. $_params['agentname'] = $_rdata['agentgame'];
  59. $_params['agent_id'] = $_channel_rq->getAgentId();
  60. $_params['device_id'] = $_device_rq->getDeviceId();
  61. $_params['mac'] = $_device_rq->getMac();
  62. $_params['userua'] = $_device_rq->getUserua();
  63. $_params['local_ip'] = $_device_rq->getIp();
  64. $_params['create_time'] = time();
  65. $_params['ip'] = $this->request->ip();
  66. $_params['idfa'] = $_params['device_id'];
  67. $_os = $_device_rq->getOs();
  68. $_params['from'] = ($_os == 'ios') ? 4 : (($_os == 'android') ? 3 : 3);//get_val($_data, 'from', 3);
  69. /*今日头条*/
  70. if (1 == Config::get('config.G_TOUTIAO_EN') && 4 == $_Platform_id) {
  71. $_toutiao_class = new \huolib\promotion\toutiao();
  72. /*是否推广白名单*/
  73. $_tt_while = $_toutiao_class->isWhile($_params['from'], $_params['device_id'], $_params['idfa']);
  74. if (1 == $this->rq_data['open_cnt'] || $_tt_while) {
  75. $_re = $_toutiao_class->install($_params);
  76. if ($_re) {
  77. }
  78. }
  79. }
  80. /*百度信息流*/
  81. if (1 == Config::get('config.G_BAIDU_EN') && 1 == $_Platform_id) {
  82. $_baidu_class = new \huolib\promotion\Baidu();
  83. /*是否推广白名单*/
  84. $_bd_while = $_baidu_class->isWhile($_params['from'], $_params['device_id'], $_params['idfa']);
  85. if (1 == $this->rq_data['open_cnt'] || $_bd_while) {
  86. $_re = $_baidu_class->install($_params);
  87. if ($_re) {
  88. }
  89. }
  90. }
  91. /*uc*/
  92. if (1 == Config::get('config.G_UC_EN') && 7 == $_Platform_id) {
  93. $_uc_class = new \huolib\promotion\Uc();
  94. /*是否推广白名单*/
  95. $_uc_while = $_uc_class->isWhile($_params['from'], $_params['device_id'], $_params['idfa']);
  96. if (1 == $this->rq_data['open_cnt'] || $_uc_while) {
  97. $_re = $_uc_class->install($_params);
  98. if ($_re) {
  99. }
  100. }
  101. }
  102. /* Modified by guxiannong END 2018/8/1 ISSUES:5842 买量系统 */
  103. $this->success(lang('SUCCESS'), $_rdata);
  104. }
  105. /**
  106. * SDK事件上报
  107. * http://doc.1tsdk.com/138?page_id=2951
  108. * 【域名】/v8/app/event
  109. */
  110. public function event() {
  111. $_game_rq = $this->setGameData();
  112. $_channel_rq = $this->setChannelData();
  113. $_device_rq = $this->setDeviceData();
  114. $_event_rq = $this->setEventData();
  115. $_app_class = new App();
  116. $_rs = $_app_class->insertLog($_event_rq, $_game_rq, $_channel_rq, $_device_rq);
  117. if (false !== $_rs) {
  118. $this->success(lang('SUCCESS'));
  119. }
  120. $this->error(lang('ERROR'));
  121. }
  122. /**
  123. * APP心跳
  124. * http://doc.1tsdk.com/138?page_id=2898
  125. * 【域名】/v8/app/heartbeat
  126. */
  127. public function heartbeat() {
  128. $_game_rq = $this->setGameData();
  129. $_channel_rq = $this->setChannelData();
  130. $_device_rq = $this->setDeviceData();
  131. $_mem_rq = $this->setMemData();
  132. $_app_class = new App();
  133. $_app_class->insertHeartLog($_game_rq, $_channel_rq, $_device_rq, $_mem_rq);
  134. //$_msg_class = new Message();
  135. //$_param = $this->request->param();
  136. $_mem_id = $this->mem_id;
  137. //$_rdata['msg_cnt'] = $_msg_class->getCnt($_param, $_mem_id);
  138. $_rdata['msg_cnt'] = 0;
  139. /* Modified by chenbingling BEGIN 2019/11/28 ISSUES:10837 新增实名认证信息处理 */
  140. $_online_class = (new Online($_game_rq->getHAppId(), $_mem_id, $_device_rq->getDeviceId()));
  141. $_rdata['url'] = $_online_class->heartOnline();
  142. $_time_left = $_online_class->getTimeLeft();
  143. $_rdata = array_merge($_rdata, $_time_left);
  144. //Log::error(['心跳', $_rdata, $_mem_id]);
  145. /* END 2019/11/28 ISSUES:10837 新增实名认证信息处理*/
  146. // /* Modified by chenbingling BEGIN 2019/11/28 ISSUES:10837 新增实名认证信息处理 */
  147. // $_online_class = (new Online($_game_rq->getHAppId(), $_mem_id, $_device_rq->getDeviceId()));
  148. // /* Modified by ouzhongfu BEGIN 2020/4/2 ISSUES:11786 游戏需要实名充值的,充值的时候弹出,其他操作不再弹。 */
  149. //// $_rdata['url'] = $_online_class->heartOnline();
  150. // $_rdata['url'] = '';
  151. // /* END 2020/4/2 ISSUES:11786 */
  152. // $_time_left = $_online_class->getTimeLeft();
  153. // $_rdata = array_merge($_rdata, $_time_left);
  154. // //Log::error(['心跳', $_rdata, $_mem_id]);
  155. // /* END 2019/11/28 ISSUES:10837 新增实名认证信息处理*/
  156. $this->success(lang('SUCCESS'), $_rdata);
  157. }
  158. /**
  159. * APP奔溃
  160. * http://doc.1tsdk.com/138?page_id=2897
  161. * 【域名】/v8/app/crash
  162. */
  163. public function crash() {
  164. $_game_rq = $this->setGameData();
  165. $_channel_rq = $this->setChannelData();
  166. $_device_rq = $this->setDeviceData();
  167. $_crash_rq = $this->setCrashData();
  168. $_app_class = new App();
  169. $_rs = $_app_class->insertCrashLog($_crash_rq, $_game_rq, $_channel_rq, $_device_rq);
  170. if (false !== $_rs) {
  171. $this->success(lang('SUCCESS'));
  172. }
  173. $this->error(lang('ERROR'));
  174. }
  175. }