1
This commit is contained in:
parent
2203a5e6ef
commit
32c6f0c498
@ -14,7 +14,9 @@ class Rankings {
|
|||||||
console.log('Rankings.start');
|
console.log('Rankings.start');
|
||||||
while (true) {
|
while (true) {
|
||||||
await this.doRanking();
|
await this.doRanking();
|
||||||
const sleepTime = 60*60*2;
|
const nowTime = utils.getUtcTime();
|
||||||
|
const daySeconds = utils.getDaySeconds(nowTime, constant.TIME_ZONE);
|
||||||
|
const sleepTime = daySeconds + 3600 * 24 - nowTime;
|
||||||
console.log('sleepTime:' + sleepTime, new Date(), sleepTime /60);
|
console.log('sleepTime:' + sleepTime, new Date(), sleepTime /60);
|
||||||
await utils.sleep(sleepTime * 1000);
|
await utils.sleep(sleepTime * 1000);
|
||||||
}
|
}
|
||||||
@ -73,8 +75,15 @@ class Rankings {
|
|||||||
sorted,
|
sorted,
|
||||||
(value , index) =>{
|
(value , index) =>{
|
||||||
value.ranking = index+1
|
value.ranking = index+1
|
||||||
Redis.hset(RANKING_KEY + "ranking",value.ranking,value.account_id)
|
let dataJson = {
|
||||||
Redis.hset(RANKING_KEY + "account",value.account_id,value.ranking)
|
"account_id" : value.account_id,
|
||||||
|
"score" : value.score,
|
||||||
|
"ranking" : value.ranking,
|
||||||
|
}
|
||||||
|
// Redis.hset(RANKING_KEY + "ranking",value.ranking,value.account_id)
|
||||||
|
Redis.hset(RANKING_KEY + "ranking",value.ranking,dataJson)
|
||||||
|
// Redis.hset(RANKING_KEY + "account",value.account_id,value.ranking)
|
||||||
|
Redis.hset(RANKING_KEY + "account",value.account_id,dataJson)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,9 @@ class SeasonController extends BaseAuthedController {
|
|||||||
if ($this->redisService->exists(RANKING_KEY.$this->redis_key_account)){
|
if ($this->redisService->exists(RANKING_KEY.$this->redis_key_account)){
|
||||||
$myInfo = $this->userInfo;
|
$myInfo = $this->userInfo;
|
||||||
if ($this->redisService->hexists(RANKING_KEY.$this->redis_key_account,$myInfo['account_id'])){
|
if ($this->redisService->hexists(RANKING_KEY.$this->redis_key_account,$myInfo['account_id'])){
|
||||||
$myInfo['ranking'] = $this->redisService->hget(RANKING_KEY.$this->redis_key_account,$myInfo['account_id']);//$myInfo['account_id']
|
$redisData= json_decode($this->redisService->hget(RANKING_KEY.$this->redis_key_account,$myInfo['account_id']),true);//$myInfo['account_id']
|
||||||
|
$myInfo['ranking'] = intval($redisData['ranking']);
|
||||||
|
$myInfo['score'] = $redisData['score'];
|
||||||
}else{
|
}else{
|
||||||
$myInfo['ranking'] = 10001;
|
$myInfo['ranking'] = 10001;
|
||||||
}
|
}
|
||||||
@ -100,9 +102,10 @@ class SeasonController extends BaseAuthedController {
|
|||||||
if ($this->redisService->exists(RANKING_KEY.$this->redis_key_ranking)){
|
if ($this->redisService->exists(RANKING_KEY.$this->redis_key_ranking)){
|
||||||
for ($i=1;$i<=100;$i++){
|
for ($i=1;$i<=100;$i++){
|
||||||
if ($this->redisService->hexists(RANKING_KEY.$this->redis_key_ranking,$i)){
|
if ($this->redisService->hexists(RANKING_KEY.$this->redis_key_ranking,$i)){
|
||||||
$accountId = $this->redisService->hget(RANKING_KEY.$this->redis_key_ranking,$i);
|
$redisData = json_decode($this->redisService->hget(RANKING_KEY.$this->redis_key_ranking,$i),true);
|
||||||
$userDb = User::find($accountId);
|
$userDb = User::find($redisData['account_id']);
|
||||||
$userDb['ranking'] = $i;
|
$userDb['ranking'] = intval($redisData['ranking']);
|
||||||
|
$userDb['score'] = $redisData['score'];
|
||||||
$userDto = $this->_getRewardByRanking($userDb);
|
$userDto = $this->_getRewardByRanking($userDb);
|
||||||
array_push($rankList,$userDto);
|
array_push($rankList,$userDto);
|
||||||
}
|
}
|
||||||
@ -176,18 +179,18 @@ class SeasonController extends BaseAuthedController {
|
|||||||
if (!$user){
|
if (!$user){
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
$userDto = User::getUserByRankMess($user);
|
// $userDto = User::getUserByRankMess($user);
|
||||||
$userDto['ranking'] = $user['ranking'];
|
$userDto['ranking'] = $user['ranking'];
|
||||||
if ($userDto['score'] >= $this->starshine){
|
if ($user['score'] >= $this->starshine){
|
||||||
if ($userDto['ranking'] <= 10000 ){
|
if ($user['ranking'] <= 10000 ){
|
||||||
$userDto['echelonTopX'] = \services\FormulaService::echelonTopX($user['ranking']);
|
$user['echelonTopX'] = \services\FormulaService::echelonTopX($user['ranking']);
|
||||||
$userDto['point'] = \services\FormulaService::standardTopX($user['ranking'],$userDto['echelonTopX']);
|
$user['point'] = \services\FormulaService::standardTopX($user['ranking'],$user['echelonTopX']);
|
||||||
}else{
|
}else{
|
||||||
$userDto['point'] = 30;
|
$user['point'] = 30;
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$userDto['point'] = 0;
|
$user['point'] = 0;
|
||||||
}
|
}
|
||||||
// //当月排位赛最大分配金额
|
// //当月排位赛最大分配金额
|
||||||
// $maxSum = \services\FormulaService::calcCECMaxSum();
|
// $maxSum = \services\FormulaService::calcCECMaxSum();
|
||||||
@ -211,13 +214,13 @@ class SeasonController extends BaseAuthedController {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'ranking' => $userDto['ranking'],
|
'ranking' => $user['ranking'],
|
||||||
'name' => $userDto['name'],
|
'name' => $user['name'],
|
||||||
'head_id' => $userDto['head_id'],
|
'head_id' => $user['head_id'],
|
||||||
'head_frame' => $userDto['head_frame'],
|
'head_frame' => $user['head_frame'],
|
||||||
'rank' => $userDto['rank'],
|
'rank' => $user['rank'],
|
||||||
'score' => $userDto['score'],
|
'score' => $user['score'],
|
||||||
'point' => round($userDto['point'],0),
|
'point' => round($user['point'],0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user