This commit is contained in:
hujiabin 2022-11-11 14:08:54 +08:00
parent eebc0f5a6e
commit 1be655ea80
2 changed files with 49 additions and 50 deletions

View File

@ -626,50 +626,51 @@ 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);
// }
// }
// 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){
// myself()->_decItems($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']
// ));
// $decFeeCb = function ($transId) use ($items){
// TransactionPrefee::add($transId,$items);
// };
// }
// }
// }
{
$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){
myself()->_decItems($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']
));
$decFeeCb = function ($transId) use ($items){
TransactionPrefee::add($transId,$items);
};
}
}
}
$this->internalBcCall(
array(
'c' => 'BcService',
@ -688,7 +689,8 @@ class BlockChainController extends BaseAuthedController {
'tokenType' => Nft::HERO_TYPE,
'itemUniId' => $heroDb['hero_uniid'],
'itemId' => $heroDb['hero_id']
)
),
$decFeeCb
);
}

View File

@ -141,7 +141,7 @@ class Chip extends BaseModel
$row['rand_attr'] = $attrs;
$row['today_get_gold'] = $todayGetGold;
$row['last_get_gold_time'] = $lastGetGoldTime;
$row['belong_to_item_id'] = self::belongsToWhereOld($row);
// $row['belong_to_item_id'] = self::belongsToWhereOld($row);
return $row;
}
@ -149,10 +149,7 @@ class Chip extends BaseModel
$tokenId = $row['token_id'];
$sql = "select * from t_chip_plugin where chip1=:tokenId or chip2=:tokenId or chip3=:tokenId or chip4=:tokenId limit 1";
$whereKv =array(
'chip1' => $tokenId,
'chip2' => $tokenId,
'chip3' => $tokenId,
'chip4' => $tokenId,
'tokenId' => $tokenId
);
$ChipPluginDb = myself()->_getMarketMysql()->execQuery($sql,$whereKv);
if (!$ChipPluginDb){