1
This commit is contained in:
parent
aab7553eef
commit
4d9a44864a
@ -3,6 +3,7 @@ use phpcommon\SqlHelper;
|
|||||||
require_once('models/Nft.php');
|
require_once('models/Nft.php');
|
||||||
require_once('models/User.php');
|
require_once('models/User.php');
|
||||||
require_once('models/Hero.php');
|
require_once('models/Hero.php');
|
||||||
|
require_once('models/GoldBullion.php');
|
||||||
require_once('mt/NftDesc.php');
|
require_once('mt/NftDesc.php');
|
||||||
require_once('mt/Hero.php');
|
require_once('mt/Hero.php');
|
||||||
require_once('mt/EconomyAttribute.php');
|
require_once('mt/EconomyAttribute.php');
|
||||||
@ -10,6 +11,7 @@ require_once('mt/EconomyAttribute.php');
|
|||||||
use models\Nft;
|
use models\Nft;
|
||||||
use models\User;
|
use models\User;
|
||||||
use models\Hero;
|
use models\Hero;
|
||||||
|
use models\GoldBullion;
|
||||||
|
|
||||||
class OutAppNftController extends BaseController {
|
class OutAppNftController extends BaseController {
|
||||||
|
|
||||||
@ -166,11 +168,26 @@ class OutAppNftController extends BaseController {
|
|||||||
myself()->_rspData($info);
|
myself()->_rspData($info);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function nftDetail()
|
public function nftDetailByContractAddress()
|
||||||
{
|
{
|
||||||
$contractAddress = getReqVal('contract_address', '');
|
$contractAddress = getReqVal('contract_address', '');
|
||||||
$netId = getReqVal('net_id', '');
|
$netId = getReqVal('net_id', '');
|
||||||
$tokenId = getReqVal('token_id', '');
|
$tokenId = getReqVal('token_id', '');
|
||||||
|
$nftDb = Nft::getNftByNetIdContractAddressTokenId($netId, $contractAddress, $tokenId);
|
||||||
|
$this->internalNftDetail($netId, $nftDb);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nftDetailByTokenType()
|
||||||
|
{
|
||||||
|
$netId = getReqVal('net_id', '');
|
||||||
|
$tokenType = getReqVal('token_type', '');
|
||||||
|
$tokenId = getReqVal('token_id', '');
|
||||||
|
$nftDb = Nft::getNftByNetIdTokenTypeTokenId($netId, $tokenType, $tokenId);
|
||||||
|
$this->internalNftDetail($netId, $nftDb);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function internalNftDetail($netId, $nftDb)
|
||||||
|
{
|
||||||
$info = array(
|
$info = array(
|
||||||
'net_id' => $netId,
|
'net_id' => $netId,
|
||||||
'contract_address' => '',
|
'contract_address' => '',
|
||||||
@ -183,23 +200,22 @@ class OutAppNftController extends BaseController {
|
|||||||
'image' => '',
|
'image' => '',
|
||||||
'detail' => array()
|
'detail' => array()
|
||||||
);
|
);
|
||||||
$this->internalGetNftDetail($netId, $contractAddress, $tokenId, $info);
|
error_log(json_encode($_REQUEST));
|
||||||
|
if (!empty($nftDb)) {
|
||||||
|
$this->internalGetNftDetail($nftDb, $info);
|
||||||
|
}
|
||||||
error_log(json_encode($info));
|
error_log(json_encode($info));
|
||||||
myself()->_rspData($info);
|
myself()->_rspData($info);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function internalGetNftDetail($netId, $contractAddress, $tokenId, &$info) {
|
private function internalGetNftDetail($nftDb, &$info) {
|
||||||
$nftDb = Nft::getNftByNetIdTokenTypeTokenId($netId, Nft::HERO_TYPE, $tokenId);
|
$info['contract_address'] = $nftDb['contract_address'];
|
||||||
if (empty($nftDb)) {
|
$info['token_id'] = $nftDb['token_id'];
|
||||||
return;
|
$info['owner_address'] = $nftDb['owner_address'];
|
||||||
}
|
|
||||||
switch ($nftDb['token_type']) {
|
switch ($nftDb['token_type']) {
|
||||||
case Nft::HERO_TYPE:
|
case Nft::HERO_TYPE:
|
||||||
{
|
{
|
||||||
$info['contract_address'] = $nftDb['contract_address'];
|
$heroDb = Hero::findByTokenId2($nftDb['token_id']);
|
||||||
$info['token_id'] = $nftDb['token_id'];
|
|
||||||
$info['owner_address'] = $nftDb['owner_address'];
|
|
||||||
$heroDb = Hero::findByTokenId2($tokenId);
|
|
||||||
if ($heroDb) {
|
if ($heroDb) {
|
||||||
$heroAttrs = emptyReplace(json_decode($heroDb['wealth_attr'], true), array());
|
$heroAttrs = emptyReplace(json_decode($heroDb['wealth_attr'], true), array());
|
||||||
$heroResult = \mt\EconomyAttribute::getAttrValue($heroAttrs);
|
$heroResult = \mt\EconomyAttribute::getAttrValue($heroAttrs);
|
||||||
@ -212,7 +228,7 @@ class OutAppNftController extends BaseController {
|
|||||||
if ($heroMeta) {
|
if ($heroMeta) {
|
||||||
$itemMeta = \mt\Item::get($heroDb['hero_id']);
|
$itemMeta = \mt\Item::get($heroDb['hero_id']);
|
||||||
$heroAtteMeta = \mt\EconomyAttribute::findByGrade($itemMeta['relationship'],$heroDb['quality']);
|
$heroAtteMeta = \mt\EconomyAttribute::findByGrade($itemMeta['relationship'],$heroDb['quality']);
|
||||||
$info['meta_url'] = NFT_META_URL . '/hero/meta/' . $netId . '/' . $tokenId;
|
$info['meta_url'] = NFT_META_URL . '/hero/meta/' . $nftDb['net_id'] . '/' . $nftDb['token_id'];
|
||||||
$info['name'] = $heroMeta['name'];
|
$info['name'] = $heroMeta['name'];
|
||||||
$info['item_id'] = $heroMeta['id'];
|
$info['item_id'] = $heroMeta['id'];
|
||||||
$info['type'] = $nftDb['token_type'];
|
$info['type'] = $nftDb['token_type'];
|
||||||
@ -230,6 +246,19 @@ class OutAppNftController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Nft::GOLD_BULLION_TYPE:
|
||||||
|
{
|
||||||
|
$itemMeta = \mt\Item::get($heroDb['hero_id']);
|
||||||
|
if ($itemMeta) {
|
||||||
|
$info['meta_url'] = NFT_META_URL . '/hero/meta/' . $netId . '/' . $tokenId;
|
||||||
|
$info['name'] = $itemMeta['name'];
|
||||||
|
$info['item_id'] = $itemMeta['id'];
|
||||||
|
$info['type'] = $nftDb['token_type'];
|
||||||
|
$info['image'] = 'https://www.cebg.games/res/avatars/' . $itemMeta['id'] . '.png';
|
||||||
|
//$info['detail']['quality'] = $heroDb['quality'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,6 +93,18 @@ class GoldBullion extends BaseModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function findByTokenId($tokenId)
|
||||||
|
{
|
||||||
|
$row = SqlHelper::ormSelectOne(
|
||||||
|
myself()->_getSelfMysql(),
|
||||||
|
't_gold_bullion',
|
||||||
|
array(
|
||||||
|
'token_id' => $tokenId,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
private static function genUniqId()
|
private static function genUniqId()
|
||||||
{
|
{
|
||||||
$uniqId = uniqid(md5(rand() . rand() . rand() . myself()->_getSessionId()), true);
|
$uniqId = uniqid(md5(rand() . rand() . rand() . myself()->_getSessionId()), true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user