From 828ae97924227fa17cc92abfd8233554f45d1abf Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 7 Nov 2022 14:36:25 +0800 Subject: [PATCH] 1 --- .../controller/BlockChainController.class.php | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index c9ab2078..e43ffe27 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -409,12 +409,75 @@ class BlockChainController extends BaseAuthedController { switch ($type) { case 1: { + $heroDb = Hero::findByTokenId($tokenId); + foreach ($chipIds as $chipId) { + $chipDb = Chip::findByTokenId($chipId); + if (!$chipDb) { + myself()->_rspErr(101, 'chip_ids paramater error'); + return; + } + } + if (!$heroDb) { + myself()->_rspErr(101, 'token_id paramater error'); + return; + } + + $this->internalBcCall( + array( + 'c' => 'BcService', + 'a' => 'unplugChip', + 'account_id' => myself()->_getAccountId(), + 'session_id' => myself()->_getSessionId(), + 'account' => myself()->_getOpenId(), + 'type' => $type, + 'token_id' => $tokenId, + 'chip_ids' => implode('|', $chipIds) + ), + array( + 'action' => Transaction::UNPLUG_CHIP_ACTION_TYPE, + 'tokenId' => $tokenId, + 'tokenType' => Nft::HERO_TYPE, + 'itemUniId' => $heroDb['chip_uniid'], + 'itemId' => $heroDb['item_id'] + ) + ); } break; case 2: { + $gunDb = Gun::findByTokenId($tokenId); + foreach ($chipIds as $chipId) { + $chipDb = Chip::findByTokenId($chipId); + if (!$chipDb) { + myself()->_rspErr(101, 'chip_ids paramater error'); + return; + } + } + if (!$gunDb) { + myself()->_rspErr(101, 'token_id paramater error'); + return; + } + $this->internalBcCall( + array( + 'c' => 'BcService', + 'a' => 'unplugChip', + 'account_id' => myself()->_getAccountId(), + 'session_id' => myself()->_getSessionId(), + 'account' => myself()->_getOpenId(), + 'type' => $type, + 'token_id' => $tokenId, + 'chip_ids' => implode('|', $chipIds) + ), + array( + 'action' => Transaction::UNPLUG_CHIP_ACTION_TYPE, + 'tokenId' => $tokenId, + 'tokenType' => Nft::EQUIP_TYPE, + 'itemUniId' => $gunDb['chip_uniid'], + 'itemId' => $gunDb['item_id'] + ) + ); } break; default: