From 296f5b45b255791d928f80ef1328a48122f068a4 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 9 Nov 2022 14:38:06 +0800 Subject: [PATCH 01/12] 1 --- webapp/models/Gun.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index 91b69ad1..ba0d80a1 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -261,9 +261,6 @@ class Gun extends BaseModel { $dto['pvp_ceg_uplimit'] = strval( round(FormulaService::getWeaponPvpDailyCegUpLimit($dto),2) ); $dto['pve_ceg_uplimit'] = strval( round(FormulaService::getWeaponPveDailyCegUpLimit($dto),2) ); $dto['mission_ceg_uplimit'] = strval( round(FormulaService::getWeaponMissionDailyCegUpLimit($dto),2) ); - error_log(json_encode(array( - 'data____info'=>$dto - ))) ; return $dto; } From db02106d8198ea8667f93a10b9b580fa84402d95 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 9 Nov 2022 17:32:44 +0800 Subject: [PATCH 02/12] HeroUpgradeQuality --- doc/Hero.py | 29 +++++ doc/_common.py | 6 +- sql/gamedb.sql | 20 ++++ .../controller/CallbackController.class.php | 29 +++-- webapp/controller/HeroController.class.php | 112 +++++++++++++++--- webapp/models/Hero.php | 22 +++- webapp/models/NftUpReceive.php | 81 +++++++++++++ 7 files changed, 268 insertions(+), 31 deletions(-) create mode 100644 webapp/models/NftUpReceive.php diff --git a/doc/Hero.py b/doc/Hero.py index 490807a9..8df64e77 100644 --- a/doc/Hero.py +++ b/doc/Hero.py @@ -111,6 +111,35 @@ class Hero(object): 'desc': '升阶', 'group': 'Hero', 'url': 'webapp/index.php?c=Hero&a=upgradeQuality', + 'params': [ + _common.ReqHead(), + ['trans_id', 0, 'transId'], + ['token_id1', 0, '英雄token'], + ['token_id2', 0, '耗材英雄token'], + ], + 'response': [ + _common.RspHead(), + ] + }, + { + 'name': 'receiveUpgradeQuality', + 'desc': '领取升阶', + 'group': 'Hero', + 'url': 'webapp/index.php?c=Hero&a=receiveUpgradeQuality', + 'params': [ + _common.ReqHead(), + ['trans_id', 0, 'transId'], + ['token_id', 0, '英雄token'], + ], + 'response': [ + _common.RspHead(), + ] + }, + { + 'name': 'upgradeQualityOld', + 'desc': '升阶', + 'group': 'Hero', + 'url': 'webapp/index.php?c=Hero&a=upgradeQualityOld', 'params': [ _common.ReqHead(), ['hero_uniid', 0, '英雄唯一id'], diff --git a/doc/_common.py b/doc/_common.py index e9ee62ae..a407aaf0 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -278,8 +278,10 @@ class QualityingHero(object): def __init__(self): self.fields = [ - ['info', Hero(), '英雄信息'], - ['countdown', 0, '倒计时'], + ['trans_id', 0, 'transId'], + ['state', 0, '0升阶中,1可领取'], + ['heroInfo', Hero(), '升阶英雄信息'], + ['costHeroInfo', Hero(), '材料英雄信息'], ] class HeroSkin(object): diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 6b0aebc0..0ce8a7bb 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -832,3 +832,23 @@ CREATE TABLE `t_nft_up_event` ( UNIQUE KEY `trans_id` (`trans_id`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; + + +DROP TABLE IF EXISTS `t_nft_up_receive`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_nft_up_receive` ( + `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', + `token_id1` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id1', + `token_id2` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id2', + `state` int(11) NOT NULL DEFAULT '0' COMMENT '0进阶中,1可领取', + `token_type` int(11) NOT NULL DEFAULT '0' COMMENT '1英雄,2枪械', + `from_data` int(11) NOT NULL DEFAULT '0' COMMENT '0本地,1链', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `trans_id` (`trans_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; diff --git a/webapp/controller/CallbackController.class.php b/webapp/controller/CallbackController.class.php index f790640e..9e919730 100644 --- a/webapp/controller/CallbackController.class.php +++ b/webapp/controller/CallbackController.class.php @@ -14,6 +14,7 @@ require_once('models/Hero.php'); require_once('models/Gun.php'); require_once('models/Chip.php'); require_once('models/DynData.php'); +require_once('models/NftUpReceive.php'); require_once('phpcommon/bchelper.php'); @@ -27,6 +28,7 @@ use models\Hero; use models\Gun; use models\Chip; use models\DynData; +use models\NftUpReceive; class CallbackController extends BaseController { private $accountId; @@ -150,8 +152,9 @@ class CallbackController extends BaseController { public function heroUpgradeQuality(){ $transId = getReqVal('trans_id', '0'); - $tokenId = getReqVal('token_id', '0'); - if (!$transId || !$tokenId){ + $tokenId1 = getReqVal('token_id1', '0'); + $tokenId2 = getReqVal('token_id2', '0'); + if (!$transId || !$tokenId1){ myself()->_rspErr(1, 'param error'); return; } @@ -163,7 +166,7 @@ class CallbackController extends BaseController { myself()->_getMysql($this->accountId), 't_hero', array( - 'token_id' => $tokenId, + 'token_id' => $tokenId1, ) ); if ( !$heroDb ){ @@ -172,7 +175,7 @@ class CallbackController extends BaseController { } $nextQualityMeta = mt\HeroQuality::getByQuality($heroDb['quality']+1); if (! $nextQualityMeta){ - $this->_rspErr(1, 'quality is full'); + myself()->_rspOk(); return; } @@ -184,27 +187,35 @@ class CallbackController extends BaseController { ( myself()->_getMysql($this->accountId), 't_hero', array( - 'token_id' => $tokenId, + 'token_id' => $tokenId1, ), array( 'hero_tili' => $heroDb['hero_tili']+($nextHeroTili-$heroTili), 'skill_points' => $heroDb['skill_points'] + $nextQualityMeta['skill_point'], 'quality' => $heroDb['quality']+1, 'advanced_count' => $heroDb['advanced_count'] + 1, - 'lock_type' => 0, - 'unlock_time' => 0, +// 'lock_type' => 0, +// 'unlock_time' => 0, 'labour' => 0, ) ); NftUpEvent::add($this->accountId, array( 'trans_id' => $transId, - 'token_id' => $tokenId, + 'token_id' => $tokenId1, 'value' => 1, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), ) ); + $param = array( + 'trans_id'=>$transId, + 'token_id1'=>$tokenId1, + 'token_id2'=>$tokenId2, + 'token_type'=>1, + ); + NftUpReceive::upsert($this->accountId,$param); + if ($heroDb['quality'] + 1 > $this->_getDynDataV(TN_HERO_MAX_QUALITY, 0)) { $this->_setDynDataV(TN_HERO_MAX_QUALITY, 0, $heroDb['quality'] + 1); } @@ -237,7 +248,7 @@ class CallbackController extends BaseController { } $nextQualityMeta = mt\GunQuality::getByQuality($gunDb['quality']+1); if (!$nextQualityMeta) { - $this->_rspErr(1, 'quality is full'); + myself()->_rspOk(); return; } $gunLucky = \services\FormulaService::Weapon_Advanced_Lucky_Value($gunDb['quality']); diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 61cf192f..af739469 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -15,6 +15,7 @@ require_once('models/Hero.php'); require_once('models/Bag.php'); require_once('models/HeroSkin.php'); require_once('models/Chip.php'); +require_once('models/NftUpReceive.php'); require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); @@ -28,6 +29,7 @@ use models\Hero; use models\Bag; use models\HeroSkin; use models\Chip; +use models\NftUpReceive; use services\LogService; class HeroController extends BaseAuthedController { @@ -205,22 +207,46 @@ class HeroController extends BaseAuthedController { public function getUpgradeQualityList() { - $infos = array(); - for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) { - $heroUniId = $this->_getV(TN_HERO_QUALITY_UP, $i); - $info = null; - if ($heroUniId) { - $heroDb = Hero::find($heroUniId); - if ($heroDb) { - $heroDto = Hero::toDto($heroDb); - $info = array( - 'info' => $heroDto, - 'countdown' => $heroDto['unlock_lefttime'] - ); +// $infos = array(); +// for ($i = 0; $i < kMaxHeroUpQualityNum; ++$i) { +// $heroUniId = $this->_getV(TN_HERO_QUALITY_UP, $i); +// $info = null; +// if ($heroUniId) { +// $heroDb = Hero::find($heroUniId); +// if ($heroDb) { +// $heroDto = Hero::toDto($heroDb); +// $info = array( +// 'info' => $heroDto, +// 'countdown' => $heroDto['unlock_lefttime'] +// ); +// } +// } +// array_push($infos, $info); +// } +// $this->_rspData(array( +// 'infos' => $infos +// )); + $list = NftUpReceive::all(myself()->_getAccountId(),1); + $infos = array(); + foreach ($list as $value){ + if ($this->_getNowTime() - $value['createtime'] < 24*3600 && !$value['from_data']){ + $hero = Hero::findByTokenId2($value['token_id1']); + $costHero = Hero::findByTokenId2($value['token_id2']); + $heroDto = null; + $costHeroDto = null; + if ($hero && $costHero){ + $heroDto = Hero::toDto($hero); + $costHeroDto = Hero::toDto($costHero); } + $info = array( + 'trans_id'=>$value['trans_id'], + 'state'=>$value['state'], + 'heroInfo'=>$heroDto, + 'costHeroInfo'=>$costHeroDto, + ); + array_push($infos,$info); } - array_push($infos, $info); - } + } $this->_rspData(array( 'infos' => $infos )); @@ -617,7 +643,7 @@ class HeroController extends BaseAuthedController { )); } - public function upgradeQuality() + public function upgradeQualityOld() { $costHeroUniId = getReqVal('cost_hero_uniid', 0); $heroUniId = getReqVal('hero_uniid', 0); @@ -821,5 +847,61 @@ class HeroController extends BaseAuthedController { } + public function upgradeQuality(){ + $tokenId1 = getReqVal('token_id1', ''); + $tokenId2 = getReqVal('token_id2', ''); + $transId = getReqVal('trans_id', ''); + if (!$tokenId1 || !$tokenId2 || !$transId){ + $this->_rspErr(1, ' error param'); + return; + } + if (NftUpReceive::find(myself()->_getAccountId(),$transId)){ + $this->_rspErr(1, ' error param trans_id '); + return; + } + Hero::updateByTokenId($tokenId1, + array( + 'lock_type' => Hero::QUALITY_LOCK, + 'unlock_time' => $this->_getNowTime() + 3600 * 24, + ) + ); + Hero::updateByTokenId($tokenId2, + array( + 'lock_type' => Hero::COST_LOCK, + 'unlock_time' => $this->_getNowTime() + 3600 * 24, + ) + ); + NftUpReceive::add( + myself()->_getAccountId(), + array( + 'account_id' => myself()->_getAccountId(), + 'trans_id' => $transId, + 'token_id1' => $tokenId1, + 'token_id2' => $tokenId2, + 'state' => 0, + 'token_type' => 1, + 'from_data' => 0, + 'createtime' => $this->_getNowTime(), + 'modifytime' => $this->_getNowTime() + ) + ); + myself()->_rspOk(); + } + public function receiveUpgradeQuality(){ + $transId = getReqVal('trans_id', ''); + $tokenId = getReqVal('token_id', ''); + if (!$tokenId || !$transId){ + $this->_rspErr(1, ' error param'); + return; + } + Hero::updateByTokenId($tokenId, + array( + 'lock_type' => Hero::NO_LOCK, + 'unlock_time' => 0, + ) + ); + NftUpReceive::setAccountIdNull(myself()->_getAccountId(),$transId); + myself()->_rspOk(); + } } diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index b0c65b37..af360733 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -63,6 +63,18 @@ class Hero extends BaseModel { return $row; } + public static function findByTokenId2($tokenId) + { + $row = SqlHelper::ormSelectOne( + myself()->_getMysql($tokenId), + 't_hero', + array( + 'token_id' => $tokenId, + ) + ); + return $row; + } + private static function internalFind($accountId, $heroUniId) { $row = SqlHelper::ormSelectOne( @@ -174,14 +186,14 @@ class Hero extends BaseModel { $lockType = 0; $unlockTime = 0; - /*if ($row['lock_type'] != 0 && $row['unlock_time'] - myself()->_getNowTime() > 0) { - $lockType = $row['lock_type']; - $unlockTime = $row['unlock_time']; - }*/ - { + if ($row['lock_type'] != 0 && $row['unlock_time'] - myself()->_getNowTime() > 0) { $lockType = $row['lock_type']; $unlockTime = $row['unlock_time']; } +// { +// $lockType = $row['lock_type']; +// $unlockTime = $row['unlock_time']; +// } $qualityMeta = mt\HeroQuality::getByQuality($row['quality']); $todayGetGold = $row['today_get_gold']; diff --git a/webapp/models/NftUpReceive.php b/webapp/models/NftUpReceive.php new file mode 100644 index 00000000..a7478d0c --- /dev/null +++ b/webapp/models/NftUpReceive.php @@ -0,0 +1,81 @@ +_getMysql($accountId), + 't_nft_up_receive', + array( + 'trans_id' => $transId, + ) + ); + return $row; + } + + public static function add($accountId,$fieldKv){ + return SqlHelper::insert( + myself()->_getMysql($accountId), + 't_nft_up_receive', + $fieldKv + ); + } + + public static function all($accountId,$tokenType) + { + $row = SqlHelper::ormSelect( + myself()->_getMysql($accountId), + 't_nft_up_receive', + array( + 'account_id' => $accountId, + 'token_type' => $tokenType, + ) + ); + return $row; + } + + public static function upsert($accountId,$data){ + SqlHelper::upsert( + myself()->_getMysql($accountId), + 't_nft_up_receive', + array( + 'trans_id' => $data['trans_id'] + ), + array( + 'state' => 1, + 'modifytime' => myself()->_getNowTime() + ), + array( + 'account_id' => $accountId, + 'trans_id' => $data['trans_id'], + 'token_id1' => $data['token_id1'], + 'token_id2' => $data['token_id2'], + 'state' => 0, + 'token_type' => $data['token_type'], + 'from_data' => 1, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ) + ); + } + + public static function setAccountIdNull($accountId,$transId){ + SqlHelper::update( + myself()->_getMysql($accountId), + 't_nft_up_receive', + array( + 'trans_id' => $transId, + ), + array( + 'account_id' => '', + ) + ); + } + +} \ No newline at end of file From 0d6e944fc3363a81a1ecb577308d32f9e36e5bd8 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 9 Nov 2022 17:56:05 +0800 Subject: [PATCH 03/12] 1 --- webapp/controller/ShopController.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index c0d4a031..af5436dd 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -11,6 +11,7 @@ require_once('models/User.php'); require_once('models/Hero.php'); require_once('models/Bag.php'); require_once('models/HeroSkin.php'); +require_once('models/Gun.php'); require_once('models/GunSkin.php'); require_once('models/ShopBuyRecord.php'); @@ -22,6 +23,7 @@ use models\User; use models\Bag; use models\Hero; use models\HeroSkin; +use models\Gun; use models\GunSkin; use models\ShopBuyRecord; @@ -668,6 +670,12 @@ class ShopController extends BaseAuthedController { $propertyChgService->addHeroSkinChg(); } break; + case mt\Item::GUN_TYPE: + { + Gun::addGun($itemMeta); + $propertyChgService->addGunChg(); + } + break; case mt\Item::GUN_SKIN_TYPE: { GunSkin::addSkin($itemMeta); From 982dc1a683b29e2d928a7b7e67c36e0a0a44923a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Nov 2022 17:59:57 +0800 Subject: [PATCH 04/12] 1 --- webapp/controller/BaseController.class.php | 6 ++++++ webapp/controller/BlockChainController.class.php | 14 -------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/webapp/controller/BaseController.class.php b/webapp/controller/BaseController.class.php index 45de9f05..e32c6748 100644 --- a/webapp/controller/BaseController.class.php +++ b/webapp/controller/BaseController.class.php @@ -58,6 +58,12 @@ class BaseController { public function _rspErr($errcode, $errmsg) { + if (SERVER_ENV != _ONLINE) { + error_log(json_encode(array( + 'errcode' => $errcode, + 'errmsg' => $errmsg, + ))); + } echo json_encode(array( 'errcode' => $errcode, 'errmsg' => $errmsg, diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index 49bf3bd0..e94842e6 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -519,13 +519,6 @@ class BlockChainController extends BaseAuthedController { case 1: { $heroDb = Hero::findByTokenId($tokenId); - foreach ($chipIds as $chipId) { - $chipDb = Chip::findByTokenId($chipId); - if (!$chipDb) { - myself()->_rspErr(101, 'chip_ids paramater error'); - return; - } - } if (!$heroDb) { myself()->_rspErr(101, 'token_id paramater error'); return; @@ -557,13 +550,6 @@ class BlockChainController extends BaseAuthedController { case 2: { $gunDb = Gun::findByTokenId($tokenId); - foreach ($chipIds as $chipId) { - $chipDb = Chip::findByTokenId($chipId); - if (!$chipDb) { - myself()->_rspErr(101, 'chip_ids paramater error'); - return; - } - } if (!$gunDb) { myself()->_rspErr(101, 'token_id paramater error'); return; From c9d93ac20d685eaea3c8e57fd996b0274136a792 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 9 Nov 2022 19:35:05 +0800 Subject: [PATCH 05/12] GunUpgradeQuality --- doc/Gun.py | 47 +++++++++- doc/Hero.py | 1 + doc/_common.py | 10 ++ .../controller/CallbackController.class.php | 22 +++-- webapp/controller/GunController.class.php | 93 ++++++++++++++++++- webapp/controller/HeroController.class.php | 8 +- webapp/models/Gun.php | 12 +++ webapp/models/NftUpReceive.php | 2 +- 8 files changed, 182 insertions(+), 13 deletions(-) diff --git a/doc/Gun.py b/doc/Gun.py index 913af50e..1bd057d5 100644 --- a/doc/Gun.py +++ b/doc/Gun.py @@ -91,10 +91,10 @@ class Gun(object): ] }, { - 'name': 'upgradeQuality', + 'name': 'upgradeQualityOld', 'desc': '升阶', 'group': 'Gun', - 'url': 'webapp/index.php?c=Gun&a=upgradeQuality', + 'url': 'webapp/index.php?c=Gun&a=upgradeQualityOld', 'params': [ _common.ReqHead(), ['gun_uniid', 0, '枪械唯一id'], @@ -106,6 +106,21 @@ class Gun(object): ['property_chg', _common.PropertyChg(), '属性变更'], ] }, + { + 'name': 'upgradeQuality', + 'desc': '升阶', + 'group': 'Gun', + 'url': 'webapp/index.php?c=Gun&a=upgradeQuality', + 'params': [ + _common.ReqHead(), + ['trans_id', 0, 'transId'], + ['token_id1', 0, '枪械token'], + ['token_id2', 0, '耗材枪械token'], + ], + 'response': [ + _common.RspHead(), + ] + }, { 'name': 'upgradeQualityPreview', 'desc': '升阶', @@ -123,6 +138,21 @@ class Gun(object): ['cost', _common.Cost(), '所需费用'], ] }, + { + 'name': 'receiveUpgradeQuality', + 'desc': '获取升阶后的武器', + 'group': 'Gun', + 'url': 'webapp/index.php?c=Gun&a=receiveUpgradeQuality', + 'params': [ + _common.ReqHead(), + ['trans_id', 0, 'transId'], + ['token_id', 0, '枪械token'], + ], + 'response': [ + _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], + ] + }, { 'name': 'receive', 'desc': '获取升级、升阶后的武器', @@ -154,4 +184,17 @@ class Gun(object): ['!data', [_common.Gun()], '枪械信息'] ] }, + { + 'name': 'getUpgradeQualityList', + 'desc': '获取升阶中的枪械列表', + 'group': 'Hero', + 'url': 'webapp/index.php?c=Hero&a=getUpgradeQualityList', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['!infos', [_common.QualityingGun()], '升阶中的枪械列表'], + ] + }, ] diff --git a/doc/Hero.py b/doc/Hero.py index 8df64e77..05d6cc02 100644 --- a/doc/Hero.py +++ b/doc/Hero.py @@ -133,6 +133,7 @@ class Hero(object): ], 'response': [ _common.RspHead(), + ['property_chg', _common.PropertyChg(), '属性变更'], ] }, { diff --git a/doc/_common.py b/doc/_common.py index a407aaf0..52f5f1be 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -284,6 +284,16 @@ class QualityingHero(object): ['costHeroInfo', Hero(), '材料英雄信息'], ] +class QualityingGun(object): + + def __init__(self): + self.fields = [ + ['trans_id', 0, 'transId'], + ['state', 0, '0升阶中,1可领取'], + ['gunInfo', Gun(), '升阶枪械信息'], + ['costGunInfo', Gun(), '材料枪械信息'], + ] + class HeroSkin(object): def __init__(self): diff --git a/webapp/controller/CallbackController.class.php b/webapp/controller/CallbackController.class.php index 9e919730..cd956d13 100644 --- a/webapp/controller/CallbackController.class.php +++ b/webapp/controller/CallbackController.class.php @@ -226,8 +226,9 @@ class CallbackController extends BaseController { public function gunUpgradeQuality(){ $transId = getReqVal('trans_id', '0'); - $tokenId = getReqVal('token_id', '0'); - if (!$transId || !$tokenId){ + $tokenId1 = getReqVal('token_id1', '0'); + $tokenId2 = getReqVal('token_id2', '0'); + if (!$transId || !$tokenId1){ myself()->_rspErr(1, 'param error'); return; } @@ -239,7 +240,7 @@ class CallbackController extends BaseController { myself()->_getMysql($this->accountId), 't_gun', array( - 'token_id' => $tokenId, + 'token_id' => $tokenId1, ) ); if ( !$gunDb ){ @@ -260,25 +261,32 @@ class CallbackController extends BaseController { (myself()->_getMysql($this->accountId), 't_gun', array( - 'token_id' => $tokenId, + 'token_id' => $tokenId1, ), array( 'durability' => $gunDb['durability']+($nextDurability-$durability), 'quality' => $gunDb['quality']+1, - 'lock_type' => 0, - 'unlock_time' => 0, +// 'lock_type' => 0, +// 'unlock_time' => 0, 'labour' => 0, ) ); NftUpEvent::add($this->accountId, array( 'trans_id' => $transId, - 'token_id' => $tokenId, + 'token_id' => $tokenId1, 'value' => 1, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), ) ); + $param = array( + 'trans_id'=>$transId, + 'token_id1'=>$tokenId1, + 'token_id2'=>$tokenId2, + 'token_type'=>2, + ); + NftUpReceive::upsert($this->accountId,$param); if ($gunDb['quality'] + 1 > $this->_getDynDataV(TN_GUN_MAX_QUALITY, 0)) { $this->_setDynDataV(TN_GUN_MAX_QUALITY, 0, $gunDb['quality'] + 1); } diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index 1ae80a76..b12ebeec 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -11,6 +11,7 @@ require_once('models/User.php'); require_once('models/Gun.php'); require_once('models/Bag.php'); require_once('models/Chip.php'); +require_once('models/NftUpReceive.php'); require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); @@ -24,6 +25,7 @@ use models\User; use models\Gun; use models\Bag; use models\Chip; +use models\NftUpReceive; use services\LogService; class GunController extends BaseAuthedController { @@ -267,7 +269,7 @@ class GunController extends BaseAuthedController { )); } - public function upgradeQuality() + public function upgradeQualityOld() { $costGunUniId = getReqVal('cost_gun_uniid', 0); $gunUniId = getReqVal('gun_uniid', 0); @@ -464,6 +466,47 @@ class GunController extends BaseAuthedController { )); } + public function upgradeQuality(){ + $tokenId1 = getReqVal('token_id1', ''); + $tokenId2 = getReqVal('token_id2', ''); + $transId = getReqVal('trans_id', ''); + if (!$tokenId1 || !$tokenId2 || !$transId){ + $this->_rspErr(1, ' error param'); + return; + } + if (NftUpReceive::find(myself()->_getAccountId(),$transId)){ + $this->_rspErr(1, ' error param trans_id '); + return; + } + Gun::updateByTokenId($tokenId1, + array( + 'lock_type' => Gun::QUALITY_LOCK, + 'unlock_time' => $this->_getNowTime() + 20, + ) + ); + Gun::updateByTokenId($tokenId2, + array( + 'lock_type' => Gun::COST_LOCK, + 'unlock_time' => $this->_getNowTime() + 20, + ) + ); + NftUpReceive::add( + myself()->_getAccountId(), + array( + 'account_id' => myself()->_getAccountId(), + 'trans_id' => $transId, + 'token_id1' => $tokenId1, + 'token_id2' => $tokenId2, + 'state' => 0, + 'token_type' => 2, + 'from_data' => 0, + 'createtime' => $this->_getNowTime(), + 'modifytime' => $this->_getNowTime() + ) + ); + myself()->_rspOk(); + } + public function receive(){ $type = getReqVal('type', 0); @@ -682,4 +725,52 @@ class GunController extends BaseAuthedController { } + public function receiveUpgradeQuality(){ + $transId = getReqVal('trans_id', ''); + $tokenId = getReqVal('token_id', ''); + if (!$tokenId || !$transId){ + $this->_rspErr(1, ' error param'); + return; + } + Gun::updateByTokenId($tokenId, + array( + 'lock_type' => Gun::NO_LOCK, + 'unlock_time' => 0, + ) + ); + NftUpReceive::setAccountIdNull(myself()->_getAccountId(),$transId); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addGunChg(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + )); + } + + public function getUpgradeQualityList(){ + $list = NftUpReceive::all(myself()->_getAccountId(),2); + $infos = array(); + foreach ($list as $value){ + if ($this->_getNowTime() - $value['createtime'] < 24*3600 && !$value['from_data'] || $value['from_data'] ){ + $gun = Gun::findByTokenId2($value['token_id1']); + $costGun = Gun::findByTokenId2($value['token_id2']); + $gunDto = null; + $costGunDto = null; + if ($gun && $costGun){ + $gunDto = Gun::toDto($gun); + $costGunDto = Gun::toDto($costGun); + } + $info = array( + 'trans_id'=>$value['trans_id'], + 'state'=>$value['state'], + 'gunInfo'=>$gunDto, + 'costGunInfo'=>$costGunDto, + ); + array_push($infos,$info); + } + } + $this->_rspData(array( + 'infos' => $infos + )); + } + } diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index af739469..6d59e210 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -229,7 +229,7 @@ class HeroController extends BaseAuthedController { $list = NftUpReceive::all(myself()->_getAccountId(),1); $infos = array(); foreach ($list as $value){ - if ($this->_getNowTime() - $value['createtime'] < 24*3600 && !$value['from_data']){ + if ($this->_getNowTime() - $value['createtime'] < 24*3600 && !$value['from_data'] || $value['from_data'] ){ $hero = Hero::findByTokenId2($value['token_id1']); $costHero = Hero::findByTokenId2($value['token_id2']); $heroDto = null; @@ -902,6 +902,10 @@ class HeroController extends BaseAuthedController { ) ); NftUpReceive::setAccountIdNull(myself()->_getAccountId(),$transId); - myself()->_rspOk(); + $propertyChgService = new services\PropertyChgService(); + $propertyChgService->addHeroChg(); + $this->_rspData(array( + 'property_chg' => $propertyChgService->toDto(), + )); } } diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index ba0d80a1..c0c597b2 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -67,6 +67,18 @@ class Gun extends BaseModel { return $row; } + public static function findByTokenId2($tokenId) + { + $row = SqlHelper::ormSelectOne( + myself()->_getMysql($tokenId), + 't_gun', + array( + 'token_id' => $tokenId, + ) + ); + return $row; + } + public static function findByAccountId($accountId, $gunUniId) { return self::internalFind($accountId, $gunUniId); diff --git a/webapp/models/NftUpReceive.php b/webapp/models/NftUpReceive.php index a7478d0c..b13017c3 100644 --- a/webapp/models/NftUpReceive.php +++ b/webapp/models/NftUpReceive.php @@ -56,7 +56,7 @@ class NftUpReceive extends BaseModel 'trans_id' => $data['trans_id'], 'token_id1' => $data['token_id1'], 'token_id2' => $data['token_id2'], - 'state' => 0, + 'state' => 1, 'token_type' => $data['token_type'], 'from_data' => 1, 'createtime' => myself()->_getNowTime(), From 03bc96de7241879987e18a17670d16634c8e7653 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Nov 2022 21:00:36 +0800 Subject: [PATCH 06/12] 1 --- sql/gamedb.sql | 1 + webapp/models/Transaction.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 0ce8a7bb..495d6bb1 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -782,6 +782,7 @@ CREATE TABLE `t_transaction` ( `item_uniid` bigint NOT NULL DEFAULT '0' COMMENT '道具uniid', `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '道具id', `status` int(11) NOT NULL DEFAULT '0' COMMENT 'status', + `client_confirmed` int(11) NOT NULL DEFAULT '0' COMMENT 'client_confirmed', `client_result` mediumblob COMMENT 'client_result', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', diff --git a/webapp/models/Transaction.php b/webapp/models/Transaction.php index df598f8f..74909e56 100644 --- a/webapp/models/Transaction.php +++ b/webapp/models/Transaction.php @@ -40,6 +40,7 @@ class Transaction extends BaseModel { array( 'account_id' => myself()->_getAccountId(), 'trans_id' => $transId, + 'client_confirmed' => 1 ) ); return $row; @@ -143,6 +144,7 @@ class Transaction extends BaseModel { ), array( 'client_result' => $result, + 'client_confirmed' => 1, 'modifytime' => myself()->_getNowTime() ) ); From 9e8ca40c8f3ffbfea1e6e4dfb30baaf050724e81 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Nov 2022 21:07:13 +0800 Subject: [PATCH 07/12] 1 --- webapp/models/Transaction.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/models/Transaction.php b/webapp/models/Transaction.php index 74909e56..10ab2234 100644 --- a/webapp/models/Transaction.php +++ b/webapp/models/Transaction.php @@ -26,7 +26,8 @@ class Transaction extends BaseModel { myself()->_getSelfMysql(), 't_transaction', array( - 'account_id' => myself()->_getAccountId() + 'account_id' => myself()->_getAccountId(), + 'client_confirmed' => 1 ) ); return $rows; @@ -40,7 +41,6 @@ class Transaction extends BaseModel { array( 'account_id' => myself()->_getAccountId(), 'trans_id' => $transId, - 'client_confirmed' => 1 ) ); return $row; From 9e3f4e2b1111e8d0abfb5716f77ce7f20e848593 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 9 Nov 2022 21:09:33 +0800 Subject: [PATCH 08/12] 1 --- .../controller/BlockChainController.class.php | 36 +++++++++++++++++++ webapp/controller/HeroController.class.php | 7 ++++ 2 files changed, 43 insertions(+) diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index e94842e6..dd19d77f 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -164,6 +164,25 @@ class BlockChainController extends BaseAuthedController { myself()->_rspErr(1, 'token paramater error'); return; } + //CEG扣除 + { + $costItems = array( + array( + '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) +// ) + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); + } $this->internalBcCall( array( 'c' => 'BcService', @@ -193,6 +212,23 @@ class BlockChainController extends BaseAuthedController { myself()->_rspErr(1, 'token paramater error'); return; } + $costItems = array( + array( + '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) +// ) + ); + + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); $this->internalBcCall( array( 'c' => 'BcService', diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 6d59e210..b065694f 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -901,11 +901,18 @@ class HeroController extends BaseAuthedController { 'unlock_time' => 0, ) ); + $newHeroDb = Hero::findByTokenId2($tokenId); + $newHero = Hero::toDto($newHeroDb); + $newHeroDb['quality'] -= 1; + $oldHero = Hero::toDto($newHeroDb); NftUpReceive::setAccountIdNull(myself()->_getAccountId(),$transId); + $propertyChgService = new services\PropertyChgService(); $propertyChgService->addHeroChg(); $this->_rspData(array( 'property_chg' => $propertyChgService->toDto(), + 'new_hero' =>$newHero, + 'old_hero'=>$oldHero )); } } From 4e0980b032b537b812cb9d76d62c0ccedf918863 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Nov 2022 21:11:21 +0800 Subject: [PATCH 09/12] 1 --- webapp/controller/BlockChainController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index dd19d77f..897a5d94 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -378,7 +378,7 @@ class BlockChainController extends BaseAuthedController { myself()->_rspErr(101, 'token_ids paramater error'); return; } - $tokenType = Nft::GUN_TYPE; + $tokenType = Nft::EQUIP_TYPE; } else { myself()->_rspErr(101, 'token_ids paramater error'); return; From d3473616248a2c9355da8af6cc532ca60c12dc78 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 9 Nov 2022 21:36:57 +0800 Subject: [PATCH 10/12] 1 --- .../controller/BlockChainController.class.php | 62 +++++++++++++++---- webapp/controller/GunController.class.php | 6 ++ 2 files changed, 56 insertions(+), 12 deletions(-) diff --git a/webapp/controller/BlockChainController.class.php b/webapp/controller/BlockChainController.class.php index 897a5d94..5bcab723 100644 --- a/webapp/controller/BlockChainController.class.php +++ b/webapp/controller/BlockChainController.class.php @@ -212,23 +212,27 @@ class BlockChainController extends BaseAuthedController { myself()->_rspErr(1, 'token paramater error'); return; } - $costItems = array( - array( - 'item_id' => V_ITEM_GOLD, - 'item_num' => \services\FormulaService::Weapon_Advanced_CEG_Expend($nft1['quality']+1) - ), + //CEG扣除 + { + $costItems = array( + array( + '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) // ) - ); + ); - $lackItem = null; - if (!$this->_hasEnoughItems($costItems, $lackItem)) { - $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); - return; + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); } - $this->_decItems($costItems); + $this->internalBcCall( array( 'c' => 'BcService', @@ -392,6 +396,37 @@ class BlockChainController extends BaseAuthedController { myself()->_getNowTime(), myself()->_getOpenId() ); + //CEG扣除 + { + if ($tokenType == Nft::HERO_TYPE){ + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => 100 + ), + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); + } + if ($tokenType == Nft::EQUIP_TYPE){ + $costItems = array( + array( + 'item_id' => V_ITEM_GOLD, + 'item_num' => 30 + ), + ); + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); + } + } $params = array( 'c' => 'BcService', @@ -559,7 +594,10 @@ class BlockChainController extends BaseAuthedController { myself()->_rspErr(101, 'token_id paramater error'); return; } - +// //CEG扣除 +// { +// Chip::getChipByTokenId($chipIds); +// } $this->internalBcCall( array( 'c' => 'BcService', diff --git a/webapp/controller/GunController.class.php b/webapp/controller/GunController.class.php index b12ebeec..bfc81ac4 100644 --- a/webapp/controller/GunController.class.php +++ b/webapp/controller/GunController.class.php @@ -738,11 +738,17 @@ class GunController extends BaseAuthedController { 'unlock_time' => 0, ) ); + $newGunDb = Gun::findByTokenId2($tokenId); + $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 )); } From a8ce8f3ae9187671110e34bc1e4a99c26ed03913 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Wed, 9 Nov 2022 23:02:05 +0800 Subject: [PATCH 11/12] 1 --- webapp/services/LogService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/services/LogService.php b/webapp/services/LogService.php index 03fbdb17..3c6db6b8 100644 --- a/webapp/services/LogService.php +++ b/webapp/services/LogService.php @@ -181,9 +181,9 @@ class LogService extends BaseService 'nft_unique_id' => $old_nft['idx'], //NFT idx 'nft_token_id' => $old_nft['token_id']?$old_nft['token_id']:null, //NFT token ID 'nft_item_id' => $old_nft['item_id']?$old_nft['item_id']:null, //NFT item ID - 'nft_quality' => $old_nft['quality'] ? $old_nft['quality'] : null, //NFT品阶 + 'nft_quality' => isset($old_nft['quality']) ? $old_nft['quality'] : null, //NFT品阶 'nft_level' => $old_nft['level'] ? $old_nft['level'] : null, //NFT等级 - 'nft_quality2' => $new_nft['quality'] ? $new_nft['quality'] : null, //NFT品阶2 + 'nft_quality2' => isset($new_nft['quality']) ? $new_nft['quality'] : null, //NFT品阶2 'nft_level2' => $new_nft['level'] ? $new_nft['level'] : null, //NFT等级2 'nft_info' => json_encode($old_nft), 'new_nft' => json_encode($new_nft) From d805e9b3c49527433bde6fb8e3b71242367092c1 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 9 Nov 2022 23:02:27 +0800 Subject: [PATCH 12/12] 1 --- webapp/mt/Item.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/mt/Item.php b/webapp/mt/Item.php index af45d570..d3e70647 100644 --- a/webapp/mt/Item.php +++ b/webapp/mt/Item.php @@ -302,7 +302,7 @@ class Item { array_push($heros, $tokenId); } if (in_array($tokenId, $gunItemIds)) { - array_push($gun, $tokenId); + array_push($guns, $tokenId); } switch ($tokenId) { case 110100: @@ -312,7 +312,7 @@ class Item { break; case 110200: { - array_push($gunHeros, $tokenId); + array_push($specGuns, $tokenId); } break; default: