diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index 97811605..3015e1dc 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -43,6 +43,11 @@ class BaseController { return $this->nowtime + $this->timeOffset; } + public function _setNowTime($newTime) + { + $this->nowtime = $newTime; + } + public function _getTimeOffset() { return $this->timeOffset; diff --git a/webapp/controller/OutAppCircuitController.class.php b/webapp/controller/OutAppCircuitController.class.php index 1f57ef9d..08e0df84 100644 --- a/webapp/controller/OutAppCircuitController.class.php +++ b/webapp/controller/OutAppCircuitController.class.php @@ -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){