$tran['trans_id'], 'item_id' => $tran['item_id'], 'action' => Transaction::getActionDesc($tran['action']), 'status' => Transaction::getActionDesc($tran['status']), 'time' => $tran['createtime'], ) ); } $this->_rspData(array( 'transactions' => $trans )); } 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($uuid); if (!$gunDb) { myself()->_rspErr(1, 'gun not found'); return; } } break; default: { myself()->_rspErr(1, 'type param error'); return; } break; } } public function active1155Nft() { } public function reportActiveResult() { } public function evolve721Nft() { } public function reportEvolve721NftResult() { } public function evolveChip() { } public function reportEvolveChipResult() { } public function mintShardBatchUser() { } public function reportMintShardBatchUserResult() { } public function shardMixByUser() { } public function reportShardMixByUserResult() { } private function internalActivate721Nft($tokenId, $tokenType, $itemUniId, $itemId) { $params = array( 'c' => 'BcService', 'a' => 'activate721Nft', 'account_id' => myself()->_getAccountId(), 'session_id' => myself()->_getSessionId(), 'account' => myself()->_getOpenId(), 'token_id' => $tokenId, 'token_type' => $tokenType, 'item_uniid' => $itemUniId, 'item_id' => $itemId ); { $url = self::getWeb3ServiceUrl(); $response = ''; if (!phpcommon\HttpClient::get ($url, $params, $response)) { myself()->_rspErr(500, 'server internal error'); die(); return; } error_log($response); $rspObj = json_decode($response, true); if ($rspObj['errcode'] == 0) { $transId = $rspObj['trans_id']; Transaction::add( $transId, Transaction::MINT_721_ACTION_TYPE, $tokenId, $tokenType, $itemUniId, $itemId ); myself()->_rspData(array( 'trans_id' => $transId, 'params' => $rspObj['params'] )); } else { myself()->_rspErr(500, 'server internal error'); return; } } } private static function getWeb3ServiceUrl() { if (SERVER_ENV == _TEST) { return 'http://127.0.0.1:7672/webapp/index.php'; } $web3ServiceCluster = require_once('../config/web3service.cluster.php'); return $web3ServiceCluster[rand() % count($web3ServiceCluster)]; } }