From 2c47da7ce5202780235e560e7a16f90cab0de9c7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 3 Dec 2021 14:18:05 +0800 Subject: [PATCH] 1 --- doc/User.py | 17 +++++++++++++ doc/_common.py | 1 + sql/gamedb.sql | 2 ++ webapp/controller/SeasonController.class.php | 26 +++++++++++++++----- webapp/controller/UserController.class.php | 4 +++ webapp/models/Season.php | 2 +- webapp/models/User.php | 2 ++ webapp/mt/SeasonCard.php | 2 +- webapp/services/SeasonService.php | 1 + 9 files changed, 49 insertions(+), 8 deletions(-) diff --git a/doc/User.py b/doc/User.py index c1b17ba..a28f71c 100644 --- a/doc/User.py +++ b/doc/User.py @@ -19,6 +19,23 @@ class User(object): ['info',_common.UserInfo(), '用户信息'] ] }, + { + 'name': 'activate', + 'desc': '激活用户', + 'group': 'User', + 'url': 'webapp/index.php?c=User&a=activate', + 'params': [ + _common.ReqHead(), + ['name', 0, '昵称'], + ['sex', 0, '性别'], + ['head_id', 0, '头像id'], + ['head_frame', 0, '头像框'], + ], + 'response': [ + _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], + ] + }, { 'name': 'update', 'desc': '更新用户信息', diff --git a/doc/_common.py b/doc/_common.py index 1197866..9ea9bf3 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -47,6 +47,7 @@ class UserInfo(object): ['diamond', 0, '钻石'], ['hero_id', 0, '当前使用的英雄ID'], ['first_fight', 0, '是否是第一次战斗'], + ['activate', 0, '是否已激活'], ] class Hero(object): diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 4bc9478..3b2a168 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -42,6 +42,8 @@ CREATE TABLE `t_user` ( `hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '当前上阵英雄id', `first_fight` int(11) NOT NULL DEFAULT '0' COMMENT '是否首战', `last_season_id` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次赛季id', + `activated` int(11) NOT NULL DEFAULT '0' COMMENT '是否已激活', + `activatetime` 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/SeasonController.class.php b/webapp/controller/SeasonController.class.php index f65c4a8..49323a4 100644 --- a/webapp/controller/SeasonController.class.php +++ b/webapp/controller/SeasonController.class.php @@ -4,23 +4,28 @@ 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(); - $currSeasonMeta = mt\Season::getCurrentSeason(); - if (!$currSeasonMeta) { + $this->currSeasonMeta = mt\Season::getCurrentSeason(); + if (!$this->currSeasonMeta) { $this->_rspErr(10, '服务器内部错误'); die(); } @@ -31,22 +36,31 @@ class SeasonController extends BaseAuthedController { $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($userInfo['rank']); + $rankMeta = mt\Rank::get($this->userInfo['rank']); $this->_rspData(array( array( 'info' => array( - 'season_id' => $currSeasonMeta['id'], - 'rank' => $userInfo['rank'], + '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' => $propertyChgService->toDto() + 'property_chg' => $this->propertyChgService->toDto() )); } diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 49170af..6db0495 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -93,6 +93,10 @@ class UserController extends BaseAuthedController { } } + public function active() + { + } + public function update() { $validFields = array( diff --git a/webapp/models/Season.php b/webapp/models/Season.php index df2f370..fcbb49b 100644 --- a/webapp/models/Season.php +++ b/webapp/models/Season.php @@ -43,7 +43,7 @@ class Season extends BaseModel { array( 'account_id' => myself()->_getAccountId(), 'season_id' => $seasonId, - 'card_lv' => $initSeasonCard ? $initSeasonCard['id'] : 1, + 'card_lv' => $initSeasonCard ? $initSeasonCard['lv'] : 1, 'card_exp' => $initSeasonCard ? $initSeasonCard['min_exp'] : 0, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime() diff --git a/webapp/models/User.php b/webapp/models/User.php index 18cc9c5..43562da 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -20,6 +20,7 @@ class User extends BaseModel { 'diamond' => $row['diamond'], 'hero_id' => $row['hero_id'], 'first_fight' => $row['first_fight'], + 'activated' => $row['activated'], ); } @@ -39,6 +40,7 @@ class User extends BaseModel { 'diamond' => $row['diamond'], 'hero_id' => $row['hero_id'], 'first_fight' => $row['first_fight'], + 'activated' => $row['activated'], ); } diff --git a/webapp/mt/SeasonCard.php b/webapp/mt/SeasonCard.php index acd8de8..feb28de 100644 --- a/webapp/mt/SeasonCard.php +++ b/webapp/mt/SeasonCard.php @@ -11,7 +11,7 @@ class SeasonCard { return getXVal(self::getMetaList(), $id); } - public static function getInitCard($id) + public static function getInitCard() { return self::get(1); } diff --git a/webapp/services/SeasonService.php b/webapp/services/SeasonService.php index f302ab5..56b9d5a 100644 --- a/webapp/services/SeasonService.php +++ b/webapp/services/SeasonService.php @@ -6,6 +6,7 @@ require_once('mt/Rank.php'); require_once('mt/Season.php'); require_once('models/User.php'); +use mt; use models\User; class SeasonService extends BaseService {