1
This commit is contained in:
parent
1957cf1271
commit
685edea7c0
@ -202,6 +202,7 @@ class OutAppNftController extends BaseController {
|
|||||||
public function nftDetail()
|
public function nftDetail()
|
||||||
{
|
{
|
||||||
$nftType = getReqVal('nft_type', '');
|
$nftType = getReqVal('nft_type', '');
|
||||||
|
$contractAddress = getReqVal('contract_address', '');
|
||||||
$netId = getReqVal('net_id', '');
|
$netId = getReqVal('net_id', '');
|
||||||
$tokenId = getReqVal('token_id', '');
|
$tokenId = getReqVal('token_id', '');
|
||||||
$info = array(
|
$info = array(
|
||||||
@ -216,6 +217,7 @@ class OutAppNftController extends BaseController {
|
|||||||
'image' => '',
|
'image' => '',
|
||||||
'detail' => array()
|
'detail' => array()
|
||||||
);
|
);
|
||||||
|
if (empty($contractAddress)) {
|
||||||
switch ($nftType) {
|
switch ($nftType) {
|
||||||
case 'hero':
|
case 'hero':
|
||||||
{
|
{
|
||||||
@ -223,10 +225,58 @@ class OutAppNftController extends BaseController {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
$this->internalGetNftDetail($netId, $contractAddress, $tokenId, $info);
|
||||||
|
}
|
||||||
error_log(json_encode($info));
|
error_log(json_encode($info));
|
||||||
myself()->_rspData($info);
|
myself()->_rspData($info);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function internalGetNftDetail($netId, $contractAddress, $tokenId, &$info) {
|
||||||
|
$nftDb = Nft::getNftByNetIdTokenTypeTokenId($netId, Nft::HERO_TYPE, $tokenId);
|
||||||
|
if (empty($nftDb)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch ($nftDb['token_type']) {
|
||||||
|
case Nft::HERO_TYPE:
|
||||||
|
{
|
||||||
|
$info['contract_address'] = $nftDb['contract_address'];
|
||||||
|
$info['token_id'] = $nftDb['token_id'];
|
||||||
|
$info['owner_address'] = $nftDb['owner_address'];
|
||||||
|
$heroDb = Hero::findByTokenId2($tokenId);
|
||||||
|
if ($heroDb) {
|
||||||
|
$heroAttrs = emptyReplace(json_decode($heroDb['wealth_attr'], true), array());
|
||||||
|
$heroResult = \mt\EconomyAttribute::getAttrValue($heroAttrs);
|
||||||
|
$wealth = $heroResult['wealth'];
|
||||||
|
$wealth_rate = $heroResult['wealth_rate'];
|
||||||
|
$lucky = $heroResult['lucky'];
|
||||||
|
$lucky_rate = $heroResult['lucky_rate'];
|
||||||
|
$heroAbility = Hero::abilityInfo($heroDb);
|
||||||
|
$heroMeta = \mt\Hero::get($heroDb['hero_id']);
|
||||||
|
if ($heroMeta) {
|
||||||
|
$itemMeta = \mt\Item::get($heroDb['hero_id']);
|
||||||
|
$heroAtteMeta = \mt\EconomyAttribute::findByGrade($itemMeta['relationship'],$heroDb['quality']);
|
||||||
|
$info['meta_url'] = NFT_META_URL . '/hero/meta/' . $netId . '/' . $tokenId;
|
||||||
|
$info['name'] = $heroMeta['name'];
|
||||||
|
$info['item_id'] = $heroMeta['id'];
|
||||||
|
$info['type'] = $nftDb['token_type'];
|
||||||
|
$info['image'] = 'https://www.cebg.games/res/avatars/' . $heroMeta['id'] . '.png';
|
||||||
|
$info['detail']['quality'] = $heroDb['quality'];
|
||||||
|
$info['detail']['max_mining_days'] = $heroAtteMeta['validTime'];
|
||||||
|
$info['detail']['wealth'] = floor($wealth * (1+$wealth_rate));
|
||||||
|
$info['detail']['lucky'] = floor($lucky * (1+$lucky_rate));
|
||||||
|
$info['detail']['hp'] = $heroAbility['hp'];
|
||||||
|
$info['detail']['atk'] = $heroAbility['attack'];
|
||||||
|
$info['detail']['def'] = $heroAbility['defence'];
|
||||||
|
$info['detail']['block'] = $heroAbility['block'];
|
||||||
|
$info['detail']['crit'] = $heroAbility['critical'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function getHeroDetail($netId, $tokenId, &$info)
|
private function getHeroDetail($netId, $tokenId, &$info)
|
||||||
{
|
{
|
||||||
$nftDb = Nft::getNftByNetIdTokenTypeTokenId($netId, Nft::HERO_TYPE, $tokenId);
|
$nftDb = Nft::getNftByNetIdTokenTypeTokenId($netId, Nft::HERO_TYPE, $tokenId);
|
||||||
|
@ -187,6 +187,20 @@ class Nft extends BaseModel
|
|||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getNftByNetIdContractAddressTokenId($netId, $contractAddress, $tokenId)
|
||||||
|
{
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getMarketMysql(),
|
||||||
|
't_nft',
|
||||||
|
array(
|
||||||
|
'net_id' => $netId,
|
||||||
|
'contract_address' => $contractAddress,
|
||||||
|
'token_id' => $tokenId,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getNftByNetCont($tokenId, $netId, $contractAddress)
|
public static function getNftByNetCont($tokenId, $netId, $contractAddress)
|
||||||
{
|
{
|
||||||
$row = SqlHelper::ormSelectOne(
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user