diff --git a/doc/BlockChain.py b/doc/BlockChain.py index 444dc53e..27bf4a56 100644 --- a/doc/BlockChain.py +++ b/doc/BlockChain.py @@ -31,6 +31,20 @@ class BlockChain(object): _common.RspHead(), ] }, + { + 'name': 'getJumpInfo', + 'desc': '获取跳转信息', + 'group': 'BlockChain', + 'url': 'webapp/index.php?c=BlockChain&a=getJumpInfo', + 'params': [ + ['trans_id', '', '事务id'], + ], + 'response': [ + _common.RspHead(), + ['action', 0,'动作 1:特定英雄详情,2:特定枪械详情,3:NFTs芯片列表,4:英雄进阶介面,5:枪械进阶介面,6:芯片升级介面,7:NFTs碎片列表 ,8:目标英雄详情介面的Chip页签,9:目标枪械详情介面的Chip页签 '], + ['!params', [''], '参数列表 params[0]: token_id'], + ] + }, { 'name': 'active721Nft', 'desc': '激活721nft', diff --git a/doc/_common.py b/doc/_common.py index 52f5f1be..26a7f24a 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -969,6 +969,7 @@ class NftTransaction(object): def __init__(self): self.fields = [ + ['trans_id', 0, 'trans_id'], ['item_id', 0, '道具id'], ['action', 0, '动作'], ['time', 0, '时间'], diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 495d6bb1..1f4c0e2d 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -803,9 +803,11 @@ 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 '道具数量', + `item_num` double NOT NULL DEFAULT '0' COMMENT '道具数量', `done` int(11) NOT NULL DEFAULT '0' COMMENT 'done', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index 5bcab723..0a742e13 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -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,9 +28,11 @@ use models\Nft; use models\Transaction; use models\BuyRecord; use models\Chip; +use models\TransactionPrefee; class BlockChainController extends BaseAuthedController { + const TEST_ITEM_ID = 666; public function _handlePre() { parent::_handlePre(); @@ -171,17 +174,22 @@ class BlockChainController extends BaseAuthedController { 'item_id' => V_ITEM_GOLD, 'item_num' => \services\FormulaService::Hero_Advanced_CEG_Expend($nft1['quality']+1) ), -// array( -// 'item_id' => V_ITEM_DIAMOND, -// 'item_num' => \services\FormulaService::Hero_Advanced_CEC_Expend($nft1['quality']+1) -// ) + array( + 'item_id' => V_ITEM_DIAMOND, + 'item_num' => \services\FormulaService::Hero_Advanced_CEC_Expend($nft1['quality']+1) + ) ); $lackItem = null; if (!$this->_hasEnoughItems($costItems, $lackItem)) { $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 +208,8 @@ class BlockChainController extends BaseAuthedController { 'tokenType' => Nft::HERO_TYPE, 'itemUniId' => $nft1['hero_uniid'], 'itemId' => $nft1['hero_id'] - ) + ), + $decFeeCb ); } break; @@ -219,10 +228,10 @@ class BlockChainController extends BaseAuthedController { 'item_id' => V_ITEM_GOLD, 'item_num' => \services\FormulaService::Weapon_Advanced_CEG_Expend($nft1['quality']+1) ), -// array( -// 'item_id' => V_ITEM_DIAMOND, -// 'item_num' => \services\FormulaService::Weapon_Advanced_CEC_Expend($nft1['quality']+1) -// ) + array( + 'item_id' => V_ITEM_DIAMOND, + 'item_num' => \services\FormulaService::Weapon_Advanced_CEC_Expend($nft1['quality']+1) + ) ); $lackItem = null; @@ -230,7 +239,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( @@ -250,7 +264,8 @@ class BlockChainController extends BaseAuthedController { 'tokenType' => Nft::EQUIP_TYPE, 'itemUniId' => $nft1['gun_uniid'], 'itemId' => $nft1['gun_id'] - ) + ), + $decFeeCb ); } break; @@ -410,7 +425,13 @@ 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->_decItems($costItems); } if ($tokenType == Nft::EQUIP_TYPE){ $costItems = array( @@ -424,7 +445,13 @@ 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->_decItems($costItems); } } @@ -463,9 +490,13 @@ class BlockChainController extends BaseAuthedController { 0, $itemId ); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addUserChg(); + $decFeeCb($transId); myself()->_rspData(array( 'trans_id' => $transId, - 'params' => $rspObj['params'] + 'params' => $rspObj['params'], + 'property_chg' => $propertyChgService->toDto(), )); error_log(5555555555); } else { @@ -594,9 +625,50 @@ class BlockChainController extends BaseAuthedController { myself()->_rspErr(101, 'token_id paramater error'); return; } -// //CEG扣除 + //CEG扣除 // { -// Chip::getChipByTokenId($chipIds); +// $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( @@ -660,6 +732,21 @@ class BlockChainController extends BaseAuthedController { } } + public function getJumpInfo(){ + $transId = getReqVal('trans_id', ''); + if (!$transId){ + myself()->_rspErr(101, 'trans_id paramater error'); + return; + } + $tranDb= Transaction::find($transId); + if (!$tranDb){ + myself()->_rspErr(101, 'trans_id paramater error'); + return; + } + $data = Transaction::getJumpInfo($tranDb); + myself()->_rspData($data); + } + private function internalActivate721Nft($tokenId, $tokenType, $itemUniId, $itemId) { $params = array( @@ -810,7 +897,9 @@ class BlockChainController extends BaseAuthedController { } } - private function internalBcCall($params, $transParams) { + private function internalBcCall($params, $transParams, $cb = null) { + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addUserChg(); $url = self::getWeb3ServiceUrl(); $response = ''; if (!phpcommon\HttpClient::get @@ -833,9 +922,13 @@ class BlockChainController extends BaseAuthedController { $transParams['itemUniId'], $transParams['itemId'] ); + if ($cb) { + $cb($transId); + } myself()->_rspData(array( 'trans_id' => $transId, - 'params' => $rspObj['params'] + 'params' => $rspObj['params'], + 'property_chg' => $propertyChgService->toDto(), )); } else { myself()->_rspErr(500, 'server internal error'); 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/controller/GunController.class.php b/webapp/controller/GunController.class.php index bfc81ac4..c4143bca 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -779,4 +779,23 @@ class GunController extends BaseAuthedController { )); } + public function getLastQualityInfo(){ + $tokenId = getReqVal('token_id', ''); + if (!$tokenId){ + $this->_rspErr(1, ' error param'); + return; + } + $gunDb = Gun::findByTokenId2($tokenId); + if(!$gunDb || $gunDb['quality']<2){ + $this->_rspErr(1, ' error param'); + return; + } + $oldGunDb = $gunDb; + $oldGunDb['quality'] -= 1; + $this->_rspData(array( + 'new_gun' =>Gun::toDto($gunDb), + 'old_gun'=>Gun::toDto($oldGunDb) + )); + } + } diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index b065694f..9f230d0b 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -915,4 +915,23 @@ class HeroController extends BaseAuthedController { 'old_hero'=>$oldHero )); } + + public function getLastQualityInfo(){ + $tokenId = getReqVal('token_id', ''); + if (!$tokenId){ + $this->_rspErr(1, ' error param'); + return; + } + $heroDb = Hero::findByTokenId2($tokenId); + if(!$heroDb || $heroDb['quality']<2){ + $this->_rspErr(1, ' error param'); + return; + } + $oldHeroDb = $heroDb; + $oldHeroDb['quality'] -= 1; + $this->_rspData(array( + 'new_hero' =>Hero::toDto($heroDb), + 'old_hero'=>Hero::toDto($oldHeroDb) + )); + } } diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index e451be51..4d6820ff 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -141,11 +141,48 @@ 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::belongsToWhere($row); + $row['belong_to_item_id'] = self::belongsToWhereOld($row); return $row; } 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(); diff --git a/webapp/models/Transaction.php b/webapp/models/Transaction.php index 10ab2234..0e9f1067 100644 --- a/webapp/models/Transaction.php +++ b/webapp/models/Transaction.php @@ -112,6 +112,179 @@ class Transaction extends BaseModel { } } + public static function getJumpInfo($transDb) + { + $jumpInfo = null; + switch ($transDb['action']) { + case self::MINT_721_ACTION_TYPE: + { + switch ($transDb['token_type']) { + case Nft::HERO_TYPE: + { + $jumpInfo = array( + 'action' => 1, //英雄激活(英雄详情) + 'params' => array( + $transDb['token_id'] + ) + ); + } + break; + case Nft::EQUIP_TYPE: + { + $jumpInfo = array( + 'action' => 2,//武器激活(武器详情) + 'params' => array( + $transDb['token_id'] + ) + ); + } + break; + } + + } + break; + case self::MINT_1155_ACTION_TYPE: + { + $jumpInfo = array( + 'action' => 3, //芯片生成(芯片列表) + 'params' => array( + $transDb['token_id'] + ) + ); + } + break; + case self::EVOLVE_721_ACTION_TYPE: + { + switch ($transDb['token_type']) { + case Nft::HERO_TYPE: + { + $jumpInfo = array( + 'action' => 4, //英雄升阶(英雄进阶界面) + 'params' => array( + $transDb['token_id'] + ) + ); + } + break; + case Nft::EQUIP_TYPE: + { + $jumpInfo = array( + 'action' => 5,//武器升阶(武器进阶界面) + 'params' => array( + $transDb['token_id'] + ) + ); + } + break; + } + } + break; + case self::EVOLVE_CHIP_ACTION_TYPE: + { + $jumpInfo = array( + 'action' => 6, //芯片进阶(芯片升级界面) + 'params' => array( + $transDb['token_id'] + ) + ); + } + break; + case self::MINT_SHARD_BATCH_ACTION_TYPE: + { + $jumpInfo = array( + 'action' => 7, //碎片生成(碎片列表) + 'params' => array( + $transDb['token_id'] + ) + ); + } + break; + case self::SHARD_MIX_BY_USER_ACTION_TYPE: + {//碎片合成 + switch ($transDb['token_type']) { + case Nft::HERO_TYPE: + { + $jumpInfo = array( + 'action' => 1, //英雄合成(英雄详情) + 'params' => array( + $transDb['token_id'] + ) + ); + } + break; + case Nft::EQUIP_TYPE: + { + $jumpInfo = array( + 'action' => 2,//武器合成(武器详情) + 'params' => array( + $transDb['token_id'] + ) + ); + } + break; + } + } + break; + case self::PLUGIN_CHIP_ACTION_TYPE: + { + switch ($transDb['token_type']) { + case Nft::HERO_TYPE: + { + $jumpInfo = array( + 'action' => 8, //英雄芯片镶嵌(目标英雄详情介面的Chip页签) + 'params' => array( + $transDb['token_id'] + ) + ); + } + break; + case Nft::EQUIP_TYPE: + { + $jumpInfo = array( + 'action' => 9,//武器芯片镶嵌(目标枪械详情介面的Chip页签) + 'params' => array( + $transDb['token_id'] + ) + ); + } + break; + } + } + break; + case self::UNPLUG_CHIP_ACTION_TYPE: + { + switch ($transDb['token_type']) { + case Nft::HERO_TYPE: + { + $jumpInfo = array( + 'action' => 8, //英雄芯片卸下(目标英雄详情介面的Chip页签) + 'params' => array( + $transDb['token_id'] + ) + ); + } + break; + case Nft::EQUIP_TYPE: + { + $jumpInfo = array( + 'action' => 9,//武器芯片卸下(目标枪械详情介面的Chip页签) + 'params' => array( + $transDb['token_id'] + ) + ); + } + break; + } + } + break; + default: + { + + } + } + return $jumpInfo; + } + public static function getStatusDesc($transDb) { switch ($transDb['status']) { diff --git a/webapp/models/TransactionPrefee.php b/webapp/models/TransactionPrefee.php new file mode 100644 index 00000000..ef87a44c --- /dev/null +++ b/webapp/models/TransactionPrefee.php @@ -0,0 +1,29 @@ +_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(), + ) + ); + } +} \ No newline at end of file