This commit is contained in:
aozhiwei 2023-06-07 15:48:19 +08:00
parent 293b30cb65
commit 0db0f994ba
4 changed files with 92 additions and 6 deletions

View File

@ -59,18 +59,18 @@ class BlockChain(object):
]
},
{
'name': 'mint',
'desc': '激活nft',
'name': 'active721Nft',
'desc': '激活721nft',
'group': 'BlockChain',
'url': 'webapp/index.php?c=BlockChain&a=mint',
'url': 'webapp/index.php?c=BlockChain&a=active721Nft',
'params': [
['item_id', '', '指定的英雄id或者武器id'],
['token_ids', '', 'token_ids多个用|分割'],
['type', 0, '1英雄 2枪械 3芯片'],
['uniid', '', '唯一id'],
],
'response': [
_common.RspHead(),
['trans_id', '', '事务id'],
['!params', [''], '合约参数列表'],
]
}
},
]

View File

@ -246,6 +246,8 @@ CREATE TABLE `t_chip` (
`state` int(11) NOT NULL DEFAULT '0' COMMENT '0已购买 1免费GIFT标签',
`inlay_state` varchar(60) COMMENT '所镶嵌的芯片页id1|2|3',
`rand_attr` mediumblob COMMENT '随机属性',
`active_token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'active_token_id',
`active_count` int(11) NOT NULL DEFAULT '0' COMMENT 'active_count',
`activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1已初始激活',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',

View File

@ -0,0 +1,8 @@
begin;
alter table t_chip add column `active_token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'active_token_id';
alter table t_chip add column `active_count` int(11) NOT NULL DEFAULT '0' COMMENT 'active_count';
insert into version (version) values(2023060701);
commit;

View File

@ -112,6 +112,82 @@ class BlockChainController extends BaseAuthedController {
));
}
public function active721Nft()
{
$type = getReqVal('type', 0);
$uniid = getReqVal('uniid', 0);
switch ($type) {
case 1:
{
$heroDb = Hero::find($uniid);
if (!$heroDb) {
myself()->_rspErr(1, 'hero not found');
return;
}
if ($heroDb['token_id']) {
myself()->_rspErr(1, 'already activated');
return;
}
$tokenId = $heroDb['active_token_id'];
if (!$tokenId) {
$tokenId = BuyRecord::genOrderId
(
2006,
phpcommon\BC_FUNC_CREATION,
myself()->_getNowTime(),
myself()->_getOpenId()
);
Hero::Update($heroDb['hero_uniid'],
array(
'active_token_id' => $tokenId,
'active_count' => function () {
return 'active_count + 1';
}
));
}
$this->internalActivate721Nft($tokenId, Nft::HERO_TYPE, $heroDb['hero_uniid'], $heroDb['hero_id']);
}
break;
case 2:
{
$gunDb = Gun::find($uniid);
if (!$gunDb) {
myself()->_rspErr(1, 'gun not found');
return;
}
if ($gunDb['token_id']) {
myself()->_rspErr(1, 'already activated');
return;
}
$tokenId = $gunDb['active_token_id'];
if (!$tokenId) {
$tokenId = BuyRecord::genOrderId
(
2006,
phpcommon\BC_FUNC_CREATION,
myself()->_getNowTime(),
myself()->_getOpenId()
);
Gun::Update($gunDb['gun_uniid'],
array(
'active_token_id' => $tokenId,
'active_count' => function () {
return 'active_count + 1';
}
));
}
$this->internalActivate721Nft($tokenId, Nft::EQUIP_TYPE, $gunDb['gun_uniid'], $gunDb['gun_id']);
}
break;
default:
{
myself()->_rspErr(1, 'type param error');
return;
}
break;
}
}
private function internalBcCall($params, $transParams, $cb = null) {
$propertyChgService = new services\PropertyChgService();
$propertyChgService->addUserChg();