From d3d9561ca9dc10c72855d9eda751b562a1ae0ce8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 3 Dec 2021 11:21:59 +0800 Subject: [PATCH] 1 --- doc/_common.py | 13 ++++++-- sql/gamedb.sql | 2 ++ webapp/bootstrap/init.php | 10 ++++++ .../controller/SeasonCardController.class.php | 33 +++++++++++++++++++ webapp/models/Season.php | 33 +++++++++++++++++++ webapp/models/SeasonCard.php | 33 +++++++++++++++++++ 6 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 webapp/models/Season.php create mode 100644 webapp/models/SeasonCard.php diff --git a/doc/_common.py b/doc/_common.py index 0b39e97..d42c757 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -182,7 +182,16 @@ class SeassonCardLvUnlockReward(object): self.fields = [ ['card_lv', 0, '手册等级'], ['state', 0, '0:不可领取 1:可领取 2:已领取'], - ['item', AwardItem(), '奖品'], + ['items', [AwardItem()], '奖品'], + ] + +class SeasonCardGiftPackage(object): + + def __init__(self): + self.fields = [ + ['package_id', 0, '礼包id'], + ['state', 0, '0:未购买 1:已购买'], + ['price_info', PriceInfo(), '价格信息'], ] class SeasonCard(object): @@ -192,7 +201,7 @@ class SeasonCard(object): ['season_id', 0, '赛季id(客户端显示为Sxxx)'], ['card_lv', 0, '手册等级'], ['card_exp', 0, '手册经验'], - ['!purchased_gift_packages', [0], '已购买的礼包列表'], + ['!gift_packages', [SeasonCardGiftPackage()], '礼包列表'], ['!unlock_rewards', [SeassonCardLvUnlockReward()], '等级解锁的奖励领取列表'], ] diff --git a/sql/gamedb.sql b/sql/gamedb.sql index fdbe8eb..ff3c11a 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -235,6 +235,8 @@ CREATE TABLE `t_season` ( `win_times` int(11) NOT NULL DEFAULT '0' COMMENT '赛季胜利场次', `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_state2` int(11) NOT NULL DEFAULT '0' COMMENT '豪华礼包购买状态 0:未购 1:已购', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/webapp/bootstrap/init.php b/webapp/bootstrap/init.php index f494820..d1d882d 100644 --- a/webapp/bootstrap/init.php +++ b/webapp/bootstrap/init.php @@ -45,6 +45,16 @@ function myself() return $_myself; } +function array_find($arr, $cb) +{ + foreach ($arr as $val) { + if ($cb($val)) { + return $val; + } + } + return null; +} + require 'config_loader.php'; function new_sendError($errcode, $errmsg_tid, $errmsg) diff --git a/webapp/controller/SeasonCardController.class.php b/webapp/controller/SeasonCardController.class.php index 7c52050..faa11b3 100644 --- a/webapp/controller/SeasonCardController.class.php +++ b/webapp/controller/SeasonCardController.class.php @@ -48,6 +48,8 @@ class SeasonCardController extends BaseAuthedController { 'season_id' => $this->currSeasonMeta['id'], 'card_lv' => $this->seasonDb ? $this->seasonDb['card_lv'] : 1, 'card_exp' => $this->seasonDb ? $this->seasonDb['card_exp'] : 0, + 'gift_packages' => $this->getGiftPackages(), + 'unlock_rewards' => $this->getUnlockRewards() ) ) )); @@ -63,6 +65,37 @@ class SeasonCardController extends BaseAuthedController { public function buyGiftPackage() { + $packageId = getReqVal('package_id', 0); + $giftPackage = array_find($this->getGiftPackages(), function ($val) use($packageId) { + if ($val['package_id'] == $packageId) { + return true; + } + return false; + }); + if (!$giftPackage) { + $this->_rspErr(1, 'pacakge_id参数错误'); + return; + } + if ($giftPackage['state'] == 1) { + $this->_rspErr(2, '不能重复购买'); + return; + } + } + + private function getGiftPackages() + { + $giftPackages = array( + + ); + return $giftPackages; + } + + private function getUnlockRewards() + { + $rewards = array( + + ); + return $rewards; } } diff --git a/webapp/models/Season.php b/webapp/models/Season.php new file mode 100644 index 0000000..739c2fc --- /dev/null +++ b/webapp/models/Season.php @@ -0,0 +1,33 @@ +_getSelfMysql(), + 't_bag', + array( + 'account_id' => myself()->_getAccountId(), + 'item_id' => $itemId, + ) + ); + return $row; + } + + public static function toDto($row) + { + return array( + 'item_id' => $row['item_id'], + 'item_num' => $row['item_num'], + ); + } + +} diff --git a/webapp/models/SeasonCard.php b/webapp/models/SeasonCard.php new file mode 100644 index 0000000..9c1f421 --- /dev/null +++ b/webapp/models/SeasonCard.php @@ -0,0 +1,33 @@ +_getSelfMysql(), + 't_bag', + array( + 'account_id' => myself()->_getAccountId(), + 'item_id' => $itemId, + ) + ); + return $row; + } + + public static function toDto($row) + { + return array( + 'item_id' => $row['item_id'], + 'item_num' => $row['item_num'], + ); + } + +}