From 89c1832f5bef16cb022fb7acc5c28f52641587df Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 8 Jun 2023 21:05:26 +0800 Subject: [PATCH] 1 --- webapp/controller/BaseAuthedController.class.php | 4 ++-- webapp/models/Hero.php | 10 +++++----- webapp/models/User.php | 12 ++++++++++++ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index c03947a4..86894c96 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -168,10 +168,10 @@ class BaseAuthedController extends BaseController { public function _getAddress() { - if ($addressActived) { + if (!$this->addressActived) { $userDb = $this->_getOrmUserInfo(); $this->address = $userDb['address']; - $addressActived = true; + $this->addressActived = true; } return $this->address; } diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index bae2f79c..83545969 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -24,7 +24,7 @@ use services\NftService; use services\FormulaService; use services\ContractConfig; use models\ChipPlugin; - +use models\User; class Hero extends BaseModel { @@ -43,7 +43,7 @@ class Hero extends BaseModel { public static function find($heroUniId) { - return self::internalFind(myself()->_getAccountId(), $heroUniId); + return self::internalFind(myself()->_getAccountId(), myself()->_getAddress(), $heroUniId); } public static function findEx($heroUniId){ @@ -64,7 +64,7 @@ class Hero extends BaseModel { public static function findByAccountId($accountId, $heroUniId) { - return self::internalFind($accountId, $heroUniId); + return self::internalFind($accountId, User::findUserAddress($accountId), $heroUniId); } public static function findByTokenId($tokenId) @@ -97,7 +97,7 @@ class Hero extends BaseModel { return $row; } - private static function internalFind($accountId, $heroUniId) + private static function internalFind($accountId, $address, $heroUniId) { $row = SqlHelper::ormSelectOne( myself()->_getMysql($accountId), @@ -109,7 +109,7 @@ class Hero extends BaseModel { if ($row) { $row['hero_uniid'] = $row['idx']; if ($row['account_id'] != $accountId) { - $openId = phpcommon\extractOpenId($accountId); + $openId = $address; if (!NftService::isHeroOwner($openId, $row['token_id'])) { $row = null; } diff --git a/webapp/models/User.php b/webapp/models/User.php index 8e45c6b9..a9115b68 100644 --- a/webapp/models/User.php +++ b/webapp/models/User.php @@ -32,6 +32,18 @@ class User extends BaseModel { return $row ? $row : null; } + public static function findUserAddress($accountId) + { + $row = SqlHelper::ormSelectOne + (myself()->_getMysql($targetId), + 't_user', + array( + 'account_id' => $targetId + ) + ); + return $row ? $row['address'] : null; + } + public static function getListByGuildId($guildId) { $rows = SqlHelper::ormSelect