This commit is contained in:
hujiabin 2024-07-03 19:33:30 +08:00
parent 86f6343ffd
commit ef476eaab2
4 changed files with 51 additions and 17 deletions

View File

@ -1,5 +1,6 @@
<?php <?php
$g_conf_accountdb_mysql_cluster = require('../config/accountdb.mysql.cluster.php');
$g_conf_market_mysql_cluster = require('../config/game2006market.mysql.cluster.php'); $g_conf_market_mysql_cluster = require('../config/game2006market.mysql.cluster.php');
$g_conf_mysql_cluster = require('../config/game2006api.mysql.cluster.php'); $g_conf_mysql_cluster = require('../config/game2006api.mysql.cluster.php');
$g_conf_relation_mysql_cluster = require('../config/game2006relation.mysql.cluster.php'); $g_conf_relation_mysql_cluster = require('../config/game2006relation.mysql.cluster.php');
@ -44,6 +45,16 @@ function getMysqlConfig($hash_value)
return $g_conf_mysql_cluster[$idx]; return $g_conf_mysql_cluster[$idx];
} }
function getAccountDbMysqlConfig($hash_value)
{
if ($hash_value < 0) {
error_log('callstack:' . json_encode(debug_backtrace(), JSON_PRETTY_PRINT));
die('hash_value < 0 ' . $hash_value);
}
global $g_conf_accountdb_mysql_cluster;
return $g_conf_accountdb_mysql_cluster;
}
function getMarketMysqlConfig($hash_value) function getMarketMysqlConfig($hash_value)
{ {
if ($hash_value < 0) { if ($hash_value < 0) {

View File

@ -5,6 +5,7 @@ use phpcommon\SqlHelper;
class BaseController { class BaseController {
private $nowtime = 0; private $nowtime = 0;
private $accountDbConn = null;
private $marketDbConn = null; private $marketDbConn = null;
private $relationDbConn = null; private $relationDbConn = null;
private $mailDbConn = null; private $mailDbConn = null;
@ -142,6 +143,22 @@ class BaseController {
return $conn; return $conn;
} }
public function _getAccountMysql()
{
if ($this->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() public function _getMarketMysql()
{ {
if ($this->marketDbConn) { if ($this->marketDbConn) {

View File

@ -1129,10 +1129,6 @@ class UserController extends BaseAuthedController {
$initRank = \mt\Parameter::getVal($this->init_rank,1); $initRank = \mt\Parameter::getVal($this->init_rank,1);
$RankMeta = mt\Rank::getRankById($initRank); $RankMeta = mt\Rank::getRankById($initRank);
$initElo = \mt\Parameter::getVal($this->init_elo,1200); $initElo = \mt\Parameter::getVal($this->init_elo,1200);
$is_gain_item = 0;
if (services\NftService::hasAnyNft($this->_getAddress())){
$is_gain_item = 1;
}
$fields = array( $fields = array(
'account_id' => $this->_getAccountId(), 'account_id' => $this->_getAccountId(),
@ -1154,11 +1150,23 @@ class UserController extends BaseAuthedController {
'score' => $RankMeta ? $RankMeta['rank_score'] : 300, 'score' => $RankMeta ? $RankMeta['rank_score'] : 300,
'history_best_score' => $RankMeta ? $RankMeta['rank_score'] : 300, 'history_best_score' => $RankMeta ? $RankMeta['rank_score'] : 300,
'elo' => $initElo, 'elo' => $initElo,
'is_gain_item' => $is_gain_item,
); );
if ($this->_getChannel() == BC_CHANNEL) { if ($this->_getChannel() == BC_CHANNEL) {
$fields['address'] = $this->_getOpenId(); $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 SqlHelper::upsert
($this->_getSelfMysql(), ($this->_getSelfMysql(),

View File

@ -214,15 +214,14 @@ class Hero extends BaseModel {
); );
$dto['is_avatar'] = 0; $dto['is_avatar'] = 0;
if ($dto['token_id']){ if ($dto['token_id']){
$nftList = Nft::getNftListByType(myself()->_getAddress(),Nft::HERO_TYPE); $nft = Nft::getNft($dto['token_id']);
if (count($nftList) > 0){ if ($nft){
foreach ($nftList as $value){ $tags = explode(",",$nft['tag']);
if ($value['token_id'] == $dto['token_id']){ if (in_array(99,$tags)){
$dto['is_avatar'] = 1; $dto['is_avatar'] = 1;
} }
} }
} }
}
return $dto; return $dto;
} }
@ -316,15 +315,14 @@ class Hero extends BaseModel {
// $dto['nft_address'] = $nft_address; // $dto['nft_address'] = $nft_address;
$dto['is_avatar'] = 0; $dto['is_avatar'] = 0;
if ($dto['token_id']){ if ($dto['token_id']){
$nftList = Nft::getNftListByType(myself()->_getAddress(),Nft::HERO_TYPE); $nft = Nft::getNft($dto['token_id']);
if (count($nftList) > 0){ if ($nft){
foreach ($nftList as $value){ $tags = explode(",",$nft['tag']);
if ($value['token_id'] == $dto['token_id']){ if (in_array(99,$tags)){
$dto['is_avatar'] = 1; $dto['is_avatar'] = 1;
} }
} }
} }
}
return $dto; return $dto;
} }