1
This commit is contained in:
parent
817645d52b
commit
8b1f3a02a0
@ -30,7 +30,7 @@ class Ranking(object):
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['ranking_list', _common.RankingList(), '排行榜数据']
|
||||
['ranking_list', _common.RankingListEx(), '排行榜数据']
|
||||
]
|
||||
}
|
||||
]
|
||||
|
@ -129,6 +129,24 @@ class UserInfo(object):
|
||||
['!head_frame_list', [0], '拥有的头像框列表'],
|
||||
]
|
||||
|
||||
class UserSimple(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['account_id', '', '账号id'],
|
||||
['address', '', '钱包地址'],
|
||||
['name', '', '用户名字'],
|
||||
['head_id', 0, '头像id'],
|
||||
['head_frame', 0, '头像框id'],
|
||||
['level', 0, '等级'],
|
||||
['exp', 0, '经验'],
|
||||
['gold', 0, '金币'],
|
||||
['diamond', 0, '钻石'],
|
||||
['hero_id', 0, '当前使用的英雄ID'],
|
||||
['rank', 0, '段位'],
|
||||
['score', 0, '积分'],
|
||||
]
|
||||
|
||||
class BcUserInfo(object):
|
||||
|
||||
def __init__(self):
|
||||
@ -399,6 +417,24 @@ class RankingList(object):
|
||||
['my_ranked', RankingItem(), '我的排名(如果ranked<1则表示自己未上榜)'],
|
||||
]
|
||||
|
||||
class RankingItemEx(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['ranked', 0, '排名'],
|
||||
['user', UserSimple(), '用户信息'],
|
||||
['value', 0, '存活时间 击杀数'],
|
||||
]
|
||||
|
||||
class RankingListEx(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['type', 0, '排行榜类型 1:存活时间 2:击杀数'],
|
||||
['!rows', [RankingItemEx()], '排行榜'],
|
||||
['my_ranked', RankingItemEx(), '我的排名(如果ranked<1则表示自己未上榜)'],
|
||||
]
|
||||
|
||||
class RedDot(object):
|
||||
|
||||
def __init__(self):
|
||||
|
@ -87,27 +87,15 @@ class RankingController extends BaseAuthedController {
|
||||
$userInfo = $this->_getOrmUserInfo();
|
||||
$myRanked = array(
|
||||
'ranked' => -1,
|
||||
'account_id' => $this->_getAccountId(),
|
||||
'address' => $this->_getOpenId(),
|
||||
'name' => $userInfo['name'],
|
||||
'sex' => $userInfo['sex'],
|
||||
'head_id' => $userInfo['hero_id'],
|
||||
'head_frame' => $userInfo['head_frame'],
|
||||
'level' => $userInfo['level'],
|
||||
'exp' => $userInfo['exp'],
|
||||
'rank' => $userInfo['rank'],
|
||||
'score' => $userInfo['score'],
|
||||
'gold' => $userInfo['gold'],
|
||||
'diamond' => $userInfo['diamond'],
|
||||
'hero_id' => $userInfo['hero_id'],
|
||||
'first_fight' => $userInfo['first_fight'],
|
||||
'user' => User::toSimple($userInfo),
|
||||
'value' => 0
|
||||
);
|
||||
$rankingList = array();
|
||||
$meta = mt\RankActivity::get($type);
|
||||
if ($meta && mt\RankActivity::isActivityPeriod($meta)) {
|
||||
$row = myself()->_getSelfMysql()->execQueryOne(
|
||||
'SELECT COUNT(*) AS row_count FROM t_rank_activity ' .
|
||||
'WHERE type=:type AND value>=:value;',
|
||||
'WHERE type=:type AND value>:value;',
|
||||
array(
|
||||
':type' => $type,
|
||||
':value' => $meta['cond']
|
||||
@ -129,25 +117,13 @@ class RankingController extends BaseAuthedController {
|
||||
foreach ($rows as $row) {
|
||||
$user = User::find($row['account_id']);
|
||||
if ($user) {
|
||||
if ($user['account_id'] == $myRanked['account_id']) {
|
||||
if ($user['account_id'] == $myRanked['user']['account_id']) {
|
||||
$myRanked['ranked'] = $ranked;
|
||||
}
|
||||
array_push($rankingList, array(
|
||||
'ranked' => $ranked++,
|
||||
'account_id' => $user['account_id'],
|
||||
'address' => phpcommon\extractOpenId($user['account_id']),
|
||||
'name' => $user['name'],
|
||||
'sex' => $user['sex'],
|
||||
'head_id' => $user['hero_id'],
|
||||
'head_frame' => $user['head_frame'],
|
||||
'level' => $user['level'],
|
||||
'exp' => $user['exp'],
|
||||
'rank' => $user['rank'],
|
||||
'score' => $user['score'],
|
||||
'gold' => $user['gold'],
|
||||
'diamond' => $user['diamond'],
|
||||
'hero_id' => $user['hero_id'],
|
||||
'first_fight' => $user['first_fight'],
|
||||
'user' => User::toSimple($user),
|
||||
'value' => 0
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -155,7 +131,7 @@ class RankingController extends BaseAuthedController {
|
||||
}
|
||||
$rankingData = array(
|
||||
'type' => $type,
|
||||
'ranking_list' => $rankingList,
|
||||
'rows' => $rankingList,
|
||||
'my_ranked' => $myRanked
|
||||
);
|
||||
return $rankingData;
|
||||
|
@ -5,6 +5,7 @@ namespace models;
|
||||
require_once('mt/Item.php');
|
||||
|
||||
use mt;
|
||||
use phpcommon;
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
class User extends BaseModel {
|
||||
@ -73,6 +74,26 @@ class User extends BaseModel {
|
||||
);
|
||||
}
|
||||
|
||||
public static function toSimple($row)
|
||||
{
|
||||
return array(
|
||||
'account_id' => $row['account_id'],
|
||||
'address' => phpcommon\extractOpenId($row['account_id']),
|
||||
'name' => $row['name'],
|
||||
'sex' => $row['sex'],
|
||||
'head_id' => $row['hero_id'],
|
||||
'head_frame' => $row['head_frame'],
|
||||
'level' => $row['level'],
|
||||
'exp' => $row['exp'],
|
||||
'rank' => $row['rank'],
|
||||
'score' => $row['score'],
|
||||
'gold' => $row['gold'],
|
||||
'diamond' => $row['diamond'],
|
||||
'hero_id' => $row['hero_id'],
|
||||
'first_fight' => $row['first_fight'],
|
||||
);
|
||||
}
|
||||
|
||||
public static function isValidHeadId($userInfo, $headId)
|
||||
{
|
||||
$headList = self::getHeadList($userInfo);
|
||||
|
Loading…
x
Reference in New Issue
Block a user