alias('g') ->field('g.*,g.id as game_id,IFNULL(r.ratio,0) as ratio,IF(g.down_port=1,s.file_size,g.game_address_size) as game_size') //游戏原包 ->join("left join tab_game_source as s on s.game_id = g.id") //返利 ->join("left join tab_rebate r on r.game_id = g.id {$rebate_join} and r.starttime < {$time} and (endtime = 0 or endtime > {$time})") ->where($where) ->page($page, $row) ->order($order) ->select(); foreach ($data as $key => $val){ $data[$key]['icon'] = get_cover($val['icon'],'path'); $data[$key]['game_score'] = $val['game_score']; if(!is_mobile_request()){ $data[$key]['relation_game_name'] = $val['game_name']; } } $title = '排行榜'; $this->assign('data',$data); $this->assign('page',$page); $this->assign('name',$name); $this->assign('rank',$rank); $this->assign('mate_title', $title); $this->display(); } public function ajaxlists() { $rank = I('request.rank') ? I('request.rank') : 'new'; $p = I('post.p'); $status = 0; $row = C('LIST_ROWS'); $model = M('Game','tab_'); $devices = get_devices_type(); $promote_id = empty(PROMOTE_ID) ? 0 : PROMOTE_ID; $rebate_join = "and (r.promote_id = {$promote_id} or r.promote_id = -1)"; $time = NOW_TIME; $where['g.game_status'] = 1; $where['g.display_site'] = ['like','%'. DISPLAY_SITE .'%']; $where['g.apply_status'] = 1; $where['g.online_status'] = 1; $where['g.sdk_version'] = array('like','%'.$devices.'%'); if($rank == 'new'){ //最新榜 $where['g.recommend_status'] = 3; $order = 'g.sort desc,g.id desc'; }elseif($rank == 'rec'){ //推荐榜 $where['g.recommend_status'] = 1; $order = 'g.sort desc,g.id desc'; }elseif($rank == 'hot'){ //热门榜 $where['g.recommend_status'] = 2; $order = 'g.sort desc,g.id desc'; }elseif($rank == 'dow'){ //热门榜 $order = 'g.dow_num desc,g.id desc'; }else{ $order = 'g.sort desc,g.id desc'; } $data = $model ->alias('g') ->field('g.*,g.id as game_id,IFNULL(r.ratio,0) as ratio,IF(g.down_port=1,s.file_size,g.game_address_size) as game_size') //游戏原包 ->join("left join tab_game_source as s on s.game_id = g.id") //返利 ->join("left join tab_rebate r on r.game_id = g.id {$rebate_join} and r.starttime < {$time} and (endtime = 0 or endtime > {$time})") ->where($where) ->page($p, $row) ->order($order) ->group("g.relation_game_id") ->select(); foreach ($data as $key => $val){ $data[$key]['icon'] = get_cover($val['icon'],'path'); $data[$key]['game_score'] = round($val['game_score'] / 2); if(!is_mobile_request()){ $data[$key]['relation_game_name'] = $val['game_name']; } if($val['game_size'] == 0){ $data[$key]['game_size'] = "0MB"; } } if (!empty($data) && is_array($data)) {$status=1;} echo json_encode(array('status'=>$status,'page'=>$p,'data'=>$data)); } }