Game.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Game.php UTF-8
  4. * 游戏基类
  5. *
  6. * @date : 2020/9/15 9:46
  7. *
  8. * @license 这不是一个自由软件,未经授权不许任何使用和传播。
  9. * @author : chenbingling <cbl@huosdk.com>
  10. * @version : H5IOS 1.0
  11. */
  12. namespace huosdk\h5ios\core\controller;
  13. use huosdk\h5ios\core\constant\GameConst;
  14. use huosdk\h5ios\core\model\GameModel;
  15. use huosdk\h5ios\core\status\GameStatus;
  16. class Game extends Base {
  17. /***
  18. * 获取游戏地址
  19. *
  20. * @param int $app_id 游戏id
  21. * @param int $agent_id 渠道id
  22. *
  23. * @return array
  24. */
  25. public function getGameUrl($app_id, $agent_id) {
  26. $_game_model = new GameModel();
  27. $_info = $_game_model->getInfoById($app_id);
  28. if (empty($_info)) {
  29. $_code = GameStatus::GAME_NOT_EXISTS;
  30. return $this->huoError($_code, GameStatus::getMsg($_code));
  31. }
  32. if (GameConst::GAME_IOS_SWITCH_H5 != $_info['classify']) {
  33. $_code = GameStatus::SERVER_TYPE_ERROR;
  34. return $this->huoError($_code, GameStatus::getMsg($_code));
  35. }
  36. /* 获得绑定的H5游戏 */
  37. $_parent_id = get_val($_info, 'parent_id', 0);
  38. $_info = $_game_model->getInfoById($_parent_id);
  39. if (empty($_info)) {
  40. $_code = GameStatus::GAME_NOT_EXISTS;
  41. return $this->huoError($_code, GameStatus::getMsg($_code));
  42. }
  43. if (GameConst::GAME_H5 != $_info['classify']) {
  44. $_code = GameStatus::SERVER_TYPE_ERROR;
  45. return $this->huoError($_code, GameStatus::getMsg($_code));
  46. }
  47. $_url = MOBILESITE.'/sdk.php/game?game_id='.$_parent_id.'&agent_id='.$agent_id.'&vb_id='.$app_id;
  48. $_rdata = [
  49. 'data' => $_url
  50. ];
  51. $_code = GameStatus::NO_ERROR;
  52. return $this->huoSuccess($_code, GameStatus::getMsg($_code), $_rdata);
  53. }
  54. }