diff --git a/sql/gamedb.sql b/sql/gamedb.sql index c5b5d90..bf5cd48 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -48,6 +48,8 @@ CREATE TABLE `t_user` ( `head_list` mediumblob COMMENT '拥有的头像列表', `head_frame_list` mediumblob COMMENT '拥有的头像框列表', `consume_gold` bigint NOT NULL DEFAULT '0' COMMENT '消费金币数', + `score_modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '积分修改时间', + `best_rank_modifytime` int(11) NOT NULL DEFAULT '0' COMMENT 'bestrank修改时间', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), @@ -253,6 +255,7 @@ CREATE TABLE `t_battle_record` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', `request` mediumblob COMMENT 'request', + `kills_modifytime` 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`), @@ -275,11 +278,15 @@ CREATE TABLE `t_season` ( `card_exp` int(11) NOT NULL DEFAULT '0' COMMENT '赛季手册经验', `rank` int(11) NOT NULL DEFAULT '0' COMMENT '段位', `score` int(11) NOT NULL DEFAULT '0' COMMENT '积分', + `history_best_rank` 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 '豪华礼包购买时间', `battle_data` mediumblob COMMENT 'battle_data', + `kills_modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '击杀修改时间', + `score_modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '积分修改时间', + `best_rank_modifytime` int(11) NOT NULL DEFAULT '0' COMMENT 'bestrank修改时间', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 817c5d4..78fda8f 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -149,6 +149,8 @@ class UserController extends BaseAuthedController { 'last_season_id' => $currSeasonMeta ? $currSeasonMeta['id'] : 0, 'head_list' => json_encode($headList), 'head_frame_list' => json_encode($headFrameList), + 'score_createtime' => $this->_getNowTime(), + 'best_rank_createtime' => $this->_getNowTime(), 'createtime' => $this->_getNowTime(), 'modifytime' => $this->_getNowTime(), ) diff --git a/webapp/models/Battle.php b/webapp/models/Battle.php index a310ffa..b015b1c 100644 --- a/webapp/models/Battle.php +++ b/webapp/models/Battle.php @@ -34,10 +34,23 @@ class Battle extends BaseModel { array( 'account_id' => myself()->_getAccountId(), 'battle_data' => $battleData, + 'kills_modifytime' => myself()->_getNowTime(), 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime() ) ); } + public static function update($fieldsKv) + { + SqlHelper::upsert + (myself()->_getSelfMysql(), + 't_battle', + array( + 'account_id' => myself()->_getAccountId(), + ), + $fieldsKv + ); + } + } diff --git a/webapp/models/Season.php b/webapp/models/Season.php index a080aa2..d549f46 100644 --- a/webapp/models/Season.php +++ b/webapp/models/Season.php @@ -45,6 +45,9 @@ class Season extends BaseModel { 'season_id' => $seasonId, 'card_lv' => $initSeasonCard ? $initSeasonCard['lv'] : 1, 'card_exp' => $initSeasonCard ? $initSeasonCard['min_exp'] : 0, + 'kills_modifytime' => myself()->_getNowTime(), + 'score_modifytime' => myself()->_getNowTime(), + 'best_rank_modifytime' => myself()->_getNowTime(), 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime() ) diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index a2dcbb8..6168a72 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -80,7 +80,17 @@ class BattleDataService extends BaseService { 'modifytime' => myself()->_getNowTime() ); } + $oldSeasonDataKills = getXVal($seasonBattleData['season_data'], 'total_kills_times', 0); $this->apply($seasonBattleData['season_data']); + $newSeasonDataKills = getXVal($seasonBattleData['season_data'], 'total_kills_times', 0); + if ($newSeasonDataKills > $oldSeasonDataKills) { + Season::update($this->currSeasonMeta['id'], array( + 'kills_modifytime' => myself()->_getNowTime(), + )); + Battle::update(array( + 'kills_modifytime' => myself()->_getNowTime(), + )); + } $this->apply($seasonBattleData['today_data']); $this->apply($seasonBattleData['this_week_data']); Season::update( @@ -255,11 +265,19 @@ class BattleDataService extends BaseService { myself()->_updateUserInfo(array( 'rank' => $newRank, 'score' => $newScore, - 'history_best_rank' => max($userInfo['rank'], $newRank) + 'history_best_rank' => max($userInfo['rank'], $newRank), + 'score_modifytime' => myself()->_getNowTime(), + 'best_rank_modifytime' => $newRank > $userInfo['rank'] ? + myself()->_getNowTime() : $userInfo['best_rank_modifytime'], )); Season::update($this->currSeasonMeta['id'], array( 'rank' => $newRank, - 'score' => $newScore + 'score' => $newScore, + 'history_best_rank' => max($userInfo['rank'], $newRank), + 'score_modifytime' => myself()->_getNowTime(), + 'score_modifytime' => myself()->_getNowTime(), + 'best_rank_modifytime' => $newRank > $userInfo['rank'] ? + myself()->_getNowTime() : $userInfo['best_rank_modifytime'], )); } }