Merge branch 'star' of git.kingsome.cn:server/game2006api into star

This commit is contained in:
hujiabin 2023-06-08 21:59:31 +08:00
commit 8ba7d42e8f
3 changed files with 19 additions and 7 deletions

View File

@ -168,10 +168,10 @@ class BaseAuthedController extends BaseController {
public function _getAddress() public function _getAddress()
{ {
if ($addressActived) { if (!$this->addressActived) {
$userDb = $this->_getOrmUserInfo(); $userDb = $this->_getOrmUserInfo();
$this->address = $userDb['address']; $this->address = $userDb['address'];
$addressActived = true; $this->addressActived = true;
} }
return $this->address; return $this->address;
} }

View File

@ -24,7 +24,7 @@ use services\NftService;
use services\FormulaService; use services\FormulaService;
use services\ContractConfig; use services\ContractConfig;
use models\ChipPlugin; use models\ChipPlugin;
use models\User;
class Hero extends BaseModel { class Hero extends BaseModel {
@ -43,7 +43,7 @@ class Hero extends BaseModel {
public static function find($heroUniId) public static function find($heroUniId)
{ {
return self::internalFind(myself()->_getAccountId(), $heroUniId); return self::internalFind(myself()->_getAccountId(), myself()->_getAddress(), $heroUniId);
} }
public static function findEx($heroUniId){ public static function findEx($heroUniId){
@ -64,7 +64,7 @@ class Hero extends BaseModel {
public static function findByAccountId($accountId, $heroUniId) public static function findByAccountId($accountId, $heroUniId)
{ {
return self::internalFind($accountId, $heroUniId); return self::internalFind($accountId, User::findUserAddress($accountId), $heroUniId);
} }
public static function findByTokenId($tokenId) public static function findByTokenId($tokenId)
@ -97,7 +97,7 @@ class Hero extends BaseModel {
return $row; return $row;
} }
private static function internalFind($accountId, $heroUniId) private static function internalFind($accountId, $address, $heroUniId)
{ {
$row = SqlHelper::ormSelectOne( $row = SqlHelper::ormSelectOne(
myself()->_getMysql($accountId), myself()->_getMysql($accountId),
@ -109,7 +109,7 @@ class Hero extends BaseModel {
if ($row) { if ($row) {
$row['hero_uniid'] = $row['idx']; $row['hero_uniid'] = $row['idx'];
if ($row['account_id'] != $accountId) { if ($row['account_id'] != $accountId) {
$openId = phpcommon\extractOpenId($accountId); $openId = $address;
if (!NftService::isHeroOwner($openId, $row['token_id'])) { if (!NftService::isHeroOwner($openId, $row['token_id'])) {
$row = null; $row = null;
} }

View File

@ -32,6 +32,18 @@ class User extends BaseModel {
return $row ? $row : null; 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) public static function getListByGuildId($guildId)
{ {
$rows = SqlHelper::ormSelect $rows = SqlHelper::ormSelect