This commit is contained in:
hujiabin 2022-11-10 14:23:35 +08:00
parent d805e9b3c4
commit 088d2f0d0a
3 changed files with 45 additions and 3 deletions

View File

@ -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 '道具数量',

View File

@ -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']

View File

@ -0,0 +1,29 @@
<?php
namespace models;
use mt;
use phpcommon\SqlHelper;
class TransactionPrefee extends BaseModel
{
public static function add($transId,$param)
{
SqlHelper::insert(
myself()->_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(),
)
);
}
}