From 088d2f0d0ae2c5f1e4c08a047e54c04ad767aecb Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 10 Nov 2022 14:23:35 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 2 ++ .../controller/BlockChainController.class.php | 17 +++++++++-- webapp/models/TransactionPrefee.php | 29 +++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 webapp/models/TransactionPrefee.php diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 495d6bb1..987708dc 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -803,6 +803,8 @@ CREATE TABLE `t_transaction_prefee` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', `trans_id` varchar(255) NOT NULL DEFAULT '' COMMENT '事务id', + `target_token_id` bigint NOT NULL DEFAULT '0' COMMENT 'target_token_id', + `target_token_type` bigint NOT NULL DEFAULT '0' COMMENT 'target_token_type', `item_uniid` bigint NOT NULL DEFAULT '0' COMMENT '道具uniid', `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', `item_num` int(11) NOT NULL DEFAULT '0' COMMENT '道具数量', diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index 5bcab723..df2d16f4 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -13,6 +13,7 @@ require_once('models/Chip.php'); require_once('models/Transaction.php'); require_once('models/BuyRecord.php'); require_once('models/Chip.php'); +require_once('models/TransactionPrefee.php'); require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); @@ -27,6 +28,7 @@ use models\Nft; use models\Transaction; use models\BuyRecord; use models\Chip; +use models\TransactionPrefee; class BlockChainController extends BaseAuthedController { @@ -181,7 +183,12 @@ class BlockChainController extends BaseAuthedController { $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); return; } - $this->_decItems($costItems); + $decFeeCb = function ($transId) use ($costItems){ + myself()->_decItems($costItems); + foreach ($costItems as $costItem){ + TransactionPrefee::add($transId,$costItem); + } + }; } $this->internalBcCall( array( @@ -200,7 +207,8 @@ class BlockChainController extends BaseAuthedController { 'tokenType' => Nft::HERO_TYPE, 'itemUniId' => $nft1['hero_uniid'], 'itemId' => $nft1['hero_id'] - ) + ), + $decFeeCb ); } break; @@ -810,7 +818,7 @@ class BlockChainController extends BaseAuthedController { } } - private function internalBcCall($params, $transParams) { + private function internalBcCall($params, $transParams, $cb = null) { $url = self::getWeb3ServiceUrl(); $response = ''; if (!phpcommon\HttpClient::get @@ -833,6 +841,9 @@ class BlockChainController extends BaseAuthedController { $transParams['itemUniId'], $transParams['itemId'] ); + if ($cb) { + $cb($transId); + } myself()->_rspData(array( 'trans_id' => $transId, 'params' => $rspObj['params'] diff --git a/webapp/models/TransactionPrefee.php b/webapp/models/TransactionPrefee.php new file mode 100644 index 00000000..ef87a44c --- /dev/null +++ b/webapp/models/TransactionPrefee.php @@ -0,0 +1,29 @@ +_getSelfMysql(), + 't_transaction_prefee', + array( + 'account_id' => myself()->_getAccountId(), + 'trans_id' => $transId, + 'target_token_id' => isset($param['token_id']) ? $param['token_id']:0, + 'target_token_type' => isset($param['token_type']) ? $param['token_type']:0, +// 'item_uniid' => $transId, + 'item_id' => $param['item_id'], + 'item_num' => $param['item_num'], + 'done' => 0, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + } +} \ No newline at end of file