From 4331033a9b3182c902721eb48157b486fd07f7b2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 3 Dec 2021 11:44:59 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 2 + .../controller/SeasonCardController.class.php | 10 ++++ webapp/models/Season.php | 54 ++++++++++++++++--- webapp/mt/SeasonCard.php | 29 ++++++++++ 4 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 webapp/mt/SeasonCard.php diff --git a/sql/gamedb.sql b/sql/gamedb.sql index ff3c11a..4bc9478 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -236,7 +236,9 @@ CREATE TABLE `t_season` ( `total_score` int(11) NOT NULL DEFAULT '0' COMMENT '赛季积分', `max_score` int(11) NOT NULL DEFAULT '0' COMMENT '赛季最高积分', `gift_state1` int(11) NOT NULL DEFAULT '0' COMMENT '普通礼包购买状态 0:未购 1:已购', + `gift_buytime1` int(11) NOT NULL DEFAULT '0' COMMENT '普通礼包购买时间', `gift_state2` int(11) NOT NULL DEFAULT '0' COMMENT '豪华礼包购买状态 0:未购 1:已购', + `gift_buytime2` int(11) NOT NULL DEFAULT '0' COMMENT '豪华礼包购买时间', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/webapp/controller/SeasonCardController.class.php b/webapp/controller/SeasonCardController.class.php index faa11b3..b614dd1 100644 --- a/webapp/controller/SeasonCardController.class.php +++ b/webapp/controller/SeasonCardController.class.php @@ -2,10 +2,13 @@ require_once('models/User.php'); require_once('models/Hero.php'); +require_once('models/Season.php'); +require_once('models/SeasonCard.php'); require_once('mt/Parameter.php'); require_once('mt/Drop.php'); require_once('mt/Season.php'); +require_once('mt/SeasonCard.php'); require_once('services/PropertyChgService.php'); require_once('services/SeasonService.php'); @@ -13,6 +16,8 @@ require_once('services/SeasonService.php'); use phpcommon\SqlHelper; use models\User; use models\Hero; +use models\Season; +use models\SeasonCard; class SeasonCardController extends BaseAuthedController { @@ -38,6 +43,10 @@ class SeasonCardController extends BaseAuthedController { $this->userInfo = $this->_safeGetOrmUserInfo(); $this->propertyChgService->addUserChg(); } + $this->seasonDb = Season::find($this->currSeasonMeta['id']); + if (!$this->seasonDb) { + $this->seasonDb = Season::find($this->currSeasonMeta['id']); + } } public function info() @@ -80,6 +89,7 @@ class SeasonCardController extends BaseAuthedController { $this->_rspErr(2, '不能重复购买'); return; } + Season::updateGiftPackageState($this->currSeasonMeta['id'], $packageId); } private function getGiftPackages() diff --git a/webapp/models/Season.php b/webapp/models/Season.php index 739c2fc..514bc01 100644 --- a/webapp/models/Season.php +++ b/webapp/models/Season.php @@ -2,21 +2,21 @@ namespace models; -require_once('mt/Item.php'); +require_once('mt/SeasonCard.php'); use mt; use phpcommon\SqlHelper; class Season extends BaseModel { - public static function find($itemId) + public static function find($seasonId) { $row = SqlHelper::ormSelectOne( myself()->_getSelfMysql(), - 't_bag', + 't_season', array( 'account_id' => myself()->_getAccountId(), - 'item_id' => $itemId, + 'season_id' => $seasonId, ) ); return $row; @@ -25,9 +25,51 @@ class Season extends BaseModel { public static function toDto($row) { return array( - 'item_id' => $row['item_id'], - 'item_num' => $row['item_num'], ); } + public static function add($seasonId) + { + $initSeasonCard = mt\SeasonCard::getInitCard(); + SqlHelper::upsert( + myself()->_getSelfMysql(), + 't_season', + array( + 'account_id' => myself()->_getAccountId(), + 'season_id' => $seasonId, + ), + array( + ), + array( + 'account_id' => myself()->_getAccountId(), + 'season_id' => $seasonId, + 'card_lv' => $initSeasonCard ? $initSeasonCard['id'] : 1, + 'card_exp' => $initSeasonCard ? $initSeasonCard['min_exp'] : 0, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ) + ); + } + + public static function updateGiftPackageState($seasonId, $packageId) + { + if (in_array($packageId, array( + 1, + 2 + ))) { + SqlHelper::update( + myself()->_getSelfMysql(), + 't_season', + array( + 'account_id' => myself()->_getAccountId(), + 'season_id' => $seasonId, + ), + array( + "gift_state${packageId}" => 1, + "gift_buytime${packageId}" => myself()->_getNowTime() + ) + ); + } + } + } diff --git a/webapp/mt/SeasonCard.php b/webapp/mt/SeasonCard.php new file mode 100644 index 0000000..66b92d6 --- /dev/null +++ b/webapp/mt/SeasonCard.php @@ -0,0 +1,29 @@ +