From ef476eaab2f1629f760c631b5f65d2663f2c3226 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Wed, 3 Jul 2024 19:33:30 +0800 Subject: [PATCH] 1 --- webapp/bootstrap/config_loader.php | 11 +++++++++++ webapp/controller/BaseController.class.php | 17 +++++++++++++++++ webapp/controller/UserController.class.php | 18 +++++++++++++----- webapp/models/Hero.php | 22 ++++++++++------------ 4 files changed, 51 insertions(+), 17 deletions(-) diff --git a/webapp/bootstrap/config_loader.php b/webapp/bootstrap/config_loader.php index 9cf24091..8d29edd2 100644 --- a/webapp/bootstrap/config_loader.php +++ b/webapp/bootstrap/config_loader.php @@ -1,5 +1,6 @@ accountDbConn) { + return $this->accountDbConn; + } + $mysql_conf = getAccountDbMysqlConfig(crc32('')); + $this->accountDbConn = new phpcommon\Mysql(array( + 'host' => $mysql_conf['host'], + 'port' => $mysql_conf['port'], + 'user' => $mysql_conf['user'], + 'passwd' => $mysql_conf['passwd'], + 'dbname' => getXVal($mysql_conf, 'dbname', 'accountdb1') + )); + return $this->accountDbConn; + } + public function _getMarketMysql() { if ($this->marketDbConn) { diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 9823ea25..2a7c3114 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -1129,10 +1129,6 @@ class UserController extends BaseAuthedController { $initRank = \mt\Parameter::getVal($this->init_rank,1); $RankMeta = mt\Rank::getRankById($initRank); $initElo = \mt\Parameter::getVal($this->init_elo,1200); - $is_gain_item = 0; - if (services\NftService::hasAnyNft($this->_getAddress())){ - $is_gain_item = 1; - } $fields = array( 'account_id' => $this->_getAccountId(), @@ -1154,11 +1150,23 @@ class UserController extends BaseAuthedController { 'score' => $RankMeta ? $RankMeta['rank_score'] : 300, 'history_best_score' => $RankMeta ? $RankMeta['rank_score'] : 300, 'elo' => $initElo, - 'is_gain_item' => $is_gain_item, ); if ($this->_getChannel() == BC_CHANNEL) { $fields['address'] = $this->_getOpenId(); } + $row = SqlHelper::ormSelectOne( + myself()->_getAccountMysql(), + 't_immutable_account', + array( + 'account_id' => $this->_getAccountId(), + ) + ); + if ($row && !empty($row['address'])){ + $fields['address'] = $row['address']; + if (services\NftService::hasAnyNft($fields['address'])){ + $fields['is_gain_item'] = 1; + } + } SqlHelper::upsert ($this->_getSelfMysql(), diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index fc3e45eb..48e27485 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -214,12 +214,11 @@ class Hero extends BaseModel { ); $dto['is_avatar'] = 0; if ($dto['token_id']){ - $nftList = Nft::getNftListByType(myself()->_getAddress(),Nft::HERO_TYPE); - if (count($nftList) > 0){ - foreach ($nftList as $value){ - if ($value['token_id'] == $dto['token_id']){ - $dto['is_avatar'] = 1; - } + $nft = Nft::getNft($dto['token_id']); + if ($nft){ + $tags = explode(",",$nft['tag']); + if (in_array(99,$tags)){ + $dto['is_avatar'] = 1; } } } @@ -316,12 +315,11 @@ class Hero extends BaseModel { // $dto['nft_address'] = $nft_address; $dto['is_avatar'] = 0; if ($dto['token_id']){ - $nftList = Nft::getNftListByType(myself()->_getAddress(),Nft::HERO_TYPE); - if (count($nftList) > 0){ - foreach ($nftList as $value){ - if ($value['token_id'] == $dto['token_id']){ - $dto['is_avatar'] = 1; - } + $nft = Nft::getNft($dto['token_id']); + if ($nft){ + $tags = explode(",",$nft['tag']); + if (in_array(99,$tags)){ + $dto['is_avatar'] = 1; } } }