1
This commit is contained in:
parent
86f6343ffd
commit
ef476eaab2
@ -1,5 +1,6 @@
|
||||
<?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_mysql_cluster = require('../config/game2006api.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];
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
if ($hash_value < 0) {
|
||||
|
@ -5,6 +5,7 @@ use phpcommon\SqlHelper;
|
||||
class BaseController {
|
||||
|
||||
private $nowtime = 0;
|
||||
private $accountDbConn = null;
|
||||
private $marketDbConn = null;
|
||||
private $relationDbConn = null;
|
||||
private $mailDbConn = null;
|
||||
@ -142,6 +143,22 @@ class BaseController {
|
||||
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()
|
||||
{
|
||||
if ($this->marketDbConn) {
|
||||
|
@ -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(),
|
||||
|
@ -214,15 +214,14 @@ 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']){
|
||||
$nft = Nft::getNft($dto['token_id']);
|
||||
if ($nft){
|
||||
$tags = explode(",",$nft['tag']);
|
||||
if (in_array(99,$tags)){
|
||||
$dto['is_avatar'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $dto;
|
||||
}
|
||||
|
||||
@ -316,15 +315,14 @@ 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']){
|
||||
$nft = Nft::getNft($dto['token_id']);
|
||||
if ($nft){
|
||||
$tags = explode(",",$nft['tag']);
|
||||
if (in_array(99,$tags)){
|
||||
$dto['is_avatar'] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $dto;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user