1
This commit is contained in:
parent
817645d52b
commit
8b1f3a02a0
@ -30,7 +30,7 @@ class Ranking(object):
|
|||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
['ranking_list', _common.RankingList(), '排行榜数据']
|
['ranking_list', _common.RankingListEx(), '排行榜数据']
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -129,6 +129,24 @@ class UserInfo(object):
|
|||||||
['!head_frame_list', [0], '拥有的头像框列表'],
|
['!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):
|
class BcUserInfo(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -399,6 +417,24 @@ class RankingList(object):
|
|||||||
['my_ranked', RankingItem(), '我的排名(如果ranked<1则表示自己未上榜)'],
|
['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):
|
class RedDot(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -87,27 +87,15 @@ class RankingController extends BaseAuthedController {
|
|||||||
$userInfo = $this->_getOrmUserInfo();
|
$userInfo = $this->_getOrmUserInfo();
|
||||||
$myRanked = array(
|
$myRanked = array(
|
||||||
'ranked' => -1,
|
'ranked' => -1,
|
||||||
'account_id' => $this->_getAccountId(),
|
'user' => User::toSimple($userInfo),
|
||||||
'address' => $this->_getOpenId(),
|
'value' => 0
|
||||||
'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'],
|
|
||||||
);
|
);
|
||||||
$rankingList = array();
|
$rankingList = array();
|
||||||
$meta = mt\RankActivity::get($type);
|
$meta = mt\RankActivity::get($type);
|
||||||
if ($meta && mt\RankActivity::isActivityPeriod($meta)) {
|
if ($meta && mt\RankActivity::isActivityPeriod($meta)) {
|
||||||
$row = myself()->_getSelfMysql()->execQueryOne(
|
$row = myself()->_getSelfMysql()->execQueryOne(
|
||||||
'SELECT COUNT(*) AS row_count FROM t_rank_activity ' .
|
'SELECT COUNT(*) AS row_count FROM t_rank_activity ' .
|
||||||
'WHERE type=:type AND value>=:value;',
|
'WHERE type=:type AND value>:value;',
|
||||||
array(
|
array(
|
||||||
':type' => $type,
|
':type' => $type,
|
||||||
':value' => $meta['cond']
|
':value' => $meta['cond']
|
||||||
@ -129,25 +117,13 @@ class RankingController extends BaseAuthedController {
|
|||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$user = User::find($row['account_id']);
|
$user = User::find($row['account_id']);
|
||||||
if ($user) {
|
if ($user) {
|
||||||
if ($user['account_id'] == $myRanked['account_id']) {
|
if ($user['account_id'] == $myRanked['user']['account_id']) {
|
||||||
$myRanked['ranked'] = $ranked;
|
$myRanked['ranked'] = $ranked;
|
||||||
}
|
}
|
||||||
array_push($rankingList, array(
|
array_push($rankingList, array(
|
||||||
'ranked' => $ranked++,
|
'ranked' => $ranked++,
|
||||||
'account_id' => $user['account_id'],
|
'user' => User::toSimple($user),
|
||||||
'address' => phpcommon\extractOpenId($user['account_id']),
|
'value' => 0
|
||||||
'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'],
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -155,7 +131,7 @@ class RankingController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
$rankingData = array(
|
$rankingData = array(
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'ranking_list' => $rankingList,
|
'rows' => $rankingList,
|
||||||
'my_ranked' => $myRanked
|
'my_ranked' => $myRanked
|
||||||
);
|
);
|
||||||
return $rankingData;
|
return $rankingData;
|
||||||
|
@ -5,6 +5,7 @@ namespace models;
|
|||||||
require_once('mt/Item.php');
|
require_once('mt/Item.php');
|
||||||
|
|
||||||
use mt;
|
use mt;
|
||||||
|
use phpcommon;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
|
|
||||||
class User extends BaseModel {
|
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)
|
public static function isValidHeadId($userInfo, $headId)
|
||||||
{
|
{
|
||||||
$headList = self::getHeadList($userInfo);
|
$headList = self::getHeadList($userInfo);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user