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,10 +51,16 @@ class RankingController extends BaseAuthedController {
{
$userInfo = $this->_getOrmUserInfo();
$type = getReqVal('type', 0);
if (! RankBattle::inspectType($type)){
$this->_rspErr(1, 'type param error');
return;
}
$list = RankBattle::getTopLimit($type,100);
$rankingList = array();
$ranked = 1;
if (count($list) > 0){
foreach ($list as $row) {
$user = User::find($row['account_id']);
array_push($rankingList, array(
@ -64,6 +70,7 @@ class RankingController extends BaseAuthedController {
'modifytime' => $row['modifytime'],
));
}
}
$myRanked = array(
'ranked' => -1,
@ -78,11 +85,13 @@ class RankingController extends BaseAuthedController {
}
$lists = RankBattle::getTopLimit($type,10000,array('account_id'));
if (count($lists) > 0){
foreach ($lists as $k=>$row){
if ($userInfo['account_id'] == $row['account_id']){
$myRanked['ranked'] = $k+1;
}
}
}
$rankingData = array(
'type' => $type,

View File

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