diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index de4f6ea6..cc2998c9 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -124,40 +124,36 @@ class BlockChainController extends BaseAuthedController { myself()->_rspErr(1, 'hero not found'); return; } + $isMint = true; if ($heroDb['token_id'] && $heroDb['activate']) { - myself()->_rspErr(1, 'already activated'); - return; - } - /* - if ($heroDb['state'] == 1) { - myself()->_rspErr(1, 'cant mint'); - return; - }*/ - $tokenId = $heroDb['token_id']; - if (!$tokenId) { - $tokenId = BuyRecord::genOrderId - ( - GAME_ID, - phpcommon\BC_FUNC_CREATION, - myself()->_getNowTime(), - myself()->_getAddress() - ); - Hero::safeUpdateTokenId($heroDb['hero_uniid'], $tokenId); - $heroDb = Hero::find($uniid); - if (!$heroDb) { - myself()->_rspErr(1, 'hero not found'); - return; - } - if ($heroDb['token_id'] != $tokenId) { - myself()->_rspErr(500, 'server internal error'); - return; + $isMint = false; + } else { + $tokenId = $heroDb['token_id']; + if (!$tokenId) { + $tokenId = BuyRecord::genOrderId + ( + GAME_ID, + phpcommon\BC_FUNC_CREATION, + myself()->_getNowTime(), + myself()->_getAddress() + ); + Hero::safeUpdateTokenId($heroDb['hero_uniid'], $tokenId); + $heroDb = Hero::find($uniid); + if (!$heroDb) { + myself()->_rspErr(1, 'hero not found'); + return; + } + if ($heroDb['token_id'] != $tokenId) { + myself()->_rspErr(500, 'server internal error'); + return; + } } } $this->internalActivate721Nft($tokenId, Nft::HERO_TYPE, $heroDb['hero_uniid'], $heroDb['hero_id'], - true); + $isMint); } break; default: @@ -204,7 +200,7 @@ class BlockChainController extends BaseAuthedController { 'token_type' => $tokenType, 'item_uniid' => $itemUniId, 'item_id' => $itemId, - 'is_mint' => $isMint, + 'is_mint' => $isMint ? 1 : 0, 'net_id' => NET_ID ); {