181 lines
7.2 KiB
PHP
181 lines
7.2 KiB
PHP
<?php
|
|
require_once('services/AwardService.php');
|
|
require_once('services/PropertyChgService.php');
|
|
|
|
require_once('mt/StarLevel.php');
|
|
require_once('mt/BattlePass.php');
|
|
require_once('mt/Rank.php');
|
|
require_once('mt/RankSeason.php');
|
|
require_once('mt/HashRateCommon.php');
|
|
|
|
require_once('models/RealtimeData.php');
|
|
require_once('models/Season.php');
|
|
require_once('models/RankingSetRecord.php');
|
|
require_once('models/ComputingPower.php');
|
|
require_once('models/RewardsCec.php');
|
|
use phpcommon\SqlHelper;
|
|
|
|
use models\RealtimeData;
|
|
use models\Season;
|
|
use models\RankingSetRecord;
|
|
use models\ComputingPower;
|
|
use models\RewardsCec;
|
|
|
|
class DailyRequestController extends BaseAuthedController {
|
|
private $awardService = null;
|
|
private $propertyChgService = null;
|
|
|
|
public function _handlePre()
|
|
{
|
|
$this->propertyChgService = new services\PropertyChgService();
|
|
$this->awardService = new services\AwardService();
|
|
}
|
|
|
|
/**
|
|
* 星星之路的赛季结算
|
|
*/
|
|
public function missionStarSeasonSettlement(){
|
|
$season = RealtimeData::getMissionSeason();
|
|
$currMissionSeasonMeta = \mt\StarLevel::getCurrentSeason();
|
|
if ($currMissionSeasonMeta && $currMissionSeasonMeta['id'] > $season){
|
|
$max_star_num = mt\Parameter::getVal('starroad_restart_point',1000);
|
|
$rows = myself()->_getMysql('')->execQuery(
|
|
'SELECT account_id,star_num FROM t_user WHERE star_num>:star_num',
|
|
array(
|
|
"star_num"=>$max_star_num
|
|
)
|
|
);
|
|
if (count($rows) > 0){
|
|
foreach ($rows as $row){
|
|
myself()->_getMysql('')->execQuery(
|
|
'UPDATE t_user SET star_num=:star_num WHERE account_id=:account_id',
|
|
array(
|
|
"star_num"=>$max_star_num,
|
|
"account_id"=>$row['account_id'],
|
|
)
|
|
);
|
|
}
|
|
}
|
|
error_log("DailyRequestController : Mission Star Season ".$season." Settlement Success !" . " Request Time : ". date('Y-M-D h:i:s',time()));
|
|
RealtimeData::setMissionSeason($currMissionSeasonMeta['id']);
|
|
$this->_rspData(array('message'=>'星星之路结算成功'));
|
|
return;
|
|
}
|
|
$this->_rspOk();
|
|
}
|
|
|
|
/**
|
|
* 通行证的赛季结算
|
|
*/
|
|
public function battlePassSeasonSettlement(){
|
|
$season = RealtimeData::getPassSeason();
|
|
$currSeasonMeta = \mt\BattlePass::getCurrentSeason();
|
|
if ($currSeasonMeta && $currSeasonMeta['id'] > $season) {
|
|
myself()->_getMysql('')->execQuery(
|
|
'UPDATE t_user SET activated=:activated,level=:level,exp=:exp',
|
|
array(
|
|
"activated" => 0,
|
|
"level" => 1,
|
|
"exp" => 0,
|
|
)
|
|
);
|
|
error_log("DailyRequestController : Battle Pass Season ".$season." Settlement Success !" . " Request Time : ". date('Y-M-D h:i:s',time()));
|
|
RealtimeData::setPassSeason($currSeasonMeta['id']);
|
|
$this->_rspData(array('message'=>'通行证结算成功'));
|
|
return;
|
|
}
|
|
$this->_rspOk();
|
|
}
|
|
|
|
/**
|
|
* 排位战斗的赛季结算
|
|
*/
|
|
public function battleRankingSeasonSettlement(){
|
|
$currSeasonMeta = mt\RankSeason::getCurrentSeason();
|
|
$lastSeasonMeta = mt\RankSeason::getLastSeason();
|
|
$season = RealtimeData::getRankSeason();
|
|
|
|
// if ($currSeasonMeta && $currSeasonMeta['id'] > $season) {
|
|
if (!$currSeasonMeta && $lastSeasonMeta && $lastSeasonMeta['id'] > $season) {
|
|
if ($lastSeasonMeta > 1){
|
|
$SeasonMeta = mt\RankSeason::get($season-1);
|
|
$time = strtotime($SeasonMeta['start_time']);
|
|
$rows = myself()->_getMysql('')->execQuery(
|
|
'SELECT account_id,`rank`,score FROM t_user ' .
|
|
'WHERE score_modifytime > :score_modifytime AND score_modifytime <> createtime',
|
|
array(
|
|
'score_modifytime' => $time
|
|
)
|
|
);
|
|
}else{
|
|
$rows = myself()->_getMysql('')->execQuery(
|
|
'SELECT account_id,`rank`,score FROM t_user ' .
|
|
'WHERE score_modifytime <> createtime'
|
|
);
|
|
}
|
|
|
|
if (count($rows) < 1){
|
|
error_log("resetRankGainAward : No user participates in the ranking");
|
|
die;
|
|
}
|
|
foreach ($rows as $row){
|
|
$currRankMeta = mt\Rank::getRankById($row['rank']);
|
|
if (! $currRankMeta){
|
|
error_log("resetRankGainAward : rankRank@rankRank.php field rank error" . json_encode($row));
|
|
continue;
|
|
}
|
|
$dropRankMeta = mt\Rank::getRankById($currRankMeta['next_season']);
|
|
if (! $dropRankMeta){
|
|
error_log("resetRankGainAward : rankRank@rankRank.php field next_season error" . json_encode($row));
|
|
continue;
|
|
}
|
|
$award = Season::seasonReward($currRankMeta);
|
|
myself()->switchAccount($row['account_id']);
|
|
myself()->_addItems($award, null, $this->propertyChgService);
|
|
$data = array(
|
|
'state' => 1,
|
|
'last_rank' => $row['rank'],
|
|
'current_rank' => $dropRankMeta['id'],
|
|
'last_score' => $row['score'],
|
|
'current_score' => $dropRankMeta['rank_score'],
|
|
'awards' => json_encode($award),
|
|
);
|
|
RankingSetRecord::upsert($data);
|
|
myself()->_updateUserInfo(array(
|
|
'last_season_id' => $lastSeasonMeta['id'],
|
|
'rank' => $dropRankMeta['id'],
|
|
'score' => $dropRankMeta['rank_score'],
|
|
));
|
|
}
|
|
error_log("DailyRequestController : Battle Ranking Season ".$season." Settlement Success !" . " Request Time : ". date('Y-M-D h:i:s',time()));
|
|
RealtimeData::setRankSeason($lastSeasonMeta['id']);
|
|
$this->_rspData(array('message'=>'排位结算成功'));
|
|
return;
|
|
}
|
|
$this->_rspOk();
|
|
}
|
|
|
|
/**
|
|
* 算力周期cec计算
|
|
*/
|
|
public function computingPowerRewards(){
|
|
$currentMeta = \mt\HashRateCommon::getLatestPeriod();
|
|
if (\mt\HashRateCommon::checkAwaitTime()){
|
|
$temp = ComputingPower::getAccountGroup($currentMeta['id']);
|
|
if (! $temp){
|
|
error_log("computingPowerRewards : No one involved");
|
|
die;
|
|
}
|
|
foreach ($temp as $row){
|
|
if ( ! RewardsCec::findByAccount($row['account_id'],$currentMeta['id'])){
|
|
RewardsCec::celCecReward($row['account_id'],$currentMeta);
|
|
error_log("computingPowerRewards : ACCOUNT_ID_{$row['account_id']} CEC Reward record completion");
|
|
}
|
|
}
|
|
$this->_rspData(array('message'=>'算力结算成功'));
|
|
return;
|
|
}
|
|
$this->_rspOk();
|
|
}
|
|
|
|
} |