1
This commit is contained in:
parent
ded703562d
commit
cac797a640
@ -617,6 +617,53 @@ class BlockChainController extends BaseAuthedController {
|
||||
return;
|
||||
}
|
||||
|
||||
//CEG扣除
|
||||
{
|
||||
$costSum = 0;
|
||||
foreach ($chipIds as $chipId){
|
||||
$chipDb = Chip::getChipByTokenId($chipId);
|
||||
if ($chipDb){
|
||||
$tiliDiff = $chipDb['strength_max'] - $chipDb['strength'];
|
||||
$costSum += \services\FormulaService::Chip_Demount_Mint($tiliDiff);
|
||||
}
|
||||
}
|
||||
$decFeeCb = null;
|
||||
if ($costSum > 0){
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $costSum
|
||||
),
|
||||
);
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$decFeeCb = function ($transId) use ($costItems, $chipIds){
|
||||
myself()->_decItems($costItems);
|
||||
error_log(json_encode($costItems));
|
||||
foreach ($costItems as $costItem){
|
||||
TransactionPrefee::add($transId,$costItem);
|
||||
}
|
||||
|
||||
foreach ($chipIds as $chipId){
|
||||
$chipDb = Chip::getChipByTokenId($chipId);
|
||||
$items = array(
|
||||
'token_id' => $chipDb['token_id'],
|
||||
'token_type' => $chipDb['chip_type'],
|
||||
'item_id' => self::TEST_ITEM_ID,
|
||||
'item_num' => $chipDb['strength_max'] - $chipDb['strength']
|
||||
);
|
||||
Chip::update($chipId,array(
|
||||
'strength'=>$chipDb['strength_max']
|
||||
));
|
||||
TransactionPrefee::add($transId,$items);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 1:
|
||||
{
|
||||
@ -625,52 +672,7 @@ class BlockChainController extends BaseAuthedController {
|
||||
myself()->_rspErr(101, 'token_id paramater error');
|
||||
return;
|
||||
}
|
||||
//CEG扣除
|
||||
{
|
||||
$costSum = 0;
|
||||
foreach ($chipIds as $chipId){
|
||||
$chipDb = Chip::getChipByTokenId($chipId);
|
||||
if ($chipDb){
|
||||
$tiliDiff = $chipDb['strength_max'] - $chipDb['strength'];
|
||||
$costSum += \services\FormulaService::Chip_Demount_Mint($tiliDiff);
|
||||
}
|
||||
}
|
||||
$decFeeCb = null;
|
||||
if ($costSum > 0){
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $costSum
|
||||
),
|
||||
);
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, $this->_getLackItemErrMsg($lackItem));
|
||||
return;
|
||||
}
|
||||
$decFeeCb = function ($transId) use ($costItems, $chipIds){
|
||||
myself()->_decItems($costItems);
|
||||
error_log(json_encode($costItems));
|
||||
foreach ($costItems as $costItem){
|
||||
TransactionPrefee::add($transId,$costItem);
|
||||
}
|
||||
|
||||
foreach ($chipIds as $chipId){
|
||||
$chipDb = Chip::getChipByTokenId($chipId);
|
||||
$items = array(
|
||||
'token_id' => $chipDb['token_id'],
|
||||
'token_type' => $chipDb['chip_type'],
|
||||
'item_id' => self::TEST_ITEM_ID,
|
||||
'item_num' => $chipDb['strength_max'] - $chipDb['strength']
|
||||
);
|
||||
Chip::update($chipId,array(
|
||||
'strength'=>$chipDb['strength_max']
|
||||
));
|
||||
TransactionPrefee::add($transId,$items);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
$this->internalBcCall(
|
||||
array(
|
||||
'c' => 'BcService',
|
||||
@ -721,7 +723,8 @@ class BlockChainController extends BaseAuthedController {
|
||||
'tokenType' => Nft::EQUIP_TYPE,
|
||||
'itemUniId' => $gunDb['gun_uniid'],
|
||||
'itemId' => $gunDb['gun_id']
|
||||
)
|
||||
),
|
||||
$decFeeCb
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
Loading…
x
Reference in New Issue
Block a user