1
This commit is contained in:
parent
4789c8b79e
commit
0e8d26bbd2
@ -43,6 +43,11 @@ class BaseController {
|
||||
return $this->nowtime + $this->timeOffset;
|
||||
}
|
||||
|
||||
public function _setNowTime($newTime)
|
||||
{
|
||||
$this->nowtime = $newTime;
|
||||
}
|
||||
|
||||
public function _getTimeOffset()
|
||||
{
|
||||
return $this->timeOffset;
|
||||
|
@ -80,6 +80,122 @@ class OutAppCircuitController extends BaseController {
|
||||
));
|
||||
}
|
||||
|
||||
public function getCircuitRankingTmp(){
|
||||
$this->_setNowTime(strtotime('2024-12-01 14:59:59'));
|
||||
$currentCircuitMeta = mt\CircuitTime::getCurrentCircuit();
|
||||
if (!$currentCircuitMeta){
|
||||
$this->_rspErr(1, 'current stage Have not yet started');
|
||||
return ;
|
||||
}
|
||||
$address = getReqVal('address', '');
|
||||
if (empty($address)){
|
||||
/*
|
||||
if (SERVER_ENV == _ONLINE) {
|
||||
myself()->_rspErr(1, 'param error');
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
$user = User::findByAddress($address);
|
||||
if (SERVER_ENV != _ONLINE) {
|
||||
$user = User::find('1_2006_email|6737dc9c219c150ace316a39');
|
||||
}
|
||||
$info = array(
|
||||
'start_time' => strtotime($currentCircuitMeta['start_time']),
|
||||
'end_time' => strtotime($currentCircuitMeta['end_time']),
|
||||
'ranking' => 0,
|
||||
'score' => 0,
|
||||
);
|
||||
if (!$user){
|
||||
} else {
|
||||
myself()->_callServiceStatic('CircuitRankingService',
|
||||
'fillRanking',
|
||||
$currentCircuitMeta
|
||||
);
|
||||
$redis = $this->_getRedis($this->redis_key_circuit_ranking);
|
||||
if (! $redis->exists(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_ranking)){
|
||||
$rows = Circuit::getCircuitList($currentCircuitMeta['circuit_season']);
|
||||
$sortRows = myself()->arraySort($rows, 'cumulative_score', 'desc');
|
||||
$list = $this->_extractRankingInfo($sortRows);
|
||||
$redis->set(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_ranking , json_encode($list));
|
||||
$redis->pexpire(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_ranking , 10*60*1000);
|
||||
}else{
|
||||
$listStr = $redis->get(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_ranking);
|
||||
$list = emptyReplace(json_decode($listStr, true), array());
|
||||
}
|
||||
$myInfo = $this->_celMyRankingInfo($list,$user['account_id']);
|
||||
$info = array(
|
||||
'start_time' => strtotime($currentCircuitMeta['start_time']),
|
||||
'end_time' => strtotime($currentCircuitMeta['end_time']),
|
||||
'ranking' => $myInfo['ranking'],
|
||||
'score' => $myInfo['score'],
|
||||
);
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'rank_list' => $list,
|
||||
'info' => $info,
|
||||
));
|
||||
}
|
||||
|
||||
public function getCircuitPhaseRankingTmp(){
|
||||
$this->_setNowTime(strtotime('2024-12-01 14:59:59'));
|
||||
$currentCircuitMeta = mt\CircuitTime::getCurrentCircuit();
|
||||
if (!$currentCircuitMeta){
|
||||
$this->_rspErr(1, 'current stage Have not yet started');
|
||||
return ;
|
||||
}
|
||||
$address = getReqVal('address', '');
|
||||
if (empty($address)){
|
||||
/*
|
||||
if (SERVER_ENV == _ONLINE) {
|
||||
myself()->_rspErr(1, 'param error');
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
$user = User::findByAddress($address);
|
||||
if (SERVER_ENV != _ONLINE) {
|
||||
$user = User::find('1_2006_email|6737dc9c219c150ace316a39');
|
||||
}
|
||||
if (!$user){
|
||||
$info = array(
|
||||
'start_time' => strtotime($currentStageMeta['start_time']),
|
||||
'end_time' => strtotime($currentStageMeta['end_time']),
|
||||
'ranking' => 0,
|
||||
'score' => 0
|
||||
);
|
||||
} else {
|
||||
$currentStageMeta = mt\CircuitTime::getCurrentStage();
|
||||
if (!$currentStageMeta){
|
||||
$currentStageMeta = mt\CircuitTime::getPrevStage();
|
||||
}
|
||||
myself()->_callServiceStatic('CircuitRankingService',
|
||||
'fillPhaseRanking',
|
||||
$currentCircuitMeta,
|
||||
$currentStageMeta);
|
||||
$redis = $this->_getRedis($this->redis_key_circuit_phase_ranking);
|
||||
if (! $redis->exists(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_phase_ranking)){
|
||||
$rows = Circuit::getCircuitPhaseList($currentStageMeta['circuit_season'],$currentStageMeta['circuit_phase']);
|
||||
$sortRows = myself()->arraySort($rows, 'cumulative_score', 'desc');
|
||||
$list = $this->_extractRankingInfo($sortRows);
|
||||
$redis->set(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_phase_ranking , json_encode($list));
|
||||
$redis->pexpire(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_phase_ranking , 10*60*1000);
|
||||
}else{
|
||||
$listStr = $redis->get(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_phase_ranking);
|
||||
$list = emptyReplace(json_decode($listStr, true), array());
|
||||
}
|
||||
$myInfo = $this->_celMyRankingInfo($list,$user['account_id']);
|
||||
$info = array(
|
||||
'start_time' => strtotime($currentStageMeta['start_time']),
|
||||
'end_time' => strtotime($currentStageMeta['end_time']),
|
||||
'ranking' => $myInfo['ranking'],
|
||||
'score' => $myInfo['score'],
|
||||
);
|
||||
}
|
||||
$this->_rspData(array(
|
||||
'rank_list' => $list,
|
||||
'info' => $info,
|
||||
));
|
||||
}
|
||||
|
||||
public function getCircuitPhaseRanking(){
|
||||
$currentCircuitMeta = mt\CircuitTime::getCurrentCircuit();
|
||||
if (!$currentCircuitMeta){
|
||||
|
Loading…
x
Reference in New Issue
Block a user