From a77e3c203e2bfd8ba74d85644cc562bba4acca6c Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 10 Nov 2022 19:20:31 +0800 Subject: [PATCH] 1 --- .../controller/BlockChainController.class.php | 48 +++++++++++++++++-- webapp/controller/ChipController.class.php | 4 +- webapp/models/Chip.php | 37 ++++++++++++++ 3 files changed, 84 insertions(+), 5 deletions(-) diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index e35ad700..0a742e13 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -32,6 +32,7 @@ use models\TransactionPrefee; class BlockChainController extends BaseAuthedController { + const TEST_ITEM_ID = 666; public function _handlePre() { parent::_handlePre(); @@ -625,9 +626,50 @@ class BlockChainController extends BaseAuthedController { return; } //CEG扣除 - { - Chip::getChipByTokenId($chipIds[0]); - } +// { +// $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); +// }; +// } +// } +// } $this->internalBcCall( array( 'c' => 'BcService', diff --git a/webapp/controller/ChipController.class.php b/webapp/controller/ChipController.class.php index c3f0e45b..ab05a5fa 100644 --- a/webapp/controller/ChipController.class.php +++ b/webapp/controller/ChipController.class.php @@ -74,10 +74,10 @@ class ChipController extends BaseAuthedController $chip['strength_temporary'] = \services\FormulaService::Hero_Chip_NFT_Maximum_Physical_Strength($chip['chip_grade'],$chip['lucky_temporary']); $chip['mint'] = strval(\services\FormulaService::Chip_Need_Mint_Cost($chip['chip_grade'])-$chip['upgrade_mint']); } - if ($chip['inlay_state'] == 1){ +// if ($chip['inlay_state'] == 1){ $tili = $chip['strength_max']-$chip['strength']; $chip['mint'] = \services\FormulaService::Chip_Demount_Mint($tili); - } +// } $chip = Chip::toDto($chip); $this->_rspData(array( 'data' => $chip, diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index e451be51..cd38d8fa 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -146,6 +146,43 @@ class Chip extends BaseModel } public static function belongsToWhere($row){ + $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, + ); + $ChipPluginDb = myself()->_getMarketMysql()->execQuery($sql,$whereKv); + if (!$ChipPluginDb){ + return 0; + } + switch ($row['chip_type']){ + case 1:{ + $heroDb = Hero::findByTokenId2($ChipPluginDb['token_id']); + if($heroDb){ + return $heroDb['hero_id']; + }else{ + return 0; + } + } + break; + case 2:{ + $gunDb = Gun::findByTokenId2($ChipPluginDb['token_id']); + if($gunDb){ + return $gunDb['gun_id']; + }else{ + return 0; + } + } + break; + default:{ + return 0; + } + } + } + public static function belongsToWhereOld($row){ switch ($row['chip_type']){ case 1:{ $heroDb = array();