This commit is contained in:
aozhiwei 2022-05-14 07:33:21 +08:00
parent f46b344a9f
commit 817645d52b

View File

@ -76,64 +76,89 @@ class RankingController extends BaseAuthedController {
public function activityRankingList() public function activityRankingList()
{ {
$rankingList = $this->internalGetActivityRankList(1); $rankingList = $this->internalGetActivityRankData(1);
$this->_rspData(array( $this->_rspData(array(
'ranking_list' =>$rankingList 'ranking_list' =>$rankingList
)); ));
} }
private function internalGetActivityRankList($type) private function internalGetActivityRankData($type)
{ {
$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'],
);
$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)) {
return $rankingList; $row = myself()->_getSelfMysql()->execQueryOne(
} 'SELECT COUNT(*) AS row_count FROM t_rank_activity ' .
$row = myself()->_getSelfMysql()->execQueryOne( 'WHERE type=:type AND value>=:value;',
'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( array(
':type' => $type, ':type' => $type,
':value' => $meta['cond'] ':value' => $meta['cond']
) )
); );
$ranked = 1; if ($row['row_count'] > 0) {
foreach ($rows as $row) { $count = $row['row_count'];
$user = User::find($row['account_id']); $rows = myself()->_getSelfMysql()->execQuery(
if ($user) { 'SELECT * FROM t_rank_activity ' .
array_push($rankingList, array( 'WHERE type=:type AND value>=:value ' .
'ranked' => $ranked++, 'ORDER BY value DESC, modifytime ASC ' .
'account_id' => $user['account_id'], "LIMIT ${count}",
'address' => phpcommon\extractOpenId($user['account_id']), array(
'name' => $user['name'], ':type' => $type,
'sex' => $user['sex'], ':value' => $meta['cond']
'head_id' => $user['hero_id'], )
'head_frame' => $user['head_frame'], );
'level' => $user['level'], $ranked = 1;
'exp' => $user['exp'], foreach ($rows as $row) {
'rank' => $user['rank'], $user = User::find($row['account_id']);
'score' => $user['score'], if ($user) {
'gold' => $user['gold'], if ($user['account_id'] == $myRanked['account_id']) {
'diamond' => $user['diamond'], $myRanked['ranked'] = $ranked;
'hero_id' => $user['hero_id'], }
'first_fight' => $user['first_fight'], 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; $rankingData = array(
'type' => $type,
'ranking_list' => $rankingList,
'my_ranked' => $myRanked
);
return $rankingData;
} }
} }