diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index bdce3bbe..bfc843ac 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -124,7 +124,26 @@ class BlockChainController extends BaseAuthedController { public function evolve721Nft() { + $type = getReqVal('type', ''); + $tokenId1 = getReqVal('token_id1', ''); + $tokenId2 = getReqVal('token_id2', ''); + switch ($type) { + case 1: + { + } + break; + case 2: + { + + } + break; + default: + { + myself()->_rspErr(1, 'type param error'); + return; + } + } } public function evolveChip() @@ -458,6 +477,40 @@ class BlockChainController extends BaseAuthedController { } } + private function internalBcCall($params, $transParams) { + $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, + $transParams['action'], + $transParams['tokenId'], + $transParams['tokenType'], + $transParams['itemUniId'], + $transParams['itemId'] + ); + myself()->_rspData(array( + 'trans_id' => $transId, + 'params' => $rspObj['params'] + )); + } else { + myself()->_rspErr(500, 'server internal error'); + die(); + return; + } + } + private static function getWeb3ServiceUrl() { if (SERVER_ENV == _TEST) { diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 955940fb..aa09dbac 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -47,6 +47,24 @@ class Gun extends BaseModel { return $row; } + public static function findByTokenId($tokenId) + { + $row = SqlHelper::ormSelectOne( + myself()->_getMysql($tokenId), + 't_gun', + array( + 'token_id' => $tokenId, + ) + ); + if ($row) { + $row['gun_uniid'] = $row['idx']; + if (!NftService::isEquipOwner(myself()->_getOpenId(), $row['token_id'])) { + $row = null; + } + } + return $row; + } + public static function findByAccountId($accountId, $gunUniId) { return self::internalFind($accountId, $gunUniId); diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index e66a6212..1d3f5a27 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -44,6 +44,24 @@ class Hero extends BaseModel { return self::internalFind($accountId, $heroUniId); } + public static function findByTokenId($tokenId) + { + $row = SqlHelper::ormSelectOne( + myself()->_getMysql($tokenId), + 't_hero', + array( + 'token_id' => $tokenId, + ) + ); + if ($row) { + $row['hero_uniid'] = $row['idx']; + if (!NftService::isHeroOwner(myself()->_getOpenId(), $row['token_id'])) { + $row = null; + } + } + return $row; + } + private static function internalFind($accountId, $heroUniId) { $row = SqlHelper::ormSelectOne(