diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index e044abf5..dc2c1e83 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -161,6 +161,37 @@ class BlockChainController extends BaseAuthedController { 'item_uniid' => $itemUniId, 'item_id' => $itemId ); + { + $url = self::getWeb3ServiceUrl(); + $response = ''; + if (!phpcommon\HttpClient::get + ($url, + $params, + $response)) { + phpcommon\sendError(500, 'server internal error'); + die(); + return; + } + $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 { + phpcommon\sendError(500, 'server internal error'); + return; + } + } } } diff --git a/webapp/models/Transaction.php b/webapp/models/Transaction.php index 08d1efad..9e30a94a 100644 --- a/webapp/models/Transaction.php +++ b/webapp/models/Transaction.php @@ -5,7 +5,7 @@ namespace models; use mt; use phpcommon\SqlHelper; -class Transaction extends BaseModel { +class Transactionxo extends BaseModel { const MINT_721_ACTION_TYPE = 1; const MINT_1155_ACTION_TYPE = 2; @@ -43,6 +43,22 @@ class Transaction extends BaseModel { return $row; } + public static function add($transId, $action, $tokenId, $tokenType, $itemUniId, $itemId) + { + SqlHelper::insert( + 't_transaction', + array( + 'account_id' => myself()->_getAccountId(), + 'trans_id' => $transId, + 'action' => $action, + 'token_id' => $tokenId, + 'token_type' => $tokenType, + 'item_uniid' => $itemUniId, + 'item_id' => $itemId, + ) + ); + } + public static function getActionDesc($transDb) { switch ($transDb['action']) {