From 4d8abbc99714e7269cd4898582216389a1b8624c Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 24 Nov 2022 16:20:21 +0800 Subject: [PATCH] 1 --- .../controller/BlockChainController.class.php | 32 ++++++++++ .../controller/CallbackController.class.php | 60 ++++++++++++++++++- webapp/controller/GunController.class.php | 22 +++++-- webapp/controller/HeroController.class.php | 22 +++++-- 4 files changed, 126 insertions(+), 10 deletions(-) diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index c30d1a62..753d215a 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -199,6 +199,16 @@ class BlockChainController extends BaseAuthedController { }else{ $result = 1; } + error_log( + json_encode( + array( + 'NftEvent'=> 'Hero', + 'nft' => $nft1, + 'probability' => $probability, + 'result' => $result + ) + ) + ); $this->internalBcCall( array( 'c' => 'BcService', @@ -263,6 +273,16 @@ class BlockChainController extends BaseAuthedController { }else{ $result = 1; } + error_log( + json_encode( + array( + 'NftEvent'=> 'Gun', + 'nft' => $nft1, + 'probability' => $probability, + 'result' => $result + ) + ) + ); $this->internalBcCall( array( @@ -328,6 +348,18 @@ class BlockChainController extends BaseAuthedController { }else{ $result = 1; } + error_log( + json_encode( + array( + 'NftEvent'=> 'Chip', + 'nft' => $nftDb, + 'upgrade_cost' => $upgrade_cost, + 'cumulative_cost' => $cumulative_cost, + 'probability' => $probability, + 'result' => $result + ) + ) + ); $this->internalBcCall( array( diff --git a/webapp/controller/CallbackController.class.php b/webapp/controller/CallbackController.class.php index cd956d13..28849c4a 100644 --- a/webapp/controller/CallbackController.class.php +++ b/webapp/controller/CallbackController.class.php @@ -15,6 +15,7 @@ require_once('models/Gun.php'); require_once('models/Chip.php'); require_once('models/DynData.php'); require_once('models/NftUpReceive.php'); +require_once('models/Transaction.php'); require_once('phpcommon/bchelper.php'); @@ -29,6 +30,7 @@ use models\Gun; use models\Chip; use models\DynData; use models\NftUpReceive; +use models\Transaction; class CallbackController extends BaseController { private $accountId; @@ -158,10 +160,28 @@ class CallbackController extends BaseController { myself()->_rspErr(1, 'param error'); return; } + $tranDb= Transaction::find($transId); + if (!$tranDb){ + myself()->_rspErr(1, 'param error'); + return; + } if (NftUpEvent::find($this->accountId,$transId)){ myself()->_rspOk(); return; } + if (! $tranDb['result']){ + NftUpEvent::add($this->accountId, + array( + 'trans_id' => $transId, + 'token_id' => $tokenId1, + 'value' => 1, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + myself()->_rspOk(); + return; + } $heroDb = SqlHelper::ormSelectOne( myself()->_getMysql($this->accountId), 't_hero', @@ -222,8 +242,6 @@ class CallbackController extends BaseController { myself()->_rspOk(); } - - public function gunUpgradeQuality(){ $transId = getReqVal('trans_id', '0'); $tokenId1 = getReqVal('token_id1', '0'); @@ -232,10 +250,28 @@ class CallbackController extends BaseController { myself()->_rspErr(1, 'param error'); return; } + $tranDb= Transaction::find($transId); + if (!$tranDb){ + myself()->_rspErr(1, 'param error'); + return; + } if (NftUpEvent::find($this->accountId,$transId)){ myself()->_rspOk(); return; } + if (! $tranDb['result']){ + NftUpEvent::add($this->accountId, + array( + 'trans_id' => $transId, + 'token_id' => $tokenId1, + 'value' => 1, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + myself()->_rspOk(); + return; + } $gunDb =SqlHelper::ormSelectOne( myself()->_getMysql($this->accountId), 't_gun', @@ -300,10 +336,30 @@ class CallbackController extends BaseController { myself()->_rspErr(1, 'param error'); return; } + + $tranDb= Transaction::find($transId); + if (!$tranDb){ + myself()->_rspErr(1, 'param error'); + return; + } if (NftUpEvent::find($this->accountId,$transId)){ myself()->_rspOk(); return; } + if (! $tranDb['result']){ + NftUpEvent::add($this->accountId, + array( + 'trans_id' => $transId, + 'token_id' => $tokenId, + 'value' => 1, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + myself()->_rspOk(); + return; + } + $chipDb = SqlHelper::ormSelectOne( myself()->_getMysql($this->accountId), 't_chip', diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index b100b9ed..461394d7 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -12,6 +12,7 @@ require_once('models/Gun.php'); require_once('models/Bag.php'); require_once('models/Chip.php'); require_once('models/NftUpReceive.php'); +require_once('models/Transaction.php'); require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); @@ -26,6 +27,7 @@ use models\Gun; use models\Bag; use models\Chip; use models\NftUpReceive; +use models\Transaction; use services\LogService; class GunController extends BaseAuthedController { @@ -730,6 +732,11 @@ class GunController extends BaseAuthedController { $this->_rspErr(1, ' error param'); return; } + $tranDb= Transaction::find($transId); + if (!$tranDb){ + myself()->_rspErr(1, 'param error'); + return; + } Gun::updateByTokenId($tokenId, array( 'lock_type' => Gun::NO_LOCK, @@ -737,16 +744,23 @@ class GunController extends BaseAuthedController { ) ); $newGunDb = Gun::findByTokenId2($tokenId); - $newGun = Gun::toDto($newGunDb); - $newGunDb['quality'] -= 1; - $oldGun = Gun::toDto($newGunDb); + if (! $tranDb['result']){ + $newGun = Gun::toDto($newGunDb); + $oldGun = $newGun; + }else{ + $newGun = Gun::toDto($newGunDb); + $newGunDb['quality'] -= 1; + $oldGun = Gun::toDto($newGunDb); + } + NftUpReceive::setAccountIdNull(myself()->_getAccountId(),$transId); $propertyChgService = new services\PropertyChgService(); $propertyChgService->addGunChg(); $this->_rspData(array( 'property_chg' => $propertyChgService->toDto(), 'new_gun' =>$newGun, - 'old_gun'=>$oldGun + 'old_gun'=>$oldGun, + 'result'=>$tranDb['result'] )); } diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index d1616288..10a8a775 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -16,6 +16,7 @@ require_once('models/Bag.php'); require_once('models/HeroSkin.php'); require_once('models/Chip.php'); require_once('models/NftUpReceive.php'); +require_once('models/Transaction.php'); require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); @@ -30,6 +31,7 @@ use models\Bag; use models\HeroSkin; use models\Chip; use models\NftUpReceive; +use models\Transaction; use services\LogService; class HeroController extends BaseAuthedController { @@ -893,6 +895,11 @@ class HeroController extends BaseAuthedController { $this->_rspErr(1, ' error param'); return; } + $tranDb= Transaction::find($transId); + if (!$tranDb){ + myself()->_rspErr(1, 'param error'); + return; + } Hero::updateByTokenId($tokenId, array( 'lock_type' => Hero::NO_LOCK, @@ -900,9 +907,15 @@ class HeroController extends BaseAuthedController { ) ); $newHeroDb = Hero::findByTokenId2($tokenId); - $newHero = Hero::toDto($newHeroDb); - $newHeroDb['quality'] -= 1; - $oldHero = Hero::toDto($newHeroDb); + if (! $tranDb['result']){ + $newHero = Hero::toDto($newHeroDb); + $oldHero = $newHero; + }else{ + $newHero = Hero::toDto($newHeroDb); + $newHeroDb['quality'] -= 1; + $oldHero = Hero::toDto($newHeroDb); + } + NftUpReceive::setAccountIdNull(myself()->_getAccountId(),$transId); $propertyChgService = new services\PropertyChgService(); @@ -910,7 +923,8 @@ class HeroController extends BaseAuthedController { $this->_rspData(array( 'property_chg' => $propertyChgService->toDto(), 'new_hero' =>$newHero, - 'old_hero'=>$oldHero + 'old_hero'=>$oldHero, + 'result'=>$tranDb['result'] )); }