1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- /**
- * Game.php UTF-8
- * 游戏基类
- *
- * @date : 2020/9/15 9:46
- *
- * @license 这不是一个自由软件,未经授权不许任何使用和传播。
- * @author : chenbingling <cbl@huosdk.com>
- * @version : H5IOS 1.0
- */
- namespace huosdk\h5ios\core\controller;
- use huosdk\h5ios\core\constant\GameConst;
- use huosdk\h5ios\core\model\GameModel;
- use huosdk\h5ios\core\status\GameStatus;
- class Game extends Base {
- /***
- * 获取游戏地址
- *
- * @param int $app_id 游戏id
- * @param int $agent_id 渠道id
- *
- * @return array
- */
- public function getGameUrl($app_id, $agent_id) {
- $_game_model = new GameModel();
- $_info = $_game_model->getInfoById($app_id);
- if (empty($_info)) {
- $_code = GameStatus::GAME_NOT_EXISTS;
- return $this->huoError($_code, GameStatus::getMsg($_code));
- }
- if (GameConst::GAME_IOS_SWITCH_H5 != $_info['classify']) {
- $_code = GameStatus::SERVER_TYPE_ERROR;
- return $this->huoError($_code, GameStatus::getMsg($_code));
- }
- /* 获得绑定的H5游戏 */
- $_parent_id = get_val($_info, 'parent_id', 0);
- $_info = $_game_model->getInfoById($_parent_id);
- if (empty($_info)) {
- $_code = GameStatus::GAME_NOT_EXISTS;
- return $this->huoError($_code, GameStatus::getMsg($_code));
- }
- if (GameConst::GAME_H5 != $_info['classify']) {
- $_code = GameStatus::SERVER_TYPE_ERROR;
- return $this->huoError($_code, GameStatus::getMsg($_code));
- }
- $_url = MOBILESITE.'/sdk.php/game?game_id='.$_parent_id.'&agent_id='.$agent_id.'&vb_id='.$app_id;
- $_rdata = [
- 'data' => $_url
- ];
- $_code = GameStatus::NO_ERROR;
- return $this->huoSuccess($_code, GameStatus::getMsg($_code), $_rdata);
- }
- }
|