1
This commit is contained in:
parent
8134287775
commit
05c3235550
@ -162,8 +162,7 @@ class Market(object):
|
||||
['account', '', '账号id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
_common.NftDetail(),
|
||||
_common.NftView(),
|
||||
]
|
||||
},
|
||||
]
|
||||
|
@ -520,6 +520,8 @@ class NftDetail(object):
|
||||
['type', '', 'nft类型 1:英雄 2:枪支 3:芯片 4:盲盒'],
|
||||
['image', '', 'nft图片地址'],
|
||||
['state', 0, '0:正常状态 1:出售中 2:出租中'],
|
||||
['hide_attr', 0, '是否隐藏属性'],
|
||||
['is_genesis', 0, '是否创世nft'],
|
||||
['info', Union([
|
||||
[NftHeroDetail(), '英雄'],
|
||||
[NftGunDetail(), '枪支'],
|
||||
@ -529,3 +531,12 @@ class NftDetail(object):
|
||||
['!currency_list', [SystemCurrency()], '货币列表,(目前有且只有一个)'],
|
||||
['mint_time', 0, '铸造时间'],
|
||||
]
|
||||
|
||||
class NftView(object):
|
||||
|
||||
def __init__(self):
|
||||
self.fields = [
|
||||
['name', '', 'nft名字'],
|
||||
['description', '', 'nft描述'],
|
||||
['image', '', 'nft图片'],
|
||||
]
|
||||
|
@ -69,6 +69,7 @@ CREATE TABLE `t_box_order` (
|
||||
`bc_mint_need1` int(11) NOT NULL DEFAULT '0' COMMENT 'need',
|
||||
`bc_mint_itemid1` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
|
||||
`bc_mint_token_type1` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 1:英雄 2:枪支 3:芯片',
|
||||
`bc_mint_tags1` varchar(60) NOT NULL DEFAULT '' COMMENT 'tags',
|
||||
`bc_mint_count1` int(11) NOT NULL DEFAULT '0' COMMENT '生成nft次数',
|
||||
`bc_mint_time1` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次生成nft时间',
|
||||
`bc_mint_prepare_block_number1` varchar(60) NOT NULL DEFAULT '' COMMENT 'nft生成准备前块id',
|
||||
@ -80,6 +81,7 @@ CREATE TABLE `t_box_order` (
|
||||
`bc_mint_need2` int(11) NOT NULL DEFAULT '0' COMMENT 'need',
|
||||
`bc_mint_itemid2` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
|
||||
`bc_mint_token_type2` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 1:英雄 2:枪支 3:芯片',
|
||||
`bc_mint_tags2` varchar(60) NOT NULL DEFAULT '' COMMENT 'tags',
|
||||
`bc_mint_count2` int(11) NOT NULL DEFAULT '0' COMMENT '生成nft次数',
|
||||
`bc_mint_time2` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次生成nft时间',
|
||||
`bc_mint_prepare_block_number2` varchar(60) NOT NULL DEFAULT '' COMMENT 'nft生成准备前块id',
|
||||
@ -91,6 +93,7 @@ CREATE TABLE `t_box_order` (
|
||||
`bc_mint_need3` int(11) NOT NULL DEFAULT '0' COMMENT 'need',
|
||||
`bc_mint_itemid3` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
|
||||
`bc_mint_token_type3` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 1:英雄 2:枪支 3:芯片',
|
||||
`bc_mint_tags3` varchar(60) NOT NULL DEFAULT '' COMMENT 'tags',
|
||||
`bc_mint_count3` int(11) NOT NULL DEFAULT '0' COMMENT '生成nft次数',
|
||||
`bc_mint_time3` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次生成nft时间',
|
||||
`bc_mint_prepare_block_number3` varchar(60) NOT NULL DEFAULT '' COMMENT 'nft生成准备前块id',
|
||||
@ -110,6 +113,44 @@ CREATE TABLE `t_box_order` (
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_present`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `t_present`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_present` (
|
||||
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`batch_id` int(11) NOT NULL DEFAULT '0' COMMENT 'batch id',
|
||||
`row_id` int(11) NOT NULL DEFAULT '0' COMMENT 'row_id',
|
||||
`seq_id` int(11) NOT NULL DEFAULT '0' COMMENT 'seqid',
|
||||
`account` varchar(60) NOT NULL DEFAULT '' COMMENT 'account',
|
||||
`game_id` int(11) NOT NULL DEFAULT '0' COMMENT 'game id',
|
||||
`ignore` int(11) NOT NULL DEFAULT '0' COMMENT '忽略',
|
||||
`bc_minted` int(11) NOT NULL DEFAULT '0' COMMENT 'nft是否已创建',
|
||||
`bc_mint_txhash` varchar(255) NOT NULL DEFAULT '' COMMENT 'bc_mint_txhash',
|
||||
`bc_mint_itemid` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
|
||||
`bc_mint_tokenid` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id',
|
||||
`bc_mint_token_type` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 1:英雄 2:枪支 3:芯片',
|
||||
`bc_mint_tags` varchar(60) NOT NULL DEFAULT '' COMMENT 'tags',
|
||||
`bc_mint_count` int(11) NOT NULL DEFAULT '0' COMMENT '生成nft次数',
|
||||
`bc_mint_time` int(11) NOT NULL DEFAULT '0' COMMENT '最后一次生成nft时间',
|
||||
`bc_mint_prepare_block_number` varchar(60) NOT NULL DEFAULT '' COMMENT 'nft生成准备前块id',
|
||||
`bc_mint_success_block_number` varchar(60) NOT NULL DEFAULT '' COMMENT 'nft生成成功块id',
|
||||
`bc_mint_confirm_time` int(11) NOT NULL DEFAULT '0' COMMENT 'nft生成被确认时间',
|
||||
`suspend` int(11) NOT NULL DEFAULT '0' COMMENT '挂起',
|
||||
`suspend_reason` mediumblob COMMENT '挂起原因',
|
||||
`done` int(11) NOT NULL DEFAULT '0' COMMENT '是否已完成',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
UNIQUE KEY `batch_id_row_id_seq_id` (`batch_id`, `row_id`, `seq_id`),
|
||||
UNIQUE KEY `bc_mint_tokenid` (`bc_mint_tokenid`),
|
||||
KEY `account` (`account`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `t_nft`
|
||||
--
|
||||
@ -126,6 +167,7 @@ CREATE TABLE `t_nft` (
|
||||
`game_id` int(11) NOT NULL DEFAULT '0' COMMENT 'game id',
|
||||
`item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id',
|
||||
`rand_attr` mediumblob COMMENT '随机属性',
|
||||
`tags` varchar(60) NOT NULL DEFAULT '' COMMENT 'tags',
|
||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
|
@ -75,6 +75,11 @@ class BaseController {
|
||||
echo json_encode($rawData);
|
||||
}
|
||||
|
||||
public function _rspRawData($data)
|
||||
{
|
||||
echo json_encode($data);
|
||||
}
|
||||
|
||||
public function _getMysql($data)
|
||||
{
|
||||
$mysql_conf = getMysqlConfig(crc32($data));
|
||||
|
@ -123,10 +123,10 @@ class BcShopController extends BaseController {
|
||||
myself()->_rspErr(500, 'server internal error3');
|
||||
return;
|
||||
}
|
||||
if ($currBatchMeta['white_list'] && !mt\WhiteList::inWhiteList($buyerAddress)) {
|
||||
/*if ($currBatchMeta['white_list'] && !mt\WhiteList::inWhiteList($buyerAddress)) {
|
||||
myself()->_rspErr(500, 'not white list user');
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
$originalPrice = $goodsMeta['price'] * pow(10, MarketService::CURRENCY_DECIMALS);
|
||||
$discountPrice = $goodsMeta['discount'] * 100 > 0 ?
|
||||
$originalPrice * $goodsMeta['discount'] : $originalPrice;
|
||||
|
@ -306,6 +306,7 @@ class MarketController extends BaseController {
|
||||
)
|
||||
),
|
||||
'handle' => function ($row) use(&$nftDbList) {
|
||||
error_log(json_encode($row));
|
||||
array_push($nftDbList, $row);
|
||||
}
|
||||
),
|
||||
|
@ -19,7 +19,6 @@ use models\BoxOrder;
|
||||
use models\Nft;
|
||||
use models\BuyRecord;
|
||||
|
||||
|
||||
class RestApiController extends BaseController {
|
||||
|
||||
public function dispatch()
|
||||
@ -47,22 +46,23 @@ class RestApiController extends BaseController {
|
||||
|
||||
private function nftInfo($path)
|
||||
{
|
||||
$nftView = array(
|
||||
'name' => '',
|
||||
'description' => '',
|
||||
'image' => ''
|
||||
);
|
||||
$tokenId = $path[4];
|
||||
if (empty($tokenId)) {
|
||||
myself()->_rspErr(1, 'nft not found');
|
||||
myself()->_rspRawData($nftView);
|
||||
return;
|
||||
}
|
||||
$nftDb = Nft::getNft($tokenId);
|
||||
if (empty($nftDb)) {
|
||||
myself()->_rspErr(1, 'nft not found');
|
||||
myself()->_rspRawData($nftView);
|
||||
return;
|
||||
}
|
||||
$nftDto = Nft::toDto($nftDb);
|
||||
if (!$nftDto) {
|
||||
myself()->_rspErr(1, 'nft not found');
|
||||
return;
|
||||
}
|
||||
myself()->_rspData($nftDto);
|
||||
Nft::toNftView($nftDb, $nftView);
|
||||
myself()->_rspRawData($nftView);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,6 +16,9 @@ class Nft extends BaseModel {
|
||||
const HERO_TYPE = 1;
|
||||
const EQUIP_TYPE = 2;
|
||||
const CHIP_TYPE = 3;
|
||||
const BLIND_BOX_TYPE = 4;
|
||||
|
||||
const GENESIS_TAG = 1;
|
||||
|
||||
public static function getTokenType($itemMeta)
|
||||
{
|
||||
@ -92,6 +95,11 @@ class Nft extends BaseModel {
|
||||
if (!$itemMeta){
|
||||
return null;
|
||||
}
|
||||
$tags = self::parseTags($nftDb['tags']);
|
||||
$image = 'https://www.cebg.games/res/avatars/' . $itemMeta['id'] . '.png';
|
||||
if (in_array(self::GENESIS_TAG, $tags)) {
|
||||
$image = 'https://www.cebg.games/res/avatars/' . $itemMeta['id'] . '_1' . '.png';
|
||||
}
|
||||
$nft = array(
|
||||
'token_id' => $nftDb['token_id'],
|
||||
'owner_address' => $nftDb['owner_address'],
|
||||
@ -99,7 +107,9 @@ class Nft extends BaseModel {
|
||||
'item_id' => $nftDb['item_id'],
|
||||
'type' => $nftDb['token_type'],
|
||||
'state' => $nftDb['token_state'],
|
||||
'image' => 'https://www.cebg.games/res/avatars/' . $itemMeta['id'] . '.png',
|
||||
'hide_attr' => 1,
|
||||
'is_genesis' => in_array(self::GENESIS_TAG, $tags),
|
||||
'image' => $image,
|
||||
'currency_list' => array(),
|
||||
'transaction_recrod' => array(),
|
||||
'info' => array(
|
||||
@ -174,4 +184,22 @@ class Nft extends BaseModel {
|
||||
return $nft;
|
||||
}
|
||||
|
||||
public static function toNftView($row, &$nftView)
|
||||
{
|
||||
$itemMeta = mt\Item::get($row['item_id']);
|
||||
if ($itemMeta) {
|
||||
$nftView['name'] = $itemMeta['name'];
|
||||
$nftView['description'] = getXVal($itemMeta, 'nft_desc', $itemMeta['name']);
|
||||
$nftView['image'] = 'https://www.cebg.games/res/avatars/' . $itemMeta['id'] . '.png';
|
||||
} else {
|
||||
$nftView['image'] = 'https://www.cebg.games/res/avatars/0.png';
|
||||
}
|
||||
}
|
||||
|
||||
private function parseTags($tagsStr)
|
||||
{
|
||||
$tags = explode('|', $tagsStr);
|
||||
return $tags;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user