1
This commit is contained in:
parent
0bc76761aa
commit
f46b344a9f
@ -2,6 +2,8 @@
|
||||
|
||||
require_once('models/User.php');
|
||||
|
||||
require_once('mt/RankActivity.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
use models\User;
|
||||
@ -74,11 +76,64 @@ class RankingController extends BaseAuthedController {
|
||||
|
||||
public function activityRankingList()
|
||||
{
|
||||
$rankingList = $this->internalGetActivityRankList(1);
|
||||
$this->_rspData(array(
|
||||
'ranking_list' =>$rankingList
|
||||
));
|
||||
}
|
||||
|
||||
private function internalGetActivityRankList($type)
|
||||
{
|
||||
|
||||
$rankingList = array();
|
||||
$meta = mt\RankActivity::get($type);
|
||||
if (!$meta || !mt\RankActivity::isActivityPeriod($meta)) {
|
||||
return $rankingList;
|
||||
}
|
||||
$row = myself()->_getSelfMysql()->execQueryOne(
|
||||
'SELECT COUNT(*) AS row_count FROM t_rank_activity ' .
|
||||
'WHERE type=:type AND value>=:value;',
|
||||
array(
|
||||
':type' => $type,
|
||||
':value' => $meta['cond']
|
||||
)
|
||||
);
|
||||
if ($row['row_count'] > 0) {
|
||||
$count = $row['row_count'];
|
||||
$rows = myself()->_getSelfMysql()->execQuery(
|
||||
'SELECT * FROM t_rank_activity ' .
|
||||
'WHERE type=:type AND value>=:value ' .
|
||||
'ORDER BY value DESC, modifytime ASC ' .
|
||||
"LIMIT ${count}",
|
||||
array(
|
||||
':type' => $type,
|
||||
':value' => $meta['cond']
|
||||
)
|
||||
);
|
||||
$ranked = 1;
|
||||
foreach ($rows as $row) {
|
||||
$user = User::find($row['account_id']);
|
||||
if ($user) {
|
||||
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'],
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
return $rankingList;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user