diff --git a/doc/AAMarket.py b/doc/AAMarket.py index b2502dff..78bdb062 100644 --- a/doc/AAMarket.py +++ b/doc/AAMarket.py @@ -58,6 +58,22 @@ class AAMarket(object): ['highest_price_goods', _common.MarketGoods(), '最高价格商品(如果没则为null)'], ] }, + { + 'method': 'GET', + 'name': '/api/market/product/goods/:net_id/:contract_address/:token_id', + 'desc': '获取单个商品信息', + 'group': '!AAMarket', + 'url': 'https://market-test.kingsome.cn/api/market/product/goods/:net_id/:contract_address/:token_id', + 'params': [ + [':net_id', 0, '链id'], + [':contract_address', '', '合约地址'], + [':token_id', '', 'token_id'], + ], + 'response': [ + _common.RspHead(), + ['data', _common.MarketGoods(), '商品信息(如果没则为null), 如果未上架则data.event==null'], + ] + }, { 'method': 'GET', 'name': '/api/market/product/category/:net_id', @@ -109,7 +125,7 @@ class AAMarket(object): 'response': [ _common.RspHead(), ['page', _common.StreamPage(), '分页信息'], - ['!rows', [_common.NftInfo()], '数据'], + ['!rows', [_common.AssetNftInfo()], '数据'], ] }, { diff --git a/doc/_common.py b/doc/_common.py index 8aca9ddc..61f9618d 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1773,3 +1773,23 @@ class MarketGoods(object): ['nft', NftInfo(), 'nft信息'], ['in_shopcart', 0, '商品是否已在购物车里'], ] + +class AssetNftInfo(object): + + def __init__(self): + self.fields = [ + ['net_id', 0, '链id'], + ['contract_address', 0, '合约地址'], + ['token_id', '', 'token id'], + ['owner_address', '', '所有者地址'], + ['meta_url', '', '元数据url'], + ['name', '', 'nft名字'], + ['item_id', 0, '道具id'], + ['on_sale', 0, '是否出售中'], + ['type', '', 'nft类型 1:英雄 11:金砖'], + ['image', '', 'nft图片地址'], + ['detail', Union([ + [NftHeroDetailNew(), '英雄'], + [NftGoldBullionDetail(), '英雄'], + ]), 'nft详细信息'], + ] diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 8a19fed9..8be0b721 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -171,6 +171,7 @@ CREATE TABLE `t_hero` ( `active_count` int(11) NOT NULL DEFAULT '0' COMMENT 'active_count', `activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1:已初始激活', `activate_time` int(11) NOT NULL DEFAULT '0' COMMENT '激活时间', + `on_chain_time` int(11) NOT NULL DEFAULT '0' COMMENT '上链时间', `wealth_attr` mediumblob COMMENT '财富值属性', `seal_type` int(11) NOT NULL DEFAULT '0' COMMENT '0:未封存 1:已封存', `unseal_time` int(11) NOT NULL DEFAULT '0' COMMENT '解开封时间', diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index 7ecb69d1..d87e09cd 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -129,6 +129,10 @@ class BlockChainController extends BaseAuthedController { myself()->_rspErr(1, 'hero not found'); return; } + if (!$heroDb['seal_type']) { + myself()->_rspErr(1, 'hero no seal'); + return; + } $isMint = true; $tokenId = $heroDb['token_id']; if ($heroDb['token_id'] && $heroDb['activate']) { diff --git a/webapp/controller/OutAppNftController.class.php b/webapp/controller/OutAppNftController.class.php index 07481910..b876dadd 100644 --- a/webapp/controller/OutAppNftController.class.php +++ b/webapp/controller/OutAppNftController.class.php @@ -3,7 +3,6 @@ use phpcommon\SqlHelper; require_once('models/Nft.php'); require_once('models/User.php'); require_once('models/Hero.php'); -require_once('models/GoldBullion.php'); require_once('mt/NftDesc.php'); require_once('mt/Hero.php'); require_once('mt/EconomyAttribute.php'); @@ -11,7 +10,6 @@ require_once('mt/EconomyAttribute.php'); use models\Nft; use models\User; use models\Hero; -use models\GoldBullion; class OutAppNftController extends BaseController { @@ -155,12 +153,15 @@ class OutAppNftController extends BaseController { $NftMeta = \mt\NftDesc::getByItemId($heroDb['hero_id']); $info['name'] = $heroMeta['name']; $info['description'] = $NftMeta['desc']; - $info['image'] = "https://res2.cebggame.com/nft/meta/".$heroDb['hero_id'].'_'.$heroDb['quality'].".gif"; + $info['image'] = "https://res2.counterfire.games/nft/meta/".$heroDb['hero_id'].'_'.$heroDb['quality'].".gif"; array_push($info['attributes'],array( "trait_type" => "level", "value" => intval($heroDb['hero_lv']), "max_value" => 15, )); + if ($this->isCloseBox()) { + $this->fillBoxMeta($info); + } } break; case Nft::GOLD_BULLION_TYPE: @@ -168,7 +169,10 @@ class OutAppNftController extends BaseController { $NftMeta = \mt\NftDesc::getByItemId($nftDb['item_id']); //$info['name'] = $heroMeta['name']; $info['description'] = $NftMeta['desc']; - $info['image'] = "https://res2.cebggame.com/nft/meta/".$nftDb['item_id'].".png"; + $info['image'] = "https://res2.counterfire.games/nft/meta/".$nftDb['item_id'].".png"; + if ($this->isCloseBox()) { + $this->fillBoxMeta($info); + } } break; } @@ -270,7 +274,7 @@ class OutAppNftController extends BaseController { $info['name'] = $heroMeta['name']; $info['item_id'] = $heroMeta['id']; $info['type'] = $nftDb['token_type']; - $info['image'] = 'https://res2.cebggame.com/nft/meta/' . $heroMeta['id'] . '_' . $heroDb['quality'] . '.gif'; + $info['image'] = 'https://res2.counterfire.games/nft/meta/' . $heroMeta['id'] . '_' . $heroDb['quality'] . '.gif'; $info['detail']['quality'] = $heroDb['quality']; $info['detail']['max_mining_days'] = $heroAtteMeta['validTime']; $info['detail']['wealth'] = floor($wealth * (1+$wealth_rate)); @@ -282,6 +286,9 @@ class OutAppNftController extends BaseController { $info['detail']['crit'] = $heroAbility['critical']; } } + if ($this->isCloseBox()) { + $this->fillBoxDetail($info); + } } break; case Nft::GOLD_BULLION_TYPE: @@ -292,9 +299,12 @@ class OutAppNftController extends BaseController { $info['name'] = $itemMeta['name']; $info['item_id'] = $itemMeta['id']; $info['type'] = $nftDb['token_type']; - $info['image'] = 'https://res2.cebggame.com/nft/meta/' . $itemMeta['id'] . '.png'; + $info['image'] = 'https://res2.counterfire.games/nft/meta/' . $itemMeta['id'] . '.png'; $info['detail']['gold_coins'] = $this->getGoldBullionGoldNum($nftDb['item_id']); } + if ($this->isCloseBox()) { + $this->fillBoxDetail($info); + } } break; } @@ -320,4 +330,39 @@ class OutAppNftController extends BaseController { } } + private function isCloseBox() + { + $openTime = 1719828000; + if (myself()->_getNowTime() < $openTime) { + if (SERVER_ENV == _ONLINE) { + return true; + } + } + return false; + } + + private function fillBoxMeta(&$info) + { + $info['name'] = 'box'; + $info['description'] = 'box'; + $info['image'] = "https://res2.counterfire.games/nft/box/Gen2_raw.gif"; + $info['attributes'] = array(); + } + + private function fillBoxDetail(&$info) + { + $info = array( + 'net_id' => $info['net_id'], + 'contract_address' => $info['contract_address'], + 'token_id' => $info['token_id'], + 'owner_address' => $info['owner_address'], + 'meta_url' => $info['meta_url'], + 'name' => 'box', + 'item_id' => 0, + 'type' => $info['type'], + 'image' => "https://res2.counterfire.games/nft/box/Gen2_raw.gif", + 'detail' => array() + ); + } + } diff --git a/webapp/models/GoldBullion.php b/webapp/models/GoldBullion.php deleted file mode 100644 index c2bf1916..00000000 --- a/webapp/models/GoldBullion.php +++ /dev/null @@ -1,114 +0,0 @@ -_getAddress(); - if (empty($address)) { - return; - } - $rows = SqlHelper::ormSelect( - myself()->_getSelfMysql(), - 't_gold_bullion', - array( - 'open_address' => myself()->_getAddress(), - 'open_status' => self::OPEN_STATUS_PENDING, - 'returned' => 0, - ) - ); - if (count($rows) > 0) { - $confirmedRows = array(); - foreach ($rows as $row) { - $uniqId = self::genUniqId(); - SqlHelper::update( - myself()->_getSelfMysql(), - 't_gold_bullion', - array( - 'idx' => $row['idx'], - 'open_status' => self::OPEN_STATUS_PENDING - ), - array( - 'open_status' => self::OPEN_STATUS_SEND_BEGIN, - 'open_uniqid' => $uniqId - ) - ); - $newRow = SqlHelper::ormSelectOne( - myself()->_getSelfMysql(), - 't_gold_bullion', - array( - 'idx' => $row['idx'], - ) - ); - if (!empty($newRow) && $newRow['open_uniqid'] == $uniqId) { - array_push($confirmedRows, $row); - } - self::doSendAward($confirmedRows); - } - } - } - - public static function doSendAward($confirmedRows) - { - $propertyChgService = new services\PropertyChgService(); - $awardService = new services\AwardService(); - if (empty($confirmedRows)) { - return; - } - foreach ($confirmedRows as $row) { - $items = array( - array( - 'item_id' => V_ITEM_GOLD, - 'item_num' => $row['gold'] - ) - ); - myself()->_addItems($items, $awardService, $propertyChgService); - SqlHelper::update( - myself()->_getSelfMysql(), - 't_gold_bullion', - array( - 'idx' => $row['idx'], - ), - array( - 'account_id' => myself()->_getAccountId(), - 'open_status' => self::OPEN_STATUS_SEND_END, - ) - ); - $content = "[Item Name] has been used successfully, you have received 100,000 gold"; - services\MailApiService::sendOpenGold($row['net_id'], - $row['token_id'], - '', - $content); - } - } - - public static function findByTokenId($tokenId) - { - $row = SqlHelper::ormSelectOne( - myself()->_getSelfMysql(), - 't_gold_bullion', - array( - 'token_id' => $tokenId, - ) - ); - return $row; - } - - private static function genUniqId() - { - $uniqId = uniqid(md5(rand() . rand() . rand() . myself()->_getSessionId()), true); - return $uniqId; - } - -} diff --git a/webapp/services/LoginService.php b/webapp/services/LoginService.php index 851c296d..3a46488a 100644 --- a/webapp/services/LoginService.php +++ b/webapp/services/LoginService.php @@ -2,15 +2,10 @@ namespace services; -require_once('models/GoldBullion.php'); - -use models\GoldBullion; - class LoginService extends BaseService { public function onLogon() { - GoldBullion::onLogin(); } } diff --git a/webapp/services/MailApiService.php b/webapp/services/MailApiService.php index 923abd57..43238b63 100644 --- a/webapp/services/MailApiService.php +++ b/webapp/services/MailApiService.php @@ -8,7 +8,6 @@ class MailApiService extends BaseService { const SELL_UNIKEY_PRE = 'ingame.market.sell:'; const BUY_UNIKEY_PRE = 'ingame.market.buy:'; - const OPEN_GOLD_BULLION_UNIKEY_PRE = 'gold_bullion:open:'; const SELL_MAIL_SUBJECT = 'Item successfully sold'; /* @@ -99,44 +98,6 @@ class MailApiService extends BaseService { ); } - /* - netId: netId - tokenId:tokenid - to:邮件接受方account_id - subject: 邮件标题 - content: 邮件正文 - */ - public function sendOpenGold($netId, $tokenId, $subject, $content) - { - $unikey = self::OPEN_GOLD_BULLION_UNIKEY_PRE . $netId . '_' . $tokenId; - SqlHelper::upsert - (myself()->_getMailMysql(), - 't_sys_mail', - array( - 'unikey' => $unikey - ), - array( - ), - array( - 'unikey' => $unikey, - 'subject' => $subject, - 'content' => $content, - 'recipients' => json_encode(array( - $to - )), - 'attachments' => json_encode(array()), - 'tag1' => 1, - 'tag2' => 3, - 'sendtime' => myself()->_getNowTime(), - 'expiretime' => myself()->_getNowTime() + 3600 * 24 * 365 * 10, - 'user_reg_start_time' => 0, - 'user_reg_end_time' => myself()->_getNowTime() + 3600 * 24 * 365 * 10, - 'createtime' => myself()->_getNowTime(), - 'modifytime' => myself()->_getNowTime() - ) - ); - } - private function adjustAttachments(&$attachments) { if (empty($attachments)) {