1
This commit is contained in:
parent
886f01720a
commit
94336932c0
@ -58,6 +58,7 @@ class OutAppCircuitController extends BaseController {
|
|||||||
$redis = $this->_getRedis($this->redis_key_circuit_ranking);
|
$redis = $this->_getRedis($this->redis_key_circuit_ranking);
|
||||||
if (! $redis->exists(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_ranking)){
|
if (! $redis->exists(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_ranking)){
|
||||||
$rows = Circuit::getCircuitList($currentCircuitMeta['circuit_season']);
|
$rows = Circuit::getCircuitList($currentCircuitMeta['circuit_season']);
|
||||||
|
error_log(json_encode($rows));
|
||||||
$sortRows = myself()->arraySort($rows, 'cumulative_score', 'desc');
|
$sortRows = myself()->arraySort($rows, 'cumulative_score', 'desc');
|
||||||
$list = $this->_extractRankingInfo($sortRows);
|
$list = $this->_extractRankingInfo($sortRows);
|
||||||
$redis->set(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_ranking , json_encode($list));
|
$redis->set(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_ranking , json_encode($list));
|
||||||
@ -117,6 +118,7 @@ class OutAppCircuitController extends BaseController {
|
|||||||
$redis = $this->_getRedis($this->redis_key_circuit_phase_ranking);
|
$redis = $this->_getRedis($this->redis_key_circuit_phase_ranking);
|
||||||
if (! $redis->exists(CIRCUIT_RANKING_KEY.$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']);
|
$rows = Circuit::getCircuitPhaseList($currentStageMeta['circuit_season'],$currentStageMeta['circuit_phase']);
|
||||||
|
error_log(json_encode($rows));
|
||||||
$sortRows = myself()->arraySort($rows, 'cumulative_score', 'desc');
|
$sortRows = myself()->arraySort($rows, 'cumulative_score', 'desc');
|
||||||
$list = $this->_extractRankingInfo($sortRows);
|
$list = $this->_extractRankingInfo($sortRows);
|
||||||
$redis->set(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_phase_ranking , json_encode($list));
|
$redis->set(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_phase_ranking , json_encode($list));
|
||||||
@ -218,7 +220,12 @@ class OutAppCircuitController extends BaseController {
|
|||||||
$this->_rspErr(1,'未满足结算条件');
|
$this->_rspErr(1,'未满足结算条件');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function _extractRankingInfo($data){
|
private function _extractRankingInfo($data)
|
||||||
|
{
|
||||||
|
return myself()->_callServiceStatic('CircuitRankingService', 'extractRankingInfo');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function _extractRankingInfoOld($data){
|
||||||
$rankingList = array();
|
$rankingList = array();
|
||||||
$ranking = 0;
|
$ranking = 0;
|
||||||
foreach ($data as $k=>$row){
|
foreach ($data as $k=>$row){
|
||||||
|
@ -77,11 +77,6 @@ class CircuitRankingService extends BaseService {
|
|||||||
|
|
||||||
public static function genAndroidData()
|
public static function genAndroidData()
|
||||||
{
|
{
|
||||||
$currentCircuitMeta = mt\CircuitTime::getCurrentCircuit();
|
|
||||||
if (!$currentCircuitMeta){
|
|
||||||
$this->_rspErr(1, 'current stage Have not yet started');
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
$currentStageMeta = mt\CircuitTime::getCurrentStage();
|
$currentStageMeta = mt\CircuitTime::getCurrentStage();
|
||||||
if (empty($currentStageMeta)) {
|
if (empty($currentStageMeta)) {
|
||||||
myself()->_rspErr(1, 'currentStageMeta Is empty');
|
myself()->_rspErr(1, 'currentStageMeta Is empty');
|
||||||
@ -100,16 +95,16 @@ class CircuitRankingService extends BaseService {
|
|||||||
't_circuit_battle_phase',
|
't_circuit_battle_phase',
|
||||||
array(
|
array(
|
||||||
'account_id' => $row['robot_id'],
|
'account_id' => $row['robot_id'],
|
||||||
'season' => $currentCircuitMeta['id'],
|
'season' => $currentStageMeta['circuit_season'],
|
||||||
'phase' => $currentStageMeta['id'],
|
'phase' => $currentStageMeta['circuit_phase'],
|
||||||
),
|
),
|
||||||
array(),
|
array(),
|
||||||
array(
|
array(
|
||||||
'account_id' => $row['robot_id'],
|
'account_id' => $row['robot_id'],
|
||||||
'is_android' => 1,
|
'is_android' => 1,
|
||||||
'cumulative_score' => 10,
|
'cumulative_score' => 10,
|
||||||
'season' => $currentCircuitMeta['id'],
|
'season' => $currentStageMeta['circuit_season'],
|
||||||
'phase' => $currentStageMeta['id'],
|
'phase' => $currentStageMeta['circuit_phase'],
|
||||||
'createtime' => myself()->_getNowTime(),
|
'createtime' => myself()->_getNowTime(),
|
||||||
'modifytime' => myself()->_getNowTime(),
|
'modifytime' => myself()->_getNowTime(),
|
||||||
)
|
)
|
||||||
@ -118,4 +113,42 @@ class CircuitRankingService extends BaseService {
|
|||||||
myself()->_rspOk();
|
myself()->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function extractRankingInfo($data){
|
||||||
|
$rankingList = array();
|
||||||
|
$ranking = 0;
|
||||||
|
foreach ($data as $k=>$row){
|
||||||
|
++$ranking;
|
||||||
|
$userDb = null;
|
||||||
|
$heroDb = null;
|
||||||
|
$heroId = 0;
|
||||||
|
$skinId = 0;
|
||||||
|
if ($data['is_android']) {
|
||||||
|
} else {
|
||||||
|
$userDb = User::find($row['account_id']);
|
||||||
|
$heroDb = Hero::findByAccountId($userDb['account_id'],$userDb['hero_id']);
|
||||||
|
$skinDb = HeroSkin::findByAccountId($heroDb['skin_id'], $userDb['account_id']);
|
||||||
|
$heroId = $heroDb ? $heroDb['hero_id']:0;
|
||||||
|
$skinId = $skinDb ? $skinDb['skin_id']:0;
|
||||||
|
}
|
||||||
|
$rewardWeight = \mt\CircuitReward::getRewardWeight($ranking);
|
||||||
|
if ($userDb){
|
||||||
|
$info = array(
|
||||||
|
'account_id' => $userDb['account_id'],
|
||||||
|
'name' => utf8_encode($userDb['name']),
|
||||||
|
'head_id' => $userDb['head_id'],
|
||||||
|
'head_frame' => $userDb['head_frame'],
|
||||||
|
'hero_id' => $heroId,
|
||||||
|
'skin_id' => $skinId,
|
||||||
|
'ranking' => $ranking,
|
||||||
|
'weight' => $rewardWeight,
|
||||||
|
#'score' => $row['cumulative_score'],
|
||||||
|
'score' => number_format($row['cumulative_score'], 2, '.', ''),
|
||||||
|
'score_boost' => number_format($row['score_boost'], 2, '.', ''),
|
||||||
|
);
|
||||||
|
array_push($rankingList,$info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $rankingList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user