This commit is contained in:
hujiabin 2023-05-22 14:02:47 +08:00
parent 08cf62cfed
commit 78f7fad29f
2 changed files with 21 additions and 12 deletions

View File

@ -51,18 +51,25 @@ class RankingController extends BaseAuthedController {
{ {
$userInfo = $this->_getOrmUserInfo(); $userInfo = $this->_getOrmUserInfo();
$type = getReqVal('type', 0); $type = getReqVal('type', 0);
if (! RankBattle::inspectType($type)){
$this->_rspErr(1, 'type param error');
return;
}
$list = RankBattle::getTopLimit($type,100); $list = RankBattle::getTopLimit($type,100);
$rankingList = array(); $rankingList = array();
$ranked = 1; $ranked = 1;
foreach ($list as $row) { if (count($list) > 0){
$user = User::find($row['account_id']); foreach ($list as $row) {
array_push($rankingList, array( $user = User::find($row['account_id']);
'ranked' => $ranked++, array_push($rankingList, array(
'user' => $this->_extractUserInfo($user), 'ranked' => $ranked++,
'value' => $row['value'], 'user' => $this->_extractUserInfo($user),
'modifytime' => $row['modifytime'], 'value' => $row['value'],
)); 'modifytime' => $row['modifytime'],
));
}
} }
$myRanked = array( $myRanked = array(
@ -78,9 +85,11 @@ class RankingController extends BaseAuthedController {
} }
$lists = RankBattle::getTopLimit($type,10000,array('account_id')); $lists = RankBattle::getTopLimit($type,10000,array('account_id'));
foreach ($lists as $k=>$row){ if (count($lists) > 0){
if ($userInfo['account_id'] == $row['account_id']){ foreach ($lists as $k=>$row){
$myRanked['ranked'] = $k+1; if ($userInfo['account_id'] == $row['account_id']){
$myRanked['ranked'] = $k+1;
}
} }
} }

View File

@ -14,7 +14,7 @@ class RankBattle extends BaseModel
const TOP_THREE_TIMES = 4; const TOP_THREE_TIMES = 4;
const KILL_TIMES = 5; const KILL_TIMES = 5;
private static function inspectType($type){ public static function inspectType($type){
if (!in_array($type,array( if (!in_array($type,array(
self::GAME_TIMES, self::GAME_TIMES,
self::WIN_TIMES, self::WIN_TIMES,