1
This commit is contained in:
parent
293b30cb65
commit
0db0f994ba
@ -59,18 +59,18 @@ class BlockChain(object):
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'name': 'mint',
|
'name': 'active721Nft',
|
||||||
'desc': '激活nft',
|
'desc': '激活721nft',
|
||||||
'group': 'BlockChain',
|
'group': 'BlockChain',
|
||||||
'url': 'webapp/index.php?c=BlockChain&a=mint',
|
'url': 'webapp/index.php?c=BlockChain&a=active721Nft',
|
||||||
'params': [
|
'params': [
|
||||||
['item_id', '', '指定的英雄id或者武器id'],
|
['type', 0, '1:英雄 2:枪械 3:芯片'],
|
||||||
['token_ids', '', 'token_ids多个用|分割'],
|
['uniid', '', '唯一id'],
|
||||||
],
|
],
|
||||||
'response': [
|
'response': [
|
||||||
_common.RspHead(),
|
_common.RspHead(),
|
||||||
['trans_id', '', '事务id'],
|
['trans_id', '', '事务id'],
|
||||||
['!params', [''], '合约参数列表'],
|
['!params', [''], '合约参数列表'],
|
||||||
]
|
]
|
||||||
}
|
},
|
||||||
]
|
]
|
||||||
|
@ -246,6 +246,8 @@ CREATE TABLE `t_chip` (
|
|||||||
`state` int(11) NOT NULL DEFAULT '0' COMMENT '0:已购买 1:免费(GIFT标签)',
|
`state` int(11) NOT NULL DEFAULT '0' COMMENT '0:已购买 1:免费(GIFT标签)',
|
||||||
`inlay_state` varchar(60) COMMENT '所镶嵌的芯片页id:1|2|3',
|
`inlay_state` varchar(60) COMMENT '所镶嵌的芯片页id:1|2|3',
|
||||||
`rand_attr` mediumblob COMMENT '随机属性',
|
`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:已初始激活',
|
`activate` int(11) NOT NULL DEFAULT '0' COMMENT '是否激活 1:已初始激活',
|
||||||
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
|
||||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||||
|
8
sql/migrate_230607_01.sql
Normal file
8
sql/migrate_230607_01.sql
Normal 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;
|
@ -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) {
|
private function internalBcCall($params, $transParams, $cb = null) {
|
||||||
$propertyChgService = new services\PropertyChgService();
|
$propertyChgService = new services\PropertyChgService();
|
||||||
$propertyChgService->addUserChg();
|
$propertyChgService->addUserChg();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user