diff --git a/webapp/services/BattleDataService.php b/webapp/services/BattleDataService.php index 1cb8f95f..d325f814 100644 --- a/webapp/services/BattleDataService.php +++ b/webapp/services/BattleDataService.php @@ -851,14 +851,16 @@ class BattleDataService extends BaseService { ))); $gold = $heroPvpCeg + $weaponPvpCeg1 + $weaponPvpCeg2; if ($heroPvpCeg>0){ - $this->_addNftActive($this->heroDto,1); +// $this->_addNftActive($this->heroDto,1); + NftService::addNftActive($this->heroDto,1); } if ($weaponPvpCeg1>0){ - $this->_addNftActive($this->weapon1Dto,2); +// $this->_addNftActive($this->weapon1Dto,2); + NftService::addNftActive($this->weapon1Dto,2); } if ($weaponPvpCeg2>0){ - - $this->_addNftActive($this->weapon2Dto,2); +// $this->_addNftActive($this->weapon2Dto,2); + NftService::addNftActive($this->weapon2Dto,2); } if ($gold > 0) { myself()->_addVirtualItem(V_ITEM_GOLD, $gold); @@ -1017,14 +1019,16 @@ class BattleDataService extends BaseService { ))); $gold = $heroPveCeg + $weaponPveCeg1 + $weaponPveCeg2; if ($heroPveCeg>0){ - $this->_addNftActive($this->heroDto,1); +// $this->_addNftActive($this->heroDto,1); + NftService::addNftActive($this->heroDto,1); } if ($weaponPveCeg1>0){ - $this->_addNftActive($this->weapon1Dto,2); +// $this->_addNftActive($this->weapon1Dto,2); + NftService::addNftActive($this->weapon1Dto,2); } if ($weaponPveCeg2>0){ - - $this->_addNftActive($this->weapon2Dto,2); +// $this->_addNftActive($this->weapon2Dto,2); + NftService::addNftActive($this->weapon2Dto,2); } if ($gold > 0) { myself()->_addVirtualItem(V_ITEM_GOLD, $gold); diff --git a/webapp/services/MissionService.php b/webapp/services/MissionService.php index 66e01dde..28d5c416 100644 --- a/webapp/services/MissionService.php +++ b/webapp/services/MissionService.php @@ -988,6 +988,13 @@ class MissionService extends BaseService { myself()->_addVirtualItem(V_ITEM_GOLD, round($ceg,2)); $awardService->addItem(V_ITEM_GOLD, round($ceg,2)); } + + if ($totalHeroUpLimit>0){ + NftService::addNftActive($heroDto,1); + } + if ($totalGunUpLimit>0){ + NftService::addNftActive($gunDto,2); + } $this->updateOfferRewardMission($missionId); $this->saveOfferRewardMission(); } diff --git a/webapp/services/NftService.php b/webapp/services/NftService.php index 223e4b01..539dc1f9 100644 --- a/webapp/services/NftService.php +++ b/webapp/services/NftService.php @@ -2,12 +2,16 @@ namespace services; +require_once('models/Chip.php'); require_once('models/Nft.php'); +require_once('models/NftActive.php'); require_once('mt/Item.php'); -use phpcommon\SqlHelper; +use models\Chip; +use models\NftActive; use models\Nft; use mt\Item; +use phpcommon\SqlHelper; class NftService extends BaseService { @@ -85,33 +89,66 @@ class NftService extends BaseService { } } -// public static function addNft($itemId,$token_id){ -// $itemMeta = Item::get($itemId); -// if ($itemMeta) { -// $tokenType = Nft::getTokenType($itemMeta); -// if ($tokenType == Nft::NONE_TYPE) { -// myself()->_rspErr(1, 'param item_id error'); -// return false; -// } else { -// SqlHelper::insert( -// myself()->_getMarketMysql(), -// 't_nft', -// array( -// 'token_id' => $token_id, -// 'token_type' => $tokenType, -// 'game_id' => 2006, -// 'item_id' => $itemId, -// 'owner_address' => myself()->_getOpenId(), -// 'createtime' => myself()->_getNowTime(), -// 'modifytime' => myself()->_getNowTime(), -// ) -// ); -// return true; -// } -// } else { -// myself()->_rspErr(1, 'param item_id error'); -// return false; -// } -// } + public static function addNftActive($nftDb,$type){ + if (!$nftDb){ + return ; + } + switch ($type){ + case Nft::HERO_TYPE: + { + $data = array( + 'uniid' => $nftDb['hero_uniid'], + 'token_id' => $nftDb['token_id'], + 'token_type' => Nft::HERO_TYPE, + ); + NftActive::upsert($data); + if ($nftDb['chip_ids']){ + $chip_ids = explode("|",$nftDb['chip_ids']); + if (count($chip_ids)>0){ + foreach ($chip_ids as $chip_id){ + $chipDb = Chip::getChipByIdx($chip_id); + self::addNftActive($chipDb,Nft::CHIP_TYPE); + } + } + } + } + break; + case Nft::EQUIP_TYPE: + { + $data = array( + 'uniid' => $nftDb['gun_uniid'], + 'token_id' => $nftDb['token_id'], + 'token_type' => Nft::EQUIP_TYPE, + ); + NftActive::upsert($data); + if ($nftDb['chip_ids']){ + $chip_ids = explode("|",$nftDb['chip_ids']); + if (count($chip_ids)>0){ + foreach ($chip_ids as $chip_id){ + $chipDb = Chip::getChipByIdx($chip_id); + self::addNftActive($chipDb,Nft::CHIP_TYPE); + } + } + } + } + break; + case Nft::CHIP_TYPE: + { + $data = array( + 'uniid' => $nftDb['idx'], + 'token_id' => $nftDb['token_id'], + 'token_type' => Nft::CHIP_TYPE, + ); + NftActive::upsert($data); + } + break; + default: + { + + } + } + } + + }