This commit is contained in:
aozhiwei 2021-11-25 10:22:12 +08:00
parent 7345245249
commit 0e63848930
2 changed files with 51 additions and 45 deletions

View File

@ -11,54 +11,42 @@ require_once('mt/SeasonPoint.php');
class PassController extends BaseAuthedController { class PassController extends BaseAuthedController {
public function getPassInfo() public function getPassInfo()
{ {
$account_id = $_REQUEST['account_id']; $season = mt\Season::getNowSeason();
$conn = $this->getMysql($account_id); $number = mt\Season::getNowSeasonNum();
if ($number == 0) {
$this->rspErr(ERR_USER_BASE + 2, '赛季未开启');
return;
}
//判断当前赛季 //判断当前赛季
$number = 0; $number = 0;
$open_time = 0;
$end_time = 0;
$sea_reward = array(); $sea_reward = array();
$sea_reward2 = array(); $sea_reward2 = array();
$rank_status = 0; $rank_status = 0;
$season = metatable\getNowSeason();
$number = metatable\getNowSeasonNum();
$open_time = strtotime($season['time1']);
$end_time = strtotime($season['time2']);
$item_multiply = $this->getExplode($season['season_reward']); $item_multiply = $this->getExplode($season['season_reward']);
$item_multiply2 = $this->getExplode($season['season_reward2']); $item_multiply2 = $this->getExplode($season['season_reward2']);
for($ii = 1; $ii <= count($item_multiply); $ii++) { for($ii = 1; $ii <= count($item_multiply); $ii++) {
$rowpass = $conn->execQueryOne('SELECT active_status, honor_status ' .
' FROM passinfo WHERE accountid=:accountid AND passid=:passid;',
array(
':accountid' => $account_id,
':passid' => $ii,
));
$rank_status = 0; $rank_status = 0;
$rank_status2 = 0; $rank_status2 = 0;
if (!$rowpass) { phpcommon\SqlHelper::upsert
$ret = $conn->execScript('INSERT INTO passinfo(accountid, passid, active_status, honor_status, create_time, modify_time) ' . ($this->getSelfMysql(),
' VALUES(:accountid, :passid, 0, 0, :create_time, :modify_time) ' . 'passinfo',
' ON DUPLICATE KEY UPDATE accountid=:accountid, passid=:passid, active_status=0, honor_status=0, modify_time=:modify_time;', array(
array( 'accountid' => $this->getAccountId(),
':accountid' => $account_id, 'passid' => $ii,
':passid' => $ii, ),
':create_time' => phpcommon\getNowTime(), array(
':modify_time' => phpcommon\getNowTime() ),
)); array(
if (!$ret) { 'accountid' => $this->getAccountId(),
die(); 'passid' => $ii,
return; 'active_status' => 0,
} 'honor_status' => 0,
$rank_status = 0; 'create_time' => $this->getNowTime(),
$rank_status2 = 0; 'modify_time' => $this->getNowTime()
} else { )
$rank_status = $rowpass['active_status']; );
$rank_status2 = $rowpass['honor_status'];
}
$key = $ii - 1; $key = $ii - 1;
array_push($sea_reward, array( array_push($sea_reward, array(
'item_id' => $item_multiply[$key][0], 'item_id' => $item_multiply[$key][0],
@ -77,10 +65,6 @@ class PassController extends BaseAuthedController {
)); ));
} }
if ($number == 0) {
phpcommon\sendError(ERR_USER_BASE + 2, '赛季未开启');
return;
}
//当前段位及积分 //当前段位及积分
$rank = 0; $rank = 0;
$rank_score = 0; $rank_score = 0;
@ -159,8 +143,8 @@ class PassController extends BaseAuthedController {
'errmsg'=> '', 'errmsg'=> '',
'pass_status' => $row['pass_status'], 'pass_status' => $row['pass_status'],
'season' => $number, 'season' => $number,
'open_time' => $open_time, 'open_time' => strtotime($season['time1']),
'end_time' => $end_time, 'end_time' => strtotime($season['time2']),
'rank' => $rank, 'rank' => $rank,
'rank_score' => $rank_score, 'rank_score' => $rank_score,
'max_rank_score' => $max_rank_score, 'max_rank_score' => $max_rank_score,
@ -175,7 +159,6 @@ class PassController extends BaseAuthedController {
)); ));
} }
public function getPassReward() public function getPassReward()
{ {
$account_id = $_REQUEST['account_id']; $account_id = $_REQUEST['account_id'];
@ -598,4 +581,3 @@ class PassController extends BaseAuthedController {
return $item_list; return $item_list;
} }
} }
?>

View File

@ -70,13 +70,37 @@ class Season {
foreach (self::getMetaList() as $meta) { foreach (self::getMetaList() as $meta) {
if (phpcommon\getNowTime() >= strtotime($meta['open_time']) && if (phpcommon\getNowTime() >= strtotime($meta['open_time']) &&
phpcommon\getNowTime() <= strtotime($meta['end_time'])) { phpcommon\getNowTime() <= strtotime($meta['end_time'])) {
$seasonTime = strtotime($season['end_time']); $seasonTime = strtotime($meta['end_time']);
break; break;
} }
} }
return $seasonTime; return $seasonTime;
} }
public static function getNowSeason()
{
foreach (self::getMetaList() as $meta) {
if (phpcommon\getNowTime() >= strtotime($meta['open_time']) &&
phpcommon\getNowTime() <= strtotime($meta['end_time'])) {
return $meta;
}
}
return null;
}
public static function getNowSeasonNum()
{
$i = 0;
foreach (self::getMetaList() as $meta) {
if (phpcommon\getNowTime() >= strtotime($meta['open_time']) &&
phpcommon\getNowTime() <= strtotime($meta['end_time'])) {
break;
}
++$i;
}
return $i;
}
protected static $itemArr; protected static $itemArr;
protected static $metaList; protected static $metaList;