1
This commit is contained in:
parent
4a3e8d33bc
commit
8266dc8389
@ -2,6 +2,7 @@
|
||||
|
||||
require_once('models/User.php');
|
||||
require_once('models/Season.php');
|
||||
require_once('models/SeasonHistory.php');
|
||||
|
||||
require_once('mt/RankActivity.php');
|
||||
require_once('mt/RankSeason.php');
|
||||
@ -14,8 +15,11 @@ use phpcommon\SqlHelper;
|
||||
|
||||
use models\User;
|
||||
use models\Season;
|
||||
use models\SeasonHistory;
|
||||
|
||||
class RankingController extends BaseAuthedController {
|
||||
private $starshine = 2800;
|
||||
private $TopXunid = 'echelon_TopX_';
|
||||
|
||||
public function getRankStatus(){
|
||||
$userInfo = $this->_getOrmUserInfo();
|
||||
@ -103,6 +107,7 @@ class RankingController extends BaseAuthedController {
|
||||
|
||||
public function getOpenList()
|
||||
{
|
||||
$this->calcCECSeasonAward(2);die;
|
||||
$this->_rspData(array(
|
||||
'list' => mt\RankActivity::getOpenList()
|
||||
));
|
||||
@ -262,4 +267,72 @@ class RankingController extends BaseAuthedController {
|
||||
return $rankingData;
|
||||
}
|
||||
|
||||
private function calcCECSeasonAward($seasonId){
|
||||
$data = SeasonHistory::getDataBySeasonId($seasonId);
|
||||
$rewardParamMeta = \mt\Parameter::getByName('rank_ring_reward');
|
||||
$rewardParamMetaValue = $rewardParamMeta ? $rewardParamMeta['param_value'] : '';
|
||||
$rewardList = explode('|',$rewardParamMetaValue);
|
||||
if (count($data)>0){
|
||||
$rankList = array();
|
||||
$ringList = array();
|
||||
$KingCount = 0;
|
||||
$users = User::orderBy($data);
|
||||
foreach ($users as $k=>$user){
|
||||
$user['rank_sort'] = $k+1;
|
||||
if ($user['score'] >= $this->starshine){
|
||||
$KingCount += 1;
|
||||
$user['echelonTopX'] = \services\FormulaService::echelonTopX($user['rank_sort']);
|
||||
// $r = $this->_getRedis($this->TopXunid.$user['echelonTopX']);
|
||||
// $TopX_List = $this->readRankingList($r,$this->TopXunid.$user['echelonTopX']);
|
||||
// array_push($TopX_List,$user);
|
||||
// $this->saveRankingList($r,$this->TopXunid.$user['echelonTopX'],$TopX_List);
|
||||
if ( ! isset( ${$this->TopXunid.$user['echelonTopX']} )){
|
||||
${$this->TopXunid.$user['echelonTopX']} =array();
|
||||
}
|
||||
array_push(${$this->TopXunid.$user['echelonTopX']},$user);
|
||||
}
|
||||
switch ($user['rank_sort']){
|
||||
case 1:$user['ring_item_id'] = $rewardList[0];array_push($ringList,$user);break;
|
||||
case 2:$user['ring_item_id'] = $rewardList[1];array_push($ringList,$user);break;
|
||||
case 3:$user['ring_item_id'] = $rewardList[2];array_push($ringList,$user);break;
|
||||
default : $user['ring_item_id'] = 0;
|
||||
}
|
||||
array_push($rankList,$user);
|
||||
}
|
||||
//当月排位赛最大分配金额
|
||||
$maxSum = \services\FormulaService::calcCECMaxSum();
|
||||
//排位赛预计分配额
|
||||
$expected_CEC_Sum = 0;
|
||||
foreach ($rankList as $k=>$value){
|
||||
// $r = $this->_getRedis($this->TopXunid.($value['echelonTopX']+1));
|
||||
// $TopX_List = $this->readRankingList($r,$this->TopXunid.($value['echelonTopX']+1));
|
||||
// $XX = $TopX_List ? $TopX_List[0]["rank_sort"]:10001;
|
||||
$TopX_List = ${$this->TopXunid.($value['echelonTopX']+1)};
|
||||
$XX = $TopX_List ? $TopX_List[0]["rank_sort"]:10001;
|
||||
$rankList[$k]['XX'] = $XX;
|
||||
$rankList[$k]['standardTopX'] = \services\FormulaService::standardTopX($value['rank_sort'],$XX);
|
||||
$expected_CEC_Sum += \services\FormulaService::calcCECTopXSum($value['rank_sort'],$KingCount,$XX);
|
||||
}
|
||||
//排位赛金额%
|
||||
$rankAmountPre = min($maxSum/($expected_CEC_Sum+1),1); //MIN(当月排位赛最大分配额/(排位赛预计分配额+1),1)
|
||||
}
|
||||
print_r($expected_CEC_Sum);
|
||||
}
|
||||
|
||||
private function readRankingList($r,$rankUnid)
|
||||
{
|
||||
$list = $r->get(RANKING_KEY.$rankUnid);
|
||||
if (empty($list)) {
|
||||
return array();
|
||||
}
|
||||
$list = json_decode($list, true);
|
||||
return $list;
|
||||
}
|
||||
|
||||
private function saveRankingList($r,$rankUnid ,$list)
|
||||
{
|
||||
$r->set(RANKING_KEY.$rankUnid , json_encode($list));
|
||||
$r->pexpire(RANKING_KEY.$rankUnid , 6*60*60*1000);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user