| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 | 
							- <?php
 
- /**
 
-  * MemGameController.php UTF-8
 
-  * 玩家小程序游戏
 
-  *
 
-  * @date    : 2018/8/15 14:31
 
-  *
 
-  * @license 这不是一个自由软件,未经授权不许任何使用和传播。
 
-  * @author  : luowei <lw@huosdk.com>
 
-  * @version : HuoMP 1.0
 
-  */
 
- namespace box\api\controller;
 
- use box\common\controller\V2ApiBaseController;
 
- use huo\controller\agent\AgentGame;
 
- use huo\controller\game\GameCache;
 
- use huo\model\agent\AgentGameModel;
 
- use huo\model\user\UserModel;
 
- use huolib\constant\CommonConst;
 
- use huolib\constant\GameConst;
 
- use huolib\status\CommonStatus;
 
- use huolib\status\GameStatus;
 
- use huolib\status\MemberStatus;
 
- use huomp\logic\game\AgentGameListLogic;
 
- use huomp\logic\game\MemGameLogic;
 
- class MemGameController extends V2ApiBaseController {
 
-     public function _initialize() {
 
-         parent::_initialize();
 
-     }
 
-     /**
 
-      * 玩家的推广游戏列表
 
-      * http://doc.1tsdk.com/159?page_id=4397
 
-      * 【域名】/mem/game/list
 
-      */
 
-     public function index() {
 
-         $_to_mem_id = get_val($this->rq_data, 'to_mem_id', null);
 
-         $_page = get_val($this->rq_data, 'page', 1);
 
-         $_offset = get_val($this->rq_data, 'offset', 10);
 
-         if (!empty($_to_mem_id)) {
 
-             //查看别人的推广游戏
 
-             $_agent_info = (new UserModel())->getInfoByMemId($_to_mem_id);
 
-         } else {
 
-             //查看自己的推广游戏
 
-             $_agent_info = (new UserModel())->getInfoByMemId($this->mem_id);
 
-         }
 
-         if (empty($_agent_info)) {
 
-             $_code = MemberStatus::YOU_ARE_NOT_AGENT;
 
-             $this->error(MemberStatus::getMsg($_code), [], $_code);
 
-         }
 
-         $_param = ['agent_id' => $_agent_info['id'], 'classify' => GameConst::GAME_MP];
 
-         $_page = $_page.','.$_offset;
 
-         $_order = '-gameext.down_cnt';
 
-         $_rdata = (new AgentGameListLogic())->getAgentGames($this->mem_id, $_param, $_page, $_order);
 
-         $_code = CommonStatus::NO_ERROR;
 
-         $this->success(CommonStatus::getMsg($_code), $_rdata, $_code);
 
-     }
 
-     /**
 
-      * 玩家添加推广游戏
 
-      * http://doc.1tsdk.com/159?page_id=4398
 
-      * 【域名】/mem/game/add
 
-      */
 
-     public function add() {
 
-         $this->checkLogin();
 
-         $_game_id = get_val($this->rq_data, 'game_id');
 
-         if (empty($_game_id)) {
 
-             $_code = GameStatus::GAME_ID_EMPTY;
 
-             $this->error(GameStatus::getMsg($_code), [], $_code);
 
-         }
 
-         $_app_info = (new GameCache())->getInfoByAppId($_game_id);
 
-         if (empty($_app_info)) {
 
-             $_code = GameStatus::GAME_NOT_EXISTS;
 
-             $this->error(GameStatus::getMsg($_code), [], $_code);
 
-         }
 
-         if ($_app_info['is_delete'] != CommonConst::CONST_NOT_DELETE) {
 
-             $_code = GameStatus::GAME_NOT_EXISTS;
 
-             $this->error(GameStatus::getMsg($_code), [], $_code);
 
-         }
 
-         if ($_app_info['status'] != GameConst::GAME_STATUS_ON) {
 
-             $_code = GameStatus::GAME_ONLINE_NO;
 
-             $this->error(GameStatus::getMsg($_code), [], $_code);
 
-         }
 
- //        if ($_app_info['promote_switch'] != GameConst::GAME_PROMOTE_SWITCH_CAN) {
 
- //            $_code = GameStatus::GAME_PROMOTE_SWITCH_NO;
 
- //            $this->error(GameStatus::getMsg($_code), [], $_code);
 
- //        }
 
-         $_agent_info = (new UserModel())->getInfoByMemId($this->mem_id);
 
-         if (empty($_agent_info)) {
 
-             $_code = MemberStatus::YOU_ARE_NOT_AGENT;
 
-             $this->error(MemberStatus::getMsg($_code), [], $_code);
 
-         }
 
-         $_rs = (new AgentGame())->addGame($_agent_info['id'], $_game_id);
 
-         if (!$_rs) {
 
-             $_code = CommonStatus::INNER_ERROR;
 
-             $this->error(CommonStatus::getMsg($_code), [], $_code);
 
-         }
 
-         $_code = CommonStatus::NO_ERROR;
 
-         $this->success(CommonStatus::getMsg($_code), [], $_code);
 
-     }
 
-     /**
 
-      * 玩家取消推广游戏
 
-      * http://doc.1tsdk.com/159?page_id=4399
 
-      * 【域名】/mem/game/cancel
 
-      */
 
-     public function cancel() {
 
-         $this->checkLogin();
 
-         $_game_id = get_val($this->rq_data, 'game_id');
 
-         if (empty($_game_id)) {
 
-             $_code = GameStatus::GAME_ID_EMPTY;
 
-             $this->error(GameStatus::getMsg($_code), [], $_code);
 
-         }
 
-         $_app_info = (new GameCache())->getInfoByAppId($_game_id);
 
-         if (empty($_app_info)) {
 
-             $_code = GameStatus::GAME_NOT_EXISTS;
 
-             $this->error(GameStatus::getMsg($_code), [], $_code);
 
-         }
 
-         $_agent_info = (new UserModel())->getInfoByMemId($this->mem_id);
 
-         if (empty($_agent_info)) {
 
-             $_code = MemberStatus::YOU_ARE_NOT_AGENT;
 
-             $this->error(MemberStatus::getMsg($_code), [], $_code);
 
-         }
 
-         $_ag_model = new AgentGameModel();
 
-         $_ag_info = $_ag_model->getInfoByAgentIdAppId($_agent_info['id'], $_game_id);
 
-         if (empty($_ag_info)) {
 
-             $_code = GameStatus::NOT_YET_ADDED_GAME;
 
-             $this->error(GameStatus::getMsg($_code), [], $_code);
 
-         }
 
-         if ($_ag_info['is_delete'] == CommonConst::CONST_DELETED) {
 
-             //已被删除,直接返回
 
-             $_code = CommonStatus::NO_ERROR;
 
-             $this->success(CommonStatus::getMsg($_code), [], $_code);
 
-         } else {
 
-             $_ag_info['is_delete'] = CommonConst::CONST_DELETED;
 
-             $_ag_info['delete_time'] = time();
 
-             $_rs = $_ag_model->updateData($_ag_info, $_ag_info['id']);
 
-             if (!$_rs) {
 
-                 $_code = CommonStatus::INNER_ERROR;
 
-                 $this->error(CommonStatus::getMsg($_code), [], $_code);
 
-             }
 
-             $_code = CommonStatus::NO_ERROR;
 
-             $this->success(CommonStatus::getMsg($_code), [], $_code);
 
-         }
 
-     }
 
-     /**
 
-      * 我玩过的游戏列表
 
-      * http://doc.1tsdk.com/159?page_id=4498
 
-      * 【域名】/mem/game/playlist
 
-      */
 
-     public function playList() {
 
-         $this->checkLogin();
 
-         $_page = get_val($this->rq_data, 'page', 1);
 
-         $_offset = get_val($this->rq_data, 'offset', 10);
 
-         //查看自己的推广游戏
 
-         $_agent_info = (new UserModel())->getInfoByMemId($this->mem_id);
 
-         if (empty($_agent_info)) {
 
-             $_code = MemberStatus::YOU_ARE_NOT_AGENT;
 
-             $this->error(MemberStatus::getMsg($_code), [], $_code);
 
-         }
 
-         $_param = [];
 
-         $_page = $_page.','.$_offset;
 
-         $_mg_logic = new MemGameLogic();
 
-         $_rdata = $_mg_logic->getApiMemGame($this->mem_id, $_param, $_page);
 
-         $_code = CommonStatus::NO_ERROR;
 
-         $this->success(CommonStatus::getMsg($_code), $_rdata, $_code);
 
-     }
 
- }
 
 
  |