89 lines
2.5 KiB
PHP
89 lines
2.5 KiB
PHP
<?php
|
|
|
|
require_once('mt/Parameter.php');
|
|
require_once('mt/Rank.php');
|
|
require_once('mt/Season.php');
|
|
|
|
require_once('models/Season.php');
|
|
|
|
require_once('services/PropertyChgService.php');
|
|
require_once('services/SeasonService.php');
|
|
|
|
use phpcommon\SqlHelper;
|
|
use models\User;
|
|
use models\Season;
|
|
|
|
class SeasonController extends BaseAuthedController {
|
|
|
|
private $propertyChgService = null;
|
|
private $userInfo = null;
|
|
private $seasonService = null;
|
|
private $currSeasonMeta = null;
|
|
private $seasonDb = null;
|
|
|
|
public function _handlePre()
|
|
{
|
|
parent::_handlePre();
|
|
$this->currSeasonMeta = mt\Season::getCurrentSeason();
|
|
if (!$this->currSeasonMeta) {
|
|
$this->_rspErr(10, '服务器内部错误');
|
|
die();
|
|
}
|
|
$this->propertyChgService = new services\PropertyChgService();
|
|
$this->userInfo = $this->_safeGetOrmUserInfo();
|
|
$this->seasonService = new services\SeasonService();
|
|
if (!$this->seasonService->checkSeason($this->userInfo)) {
|
|
$this->userInfo = $this->_safeGetOrmUserInfo();
|
|
$this->propertyChgService->addUserChg();
|
|
}
|
|
$this->seasonDb = Season::find($this->currSeasonMeta['id']);
|
|
if (!$this->seasonDb) {
|
|
Season::add($this->currSeasonMeta['id']);
|
|
$this->seasonDb = Season::find($this->currSeasonMeta['id']);
|
|
}
|
|
if (!$this->seasonDb) {
|
|
$this->_rspErr(10, '服务器内部错误');
|
|
die();
|
|
}
|
|
}
|
|
|
|
public function info()
|
|
{
|
|
$rankMeta = mt\Rank::get($this->userInfo['rank']);
|
|
$this->_rspData(array(
|
|
array(
|
|
'info' => array(
|
|
'season_id' => $this->currSeasonMeta['id'],
|
|
'rank' => $this->userInfo['rank'],
|
|
'max_score' => $rankMeta ? $rankMeta['max_score'] : 0,
|
|
'noshow_score_bar' => $rankMeta ? $rankMeta['noshow_score_bar'] : 1,
|
|
'mission' => $this->getMissionInfo()
|
|
)
|
|
),
|
|
'property_chg' => $this->propertyChgService->toDto()
|
|
));
|
|
}
|
|
|
|
public function getMissionReward()
|
|
{
|
|
$mission = $this->getMissionInfo();
|
|
if ($mission['state'] != 1) {
|
|
$this->_rspErr(1, '不可领取');
|
|
return;
|
|
}
|
|
$this->_rspOk();
|
|
}
|
|
|
|
private function getMissionInfo()
|
|
{
|
|
$info = array(
|
|
'state' => 0,
|
|
'current' => 0,
|
|
'target' => 0,
|
|
'target_rank' => 0
|
|
);
|
|
return $info;
|
|
}
|
|
|
|
}
|