diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index 5a1796c2..3a1b6cb1 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -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 ); } diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 4d6820ff..4d2992ca 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -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){