1
This commit is contained in:
parent
2f1028cabe
commit
ae5310f154
@ -84,6 +84,7 @@ class rankingInfo(object):
|
|||||||
['skin_id', 0, '皮肤ItemId'],
|
['skin_id', 0, '皮肤ItemId'],
|
||||||
['ranking', 0, '排名'],
|
['ranking', 0, '排名'],
|
||||||
['score', 0, '积分'],
|
['score', 0, '积分'],
|
||||||
|
['score_boost', 0, '加成的积分'],
|
||||||
['cec', 0, 'cec(个人榜信息才有)'],
|
['cec', 0, 'cec(个人榜信息才有)'],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -479,4 +479,17 @@ class BaseController {
|
|||||||
}
|
}
|
||||||
return $finalItems;
|
return $finalItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function arraySort($arr, $keys, $type = 'asc') {
|
||||||
|
$keys_value = $new_array = array();
|
||||||
|
foreach ($arr as $k => $v){
|
||||||
|
$keys_value[$k] = $v[$keys];
|
||||||
|
}
|
||||||
|
$type == 'asc' ? asort($keys_value) : arsort($keys_value);
|
||||||
|
reset($keys_value);
|
||||||
|
foreach ($keys_value as $k => $v) {
|
||||||
|
$new_array[$k] = $arr[$k];
|
||||||
|
}
|
||||||
|
return $new_array;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ require_once('models/User.php');
|
|||||||
require_once('models/Hero.php');
|
require_once('models/Hero.php');
|
||||||
require_once('models/HeroSkin.php');
|
require_once('models/HeroSkin.php');
|
||||||
require_once('models/CircuitTask.php');
|
require_once('models/CircuitTask.php');
|
||||||
|
require_once('models/UserInvitationCode.php');
|
||||||
|
|
||||||
|
|
||||||
use models\Circuit;
|
use models\Circuit;
|
||||||
@ -16,6 +17,7 @@ use models\User;
|
|||||||
use models\Hero;
|
use models\Hero;
|
||||||
use models\HeroSkin;
|
use models\HeroSkin;
|
||||||
use models\CircuitTask;
|
use models\CircuitTask;
|
||||||
|
use models\UserInvitationCode;
|
||||||
use phpcommon\SqlHelper;
|
use phpcommon\SqlHelper;
|
||||||
class CircuitController extends BaseAuthedController {
|
class CircuitController extends BaseAuthedController {
|
||||||
private $redis_key_circuit_ranking = 'circuit_ranking';
|
private $redis_key_circuit_ranking = 'circuit_ranking';
|
||||||
@ -81,8 +83,9 @@ class CircuitController extends BaseAuthedController {
|
|||||||
|
|
||||||
$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::getRankingList($currentCircuitMeta['circuit_season']);
|
$rows = Circuit::getCircuitList($currentCircuitMeta['circuit_season']);
|
||||||
$list = $this->_extractRankingInfo($rows);
|
$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->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);
|
$redis->pexpire(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_ranking , 10*60*1000);
|
||||||
}else{
|
}else{
|
||||||
@ -107,8 +110,9 @@ class CircuitController extends BaseAuthedController {
|
|||||||
}
|
}
|
||||||
$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::getPhaseRankingList($currentStageMeta['circuit_season'],$currentStageMeta['circuit_phase']);
|
$rows = Circuit::getCircuitPhaseList($currentStageMeta['circuit_season'],$currentStageMeta['circuit_phase']);
|
||||||
$list = $this->_extractRankingInfo($rows);
|
$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->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);
|
$redis->pexpire(CIRCUIT_RANKING_KEY.$this->redis_key_circuit_phase_ranking , 10*60*1000);
|
||||||
}else{
|
}else{
|
||||||
@ -143,6 +147,7 @@ class CircuitController extends BaseAuthedController {
|
|||||||
'ranking' => $ranking,
|
'ranking' => $ranking,
|
||||||
'weight' => $rewardWeight,
|
'weight' => $rewardWeight,
|
||||||
'score' => $row['cumulative_score'],
|
'score' => $row['cumulative_score'],
|
||||||
|
'score_boost' => $row['score_boost'],
|
||||||
);
|
);
|
||||||
array_push($rankingList,$info);
|
array_push($rankingList,$info);
|
||||||
}
|
}
|
||||||
@ -152,14 +157,20 @@ class CircuitController extends BaseAuthedController {
|
|||||||
|
|
||||||
private function _celMyRankingInfo($list){
|
private function _celMyRankingInfo($list){
|
||||||
$currentCircuitMeta = mt\CircuitTime::getCurrentCircuit();
|
$currentCircuitMeta = mt\CircuitTime::getCurrentCircuit();
|
||||||
|
$score = Circuit::getMyScore($currentCircuitMeta['circuit_season']);
|
||||||
$userDb = User::find(myself()->_getAccountId());
|
$userDb = User::find(myself()->_getAccountId());
|
||||||
|
$codeDb = UserInvitationCode::findMyCode();
|
||||||
|
$count = UserInvitationCode::getMyCodeBindCount($codeDb['invitation_code']);
|
||||||
|
$boost = min($count * 3 / 100,60 / 100);
|
||||||
|
$boostScore = $score * $boost;
|
||||||
$myRankedInfo = array(
|
$myRankedInfo = array(
|
||||||
'ranking' => 0,
|
'ranking' => 0,
|
||||||
'account_id' => $userDb['account_id'],
|
'account_id' => $userDb['account_id'],
|
||||||
'name' => $userDb['name'],
|
'name' => $userDb['name'],
|
||||||
'head_id' => $userDb['head_id'],
|
'head_id' => $userDb['head_id'],
|
||||||
'head_frame' => $userDb['head_frame'],
|
'head_frame' => $userDb['head_frame'],
|
||||||
'score' => Circuit::getMyScore($currentCircuitMeta['circuit_season']),
|
'score' => $score + $boostScore,
|
||||||
|
'score_boost' => $boostScore,
|
||||||
'cec' => 0,
|
'cec' => 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -57,12 +57,13 @@ class OutAppCircuitController extends BaseController {
|
|||||||
$prevStageMeta &&
|
$prevStageMeta &&
|
||||||
$prevStageMeta['is_reward'] > 0 &&
|
$prevStageMeta['is_reward'] > 0 &&
|
||||||
!CircuitReward::_verifySettlement($prevStageMeta['circuit_season'],$prevStageMeta['circuit_phase'])){
|
!CircuitReward::_verifySettlement($prevStageMeta['circuit_season'],$prevStageMeta['circuit_phase'])){
|
||||||
$rows = Circuit::getRankingList($prevStageMeta['circuit_season']);
|
$rows = Circuit::getCircuitList($prevStageMeta['circuit_season']);
|
||||||
if (count($rows) > 0){
|
$sortRows = myself()->arraySort($rows, 'cumulative_score', 'desc');
|
||||||
|
if (count($sortRows) > 0){
|
||||||
$totalWeight = 0;
|
$totalWeight = 0;
|
||||||
$rate = \mt\Parameter::getVal('circuit_reward_rate','');
|
$rate = \mt\Parameter::getVal('circuit_reward_rate','');
|
||||||
$count = floor(count($rows) * $rate) ;
|
$count = floor(count($sortRows) * $rate) ;
|
||||||
foreach ($rows as $k=>$value){
|
foreach ($sortRows as $k=>$value){
|
||||||
$ranking = $k+1;
|
$ranking = $k+1;
|
||||||
$rewardWeight = \mt\CircuitReward::getRewardWeight($ranking);
|
$rewardWeight = \mt\CircuitReward::getRewardWeight($ranking);
|
||||||
if ($ranking <= $count){
|
if ($ranking <= $count){
|
||||||
@ -70,7 +71,7 @@ class OutAppCircuitController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$cecPool = $prevStageMeta['cec_pool'];
|
$cecPool = $prevStageMeta['cec_pool'];
|
||||||
foreach ($rows as $k=>$value){
|
foreach ($sortRows as $k=>$value){
|
||||||
$cec = 0;
|
$cec = 0;
|
||||||
$ranking = $k+1;
|
$ranking = $k+1;
|
||||||
$rewardWeight = \mt\CircuitReward::getRewardWeight($ranking);
|
$rewardWeight = \mt\CircuitReward::getRewardWeight($ranking);
|
||||||
|
@ -91,6 +91,25 @@ class Circuit extends BaseModel
|
|||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getCircuitList($season){
|
||||||
|
$rows = SqlHelper::ormSelect(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_circuit_battle',
|
||||||
|
array(
|
||||||
|
'season' => $season
|
||||||
|
)
|
||||||
|
);
|
||||||
|
foreach ($rows as &$row){
|
||||||
|
$codeDb = UserInvitationCode::findCodeByAccount($row['account_id']);
|
||||||
|
$count = UserInvitationCode::getMyCodeBindCount($codeDb['invitation_code']);
|
||||||
|
$boost = min($count * 3 / 100,60 / 100);
|
||||||
|
$boostScore = $row['cumulative_score'] * $boost;
|
||||||
|
$row['score_boost'] = $boostScore;
|
||||||
|
$row['cumulative_score'] += $boostScore;
|
||||||
|
}
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getPhaseRankingList($season,$phase){
|
public static function getPhaseRankingList($season,$phase){
|
||||||
$sql = "select * from t_circuit_battle_phase where season=:season and phase=:phase order by cumulative_score desc,modifytime asc";
|
$sql = "select * from t_circuit_battle_phase where season=:season and phase=:phase order by cumulative_score desc,modifytime asc";
|
||||||
$whereKv = array(
|
$whereKv = array(
|
||||||
@ -104,6 +123,26 @@ class Circuit extends BaseModel
|
|||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getCircuitPhaseList($season,$phase){
|
||||||
|
$rows = SqlHelper::ormSelect(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_circuit_battle_phase',
|
||||||
|
array(
|
||||||
|
'season' => $season,
|
||||||
|
'phase' => $phase,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
foreach ($rows as &$row){
|
||||||
|
$codeDb = UserInvitationCode::findCodeByAccount($row['account_id']);
|
||||||
|
$count = UserInvitationCode::getMyCodeBindCount($codeDb['invitation_code']);
|
||||||
|
$boost = min($count * 3 / 100,60 / 100);
|
||||||
|
$boostScore = $row['cumulative_score'] * $boost;
|
||||||
|
$row['score_boost'] = $boostScore;
|
||||||
|
$row['cumulative_score'] += $boostScore;
|
||||||
|
}
|
||||||
|
return $rows;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static function getCurrentMyScore(){
|
public static function getCurrentMyScore(){
|
||||||
$circuitMeta = myself()->_callMtStatic('CircuitTime', 'getCurrentCircuit');
|
$circuitMeta = myself()->_callMtStatic('CircuitTime', 'getCurrentCircuit');
|
||||||
|
@ -18,6 +18,17 @@ class UserInvitationCode extends BaseModel
|
|||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function findCodeByAccount($account){
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_user_invitation_code',
|
||||||
|
array(
|
||||||
|
'account_id' => $account,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
public static function generateCode(){
|
public static function generateCode(){
|
||||||
$user = myself()->_getOrmUserInfo();
|
$user = myself()->_getOrmUserInfo();
|
||||||
SqlHelper::upsert(
|
SqlHelper::upsert(
|
||||||
|
@ -141,8 +141,8 @@ class RoomBattleDataService extends BaseService {
|
|||||||
$circuitScore = $battleScore * $multConstant + $shiftConstant;
|
$circuitScore = $battleScore * $multConstant + $shiftConstant;
|
||||||
$myScore = Circuit::getMyScore($circuitMeta['circuit_season']);
|
$myScore = Circuit::getMyScore($circuitMeta['circuit_season']);
|
||||||
$myPhaseScore = Circuit::getMyPhaseScore($circuitStageMeta['circuit_season'],$circuitStageMeta['circuit_phase']);
|
$myPhaseScore = Circuit::getMyPhaseScore($circuitStageMeta['circuit_season'],$circuitStageMeta['circuit_phase']);
|
||||||
$finalScore = max($minScore, $myScore+$circuitScore);
|
$finalScore = floor(max($minScore, $myScore+$circuitScore)) ;
|
||||||
$finalPhaseScore = max($minScore, $myPhaseScore+$circuitScore);
|
$finalPhaseScore = floor(max($minScore, $myPhaseScore+$circuitScore));
|
||||||
Circuit::updateScore($circuitMeta['circuit_season'],$finalScore);
|
Circuit::updateScore($circuitMeta['circuit_season'],$finalScore);
|
||||||
Circuit::updatePhaseScore($circuitStageMeta['circuit_season'],$circuitStageMeta['circuit_phase'],$finalPhaseScore);
|
Circuit::updatePhaseScore($circuitStageMeta['circuit_season'],$circuitStageMeta['circuit_phase'],$finalPhaseScore);
|
||||||
$member['new_circuit_score'] = $finalScore;
|
$member['new_circuit_score'] = $finalScore;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user