From 0e63848930e1186ca9ca66c4e84af0296b92d46e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 25 Nov 2021 10:22:12 +0800 Subject: [PATCH] 1 --- webapp/controller/PassController.class.php | 70 ++++++++-------------- webapp/mt/Season.php | 26 +++++++- 2 files changed, 51 insertions(+), 45 deletions(-) diff --git a/webapp/controller/PassController.class.php b/webapp/controller/PassController.class.php index 766b455a..7a9b0091 100644 --- a/webapp/controller/PassController.class.php +++ b/webapp/controller/PassController.class.php @@ -11,54 +11,42 @@ require_once('mt/SeasonPoint.php'); class PassController extends BaseAuthedController { - public function getPassInfo() { - $account_id = $_REQUEST['account_id']; - $conn = $this->getMysql($account_id); + $season = mt\Season::getNowSeason(); + $number = mt\Season::getNowSeasonNum(); + if ($number == 0) { + $this->rspErr(ERR_USER_BASE + 2, '赛季未开启'); + return; + } //判断当前赛季 $number = 0; - $open_time = 0; - $end_time = 0; $sea_reward = array(); $sea_reward2 = array(); $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_multiply2 = $this->getExplode($season['season_reward2']); 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_status2 = 0; - if (!$rowpass) { - $ret = $conn->execScript('INSERT INTO passinfo(accountid, passid, active_status, honor_status, create_time, modify_time) ' . - ' VALUES(:accountid, :passid, 0, 0, :create_time, :modify_time) ' . - ' ON DUPLICATE KEY UPDATE accountid=:accountid, passid=:passid, active_status=0, honor_status=0, modify_time=:modify_time;', - array( - ':accountid' => $account_id, - ':passid' => $ii, - ':create_time' => phpcommon\getNowTime(), - ':modify_time' => phpcommon\getNowTime() - )); - if (!$ret) { - die(); - return; - } - $rank_status = 0; - $rank_status2 = 0; - } else { - $rank_status = $rowpass['active_status']; - $rank_status2 = $rowpass['honor_status']; - } - + phpcommon\SqlHelper::upsert + ($this->getSelfMysql(), + 'passinfo', + array( + 'accountid' => $this->getAccountId(), + 'passid' => $ii, + ), + array( + ), + array( + 'accountid' => $this->getAccountId(), + 'passid' => $ii, + 'active_status' => 0, + 'honor_status' => 0, + 'create_time' => $this->getNowTime(), + 'modify_time' => $this->getNowTime() + ) + ); $key = $ii - 1; array_push($sea_reward, array( '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_score = 0; @@ -159,8 +143,8 @@ class PassController extends BaseAuthedController { 'errmsg'=> '', 'pass_status' => $row['pass_status'], 'season' => $number, - 'open_time' => $open_time, - 'end_time' => $end_time, + 'open_time' => strtotime($season['time1']), + 'end_time' => strtotime($season['time2']), 'rank' => $rank, 'rank_score' => $rank_score, 'max_rank_score' => $max_rank_score, @@ -175,7 +159,6 @@ class PassController extends BaseAuthedController { )); } - public function getPassReward() { $account_id = $_REQUEST['account_id']; @@ -598,4 +581,3 @@ class PassController extends BaseAuthedController { return $item_list; } } -?> diff --git a/webapp/mt/Season.php b/webapp/mt/Season.php index 0d0a0818..595836bf 100644 --- a/webapp/mt/Season.php +++ b/webapp/mt/Season.php @@ -70,13 +70,37 @@ class Season { foreach (self::getMetaList() as $meta) { if (phpcommon\getNowTime() >= strtotime($meta['open_time']) && phpcommon\getNowTime() <= strtotime($meta['end_time'])) { - $seasonTime = strtotime($season['end_time']); + $seasonTime = strtotime($meta['end_time']); break; } } 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 $metaList;