From 21d708581720ed8916886b39f3b428cdf0fbc79d Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Thu, 9 May 2024 11:44:41 +0800 Subject: [PATCH] 1 --- .../gamedb2006_migrate_240423_01.sql | 0 sql/gamedb.sql | 18 +++++ sql/gamedb2006_migrate_240508_01.sql | 16 ++++ webapp/bootstrap/constant.php | 1 + webapp/controller/BaseController.class.php | 30 +++++++ .../controller/OutAppNftController.class.php | 79 +++++++++++++++++++ webapp/controller/UserController.class.php | 24 ++++++ webapp/services/RoomBattleDataService.php | 19 +++++ 8 files changed, 187 insertions(+) rename sql/{ => archived}/gamedb2006_migrate_240423_01.sql (100%) create mode 100644 sql/gamedb2006_migrate_240508_01.sql diff --git a/sql/gamedb2006_migrate_240423_01.sql b/sql/archived/gamedb2006_migrate_240423_01.sql similarity index 100% rename from sql/gamedb2006_migrate_240423_01.sql rename to sql/archived/gamedb2006_migrate_240423_01.sql diff --git a/sql/gamedb.sql b/sql/gamedb.sql index cd51c00a..10310756 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1729,3 +1729,21 @@ CREATE TABLE `t_global_data` ( PRIMARY KEY (`idx`), UNIQUE KEY `name` (`name`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + + +-- +-- Table structure for table `t_sub_user_bind` +-- + +DROP TABLE IF EXISTS `t_sub_user_bind`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_sub_user_bind` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `org_account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '初始账号id', + `cur_account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '最新账号id', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `org_account_id` (`org_account_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; \ No newline at end of file diff --git a/sql/gamedb2006_migrate_240508_01.sql b/sql/gamedb2006_migrate_240508_01.sql new file mode 100644 index 00000000..8b7362d7 --- /dev/null +++ b/sql/gamedb2006_migrate_240508_01.sql @@ -0,0 +1,16 @@ +begin; + +CREATE TABLE `t_sub_user_bind` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `org_account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '初始账号id', + `cur_account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '最新账号id', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `org_account_id` (`org_account_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + + +insert into version (version) values(2024050801); + +commit; diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index e2a3d17e..8df938a5 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -69,6 +69,7 @@ define('TN_DAILY_BUY_LEVEL_STATE', 9018); define('TN_DAILY_RESET_HERO_LEVEL_STATE', 9019); define('TN_DAILY_REFRESH_MISSION_TIMES', 9020); define('TN_DAILY_GOLD_MODE_BATTLE_TIMES', 9021); +define('TN_DAILY_GATHER_GOLD', 9022); define('TN_WEEKLY_BEGIN', 10001); define('TN_WEEKLY_ACTIVE', 10002); diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index 3bcb445e..c8ff7e4b 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -247,4 +247,34 @@ class BaseController { return $ret; } + public function _getGameId() { + return 2006; + } + + public function _isSubAccountId($accountId) { + $str_list = explode('_', $accountId); + if (count($str_list) < 4) { + return false; + } + $channel = $str_list[0]; + $gameId = $str_list[1]; + if ($channel != BC_CHANNEL) { + return false; + } + if ($gameId != $this->_getGameId()) { + return false; + } + return $str_list[2][0] == 's'; + } + + public function _getShortAccountId($accountId) { + if (!$this->_isSubAccountId($accountId)) { + return $accountId; + } + // + $str_list = explode('_', $accountId); + unset($str_list[2]); + return implode("_",$str_list); + } + } diff --git a/webapp/controller/OutAppNftController.class.php b/webapp/controller/OutAppNftController.class.php index b1fbbc24..aee4720a 100644 --- a/webapp/controller/OutAppNftController.class.php +++ b/webapp/controller/OutAppNftController.class.php @@ -1,8 +1,10 @@ _getGameId().'_'.$channel.'_'.$openId; + $userDb = User::find($accountId); + if (!$userDb){ + $this->_rspErr(1, 'user not found'); + return; + } + + $info = array( + 'loginVal' => 0, + 'battleTimes' => 0, + 'winTimes' => 0, + 'kills' => 0, + 'getGoldVal' => 0, + ); + $accountBindDb = SqlHelper::ormSelectOne( + myself()->_getMysql($openId), + 't_sub_user_bind', + array( + 'org_account_id' => $accountId, + ) + ); + $accountId = $accountBindDb ? $accountBindDb['cur_account_id'] : $accountId ; + $loginDyn = SqlHelper::ormSelectOne( + myself()->_getMysql($openId), + 't_dyndata', + array( + 'account_id' => $accountId, + 'x' => TN_DAILY_LOGINS, + 'y' => 0, + ) + ); + if ($loginDyn){ + $info['loginVal'] = $loginDyn['val']; + if (myself()->_getDaySeconds($loginDyn['modifytime']) < myself()->_getNowDaySeconds()) { + $info['loginVal'] = 0; + } + } + + $battleDb = SqlHelper::ormSelectOne( + myself()->_getMysql($openId), + 't_battle', + array( + 'account_id' => $accountId, + ) + ); + if ($battleDb){ + $hisBattleData = json_decode($battleDb['battle_data'], true); + $todayBattleData = getXVal($hisBattleData, 'today_data', array()); + if (myself()->_getDaySeconds(getXVal($todayBattleData, 'modifytime', 0)) == myself()->_getNowDaySeconds()) { + $info['battleTimes'] = getXVal($todayBattleData, "total_battle_times", 0); + $info['winTimes'] = getXVal($todayBattleData, "total_win_times", 0); + $info['kills'] = getXVal($todayBattleData, "total_kills_times", 0); + } + } + $getGoldDyn = SqlHelper::ormSelectOne( + myself()->_getMysql($openId), + 't_dyndata', + array( + 'account_id' => $accountId, + 'x' => TN_DAILY_GATHER_GOLD, + 'y' => 0, + ) + ); + if ($getGoldDyn){ + $info['getGoldVal'] = $getGoldDyn['val']; + if (myself()->_getDaySeconds($getGoldDyn['modifytime']) < myself()->_getNowDaySeconds()) { + $info['getGoldVal'] = 0; + } + } + $this->_rspData(array( + 'info' => $info, + )); + } } diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index fafabde7..a727e37d 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -72,6 +72,7 @@ class UserController extends BaseAuthedController { $userInfo['address'] = $this->_getOpenId(); } $this->_updateLastSeason($userInfo); + $this->_updateSubUserAccount(); $this->_sign(); $event = array( 'ID' => 'luck', @@ -1168,6 +1169,29 @@ class UserController extends BaseAuthedController { } } + private function _updateSubUserAccount() { + if ($this->_getChannel() == BC_CHANNEL) { + $shortAccountId = $this->_getShortAccountId(myself()->_getAccountId()); + SqlHelper::upsert + ($this->_getSelfMysql(), + 't_sub_user_bind', + array( + 'org_account_id' => $shortAccountId + ), + array( + 'cur_account_id' => myself()->_getAccountId(), + 'modifytime' => myself()->_getNowTime(), + ), + array( + 'org_account_id' => myself()->_getAccountId(), + 'cur_account_id' => myself()->_getAccountId(), + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + } + } + private function _sign(){ //用户是否有签到记录 if (SignLog::isSignRecord()){ diff --git a/webapp/services/RoomBattleDataService.php b/webapp/services/RoomBattleDataService.php index 011f106f..21c93c96 100644 --- a/webapp/services/RoomBattleDataService.php +++ b/webapp/services/RoomBattleDataService.php @@ -221,6 +221,7 @@ class RoomBattleDataService extends BaseService { "item_id" => V_ITEM_GOLD, "item_num" => floor($gold), )); + myself()->_incDailyV(TN_DAILY_GATHER_GOLD,0,floor($gold)); } } @@ -240,6 +241,10 @@ class RoomBattleDataService extends BaseService { public function _calBattleScore($battleInfo){ $paramMeta = mt\Parameter::getVal('performance_score_range',0); + $paramMetaMoba = mt\Parameter::getVal('performance_score_weight_4V4',0); + $paramMetaPvp = mt\Parameter::getVal('performance_score_weight_BR',0); + $weightMoba = explode("|",$paramMetaMoba); + $weightPvp = explode("|",$paramMetaPvp); $scoreParam = explode("|",$paramMeta); if (count($scoreParam) < 2){ error_log('Parameter table error'); @@ -284,10 +289,24 @@ class RoomBattleDataService extends BaseService { } switch ($room_mode){ case self::ROOM_MODE_PVP: { + if (count($weightPvp) == 5){ + $killSco *= $weightPvp[0]; + $assistSco *= $weightPvp[1]; + $damageSco *= $weightPvp[2]; + $recoverSco *= $weightPvp[3]; + $aliveSco *= $weightPvp[4]; + } $battleScore = round($killSco + $assistSco + $damageSco + $recoverSco + $aliveSco , 2); } break; case self::ROOM_MODE_MOBA :{ + if (count($weightMoba) == 5){ + $killSco *= $weightMoba[0]; + $assistSco *= $weightMoba[1]; + $damageSco *= $weightMoba[2]; + $recoverSco *= $weightMoba[3]; + $levelSco *= $weightMoba[4]; + } $battleScore = round($killSco + $assistSco + $damageSco + $recoverSco + $levelSco , 2); } break;