@ -217,104 +217,42 @@ class ApplyController extends BaseController
//查看游戏资料专区
public function feature($p = 0, $type = 0)
{
$promoteId = empty(I('promote_id')) ? PID : I('promote_id');//搜索的渠道ID
$promoteRole = empty(I('promote_role')) ? 1 : I('promote_role');//渠道角色
//$parentPromoteId = getParentPromoteId($promoteId);//上级渠道ID
$thisParentPromoteId = getParentPromoteId(PID);//本账号上级渠道ID
$map = ['_string' => '1=1'];
$map['online_status'] = 1;//开发者游戏上线状态
$map['down_port'] = 1;//游戏端口 第三方接口不能申请
$map['game_status'] = 1;//游戏状态
$map['developers'] = 0; //平台游戏(官网游戏,非开发者游戏)
// $addPermission = 1;//是否有添加游戏权限
// if ($thisParentPromoteId == 0 & & $promoteRole == 3) {
// $addPermission = 0;
// }
$map['tab_game.online_status'] = 1;//开发者游戏上线状态
$map['tab_game.down_port'] = 1;//游戏端口 第三方接口不能申请
$map['tab_game.game_status'] = 1;//游戏状态
$map['tab_game.developers'] = 0; //平台游戏(官网游戏,非开发者游戏)
$applyPromote = M('apply', 'tab_')->field('game_id')->where(['promote_id' => $promoteId])->select();
$noDeveloperGameArr = array();
foreach ($applyPromote as $key => $value) {
$applyPromoteGameId = $value['game_id'];
$gameInfo = M('Game', 'tab_')
->field('id,icon,game_name,features,sdk_version,game_size,game_type_name,relation_game_name,developers')
->where(['id' => $applyPromoteGameId])->select();
if ($gameInfo[0]['developers'] > 0) {
unset($gameInfo[0]['developers']);
$noDeveloperGameArr[] = $gameInfo[0]['id']; //非开发者游戏
}
}
$page = intval($p);
$page = $page ? $page : 1; //默认显示第一页数据
if (isset($_REQUEST['row'])) {
$row = $_REQUEST['row'];
$promote = $this->getLoginPromote();
$promoteService = new PromoteService();
$gameIds = $promoteService->getVisibleGameIds($promote);
if (count($gameIds) > 0) {
$map['id'] = ['in', $gameIds];
} else {
$row = 10 ;
$map['_string'] .= ' and 1< >1';
}
$map['_logic'] = 'and';
if (!empty(I('game_id'))) {
$thisRelationGameName = M('Game', 'tab_')->where(array('id' => I('game_id')))->getField('relation_game_name');
$map['tab_game.relation_game_name'] = ['like', $thisRelationGameName];
$where['_complex'] = $map;
// $where['tab_game.id'] = ['in',$noDeveloperGameArr];
// $where['_logic']='or';
} else {
$where['_complex'] = $map;
if (empty($noDeveloperGameArr)) {
$where['tab_game.id'] = ['in', '-100'];
$relationGameId = M('game', 'tab_')->where(array('id' => I('game_id')))->getField('relation_game_id');
if ($relationGameId) {
$map['_string'] .= ' and relation_game_id=' . $relationGameId;
} else {
$where['tab_game.id'] = ['in', $noDeveloperGameArr] ;
$map['_string'] .= ' and 1< >1';
}
$where['_logic'] = 'or';
}
$data = M('Game', 'tab_')
->field('tab_game.id,tab_game.icon,tab_game.game_name,tab_game.features,tab_game.sdk_version,tab_game.game_size,tab_game.game_type_name,tab_game.relation_game_name,ta_1.id as apply_id_1')
->join('left join tab_apply as ta_1 on tab_game.id = ta_1.game_id and ta_1.offline_status = 0 and ta_1.promote_id = ' . $promoteId)//查询是否拥有该游戏
->where($where)
->order('tab_game.developers desc,tab_game.sort desc,tab_game.id desc')
->page($page, $row)
->select();
//$AllData = array_merge($noDeveloperGameArr,$data);
/* 查询记录总数 */
$count = M("Game", "tab_")
->field('tab_game.id')
$query = M('game', 'tab_')
->field('id,icon,game_name,features,sdk_version,game_size,game_type_name,relation_game_name')
->where($map)
->select();
$count = count($count);
//分页
$parameter['p'] = I('get.p', 1);
$parameter['row'] = I('get.row');
$parameter['type'] = $type;
$parameter['promote_role'] = $promoteRole;
empty(I('promote_id')) || $parameter['promote_id'] = I('promote_id');
$page = set_pagination($count, $row, $parameter);
if ($page) {
$this->assign('_page', $page);
}
$this->assign('list_data', $data);
$this->assign("count", $count);
$this->assign("promoteId", $promoteId);
// $this->assign('parentPromoteId', $parentPromoteId);
$this->assign('thisParentPromoteId', $thisParentPromoteId);
// $this->assign('promoteRole', $promoteRole);
$this->assign('pID', PID);
//$this->assign('promoteData', getAllPromoteListByType($promoteRole));
// $this->assign('addPermission', $addPermission);
// $this->assign('type', $type);
->order('developers desc,sort desc,id desc');
$this->meta_title = "申请游戏" ;
list($records, $pagination, $count) = $this->paginate($query);
$this->assign('pagination', $pagination);
$this->assign('records', $records);
$this->assign('count', $count);
$this->assign('games', $this->getSelectGames());
$this->meta_title = "资料专区";
$this->display();
}