diff --git a/doc/Staking.py b/doc/Staking.py index 94709288..6f1ca9a9 100644 --- a/doc/Staking.py +++ b/doc/Staking.py @@ -66,7 +66,23 @@ class Staking(object): 'response': [ _common.RspHead(), ['cec_rewards', 0, '该nft结算得到的ceg数量'], - ['state', 0, '0:提前赎回 1:到期赎回'], + ] + }, + { + 'name': 'stakingPreview', + 'desc': '质押预览', + 'group': 'Staking', + 'url': 'webapp/index.php?c=Staking&a=stakingPreview', + 'params': [ + _common.ReqHead(), + ['token_id_list', '', 'token_id多个|分割'], + ['contract_address_list', '', 'contract_address多个|分割'], + ['net_id', '', 'net_id'], + ], + 'response': [ + _common.RspHead(), + ['nft_value', 0, 'nft价值'], + ['!items', [_common.StakingPreview()], ''], ] }, ] diff --git a/doc/_common.py b/doc/_common.py index d2b8fb31..ca5b28da 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1454,3 +1454,11 @@ class StakingDetail(object): ['stacked_days', 0, '该nft质押的总天数'], ['remain_days', 0, '该nft剩余质押天数'], ] + +class StakingPreview(object): + + def __init__(self): + self.fields = [ + ['time', 0, '天数'], + ['interest', 0, '利息'], + ] diff --git a/sql/gamedb2006_migrate_230816_01.sql b/sql/gamedb2006_migrate_230816_01.sql index d1e3827f..f46b830f 100644 --- a/sql/gamedb2006_migrate_230816_01.sql +++ b/sql/gamedb2006_migrate_230816_01.sql @@ -81,6 +81,7 @@ CREATE TABLE `t_staking` ( `address` varchar(60) NOT NULL DEFAULT '' COMMENT 'address', `order_id` varchar(60) COMMENT 'order_id', `token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id', + `item_id` int(11) NOT NULL COMMENT 'item_id', `token_type` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 1:英雄 2:枪支 3:芯片 6:荣誉 7:徽章', `net_id` bigint NOT NULL DEFAULT '0' COMMENT 'net_id', `contract_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'contract_address', diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index b56bf7dc..9253700a 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -181,6 +181,9 @@ class BaseAuthedController extends BaseController { $this->addressActived = true; if (SERVER_ENV != _ONLINE && empty($this->address)) { $this->address = strtolower('0xa9ecB9F3A0b54d31ce4a035C89EC7Da4110beB59'); + if (myself()->_getAccountId() == '6513_2006_3WOWIsmpcihK1KTnNP1Ky5MBOh7rt6Rl') { + $this->address = strtolower('0x0bb52209756e8d157f2e551a9adb8d9019b688b1'); + } } } return $this->address; diff --git a/webapp/controller/StakingController.class.php b/webapp/controller/StakingController.class.php index 086cef19..633e09e4 100644 --- a/webapp/controller/StakingController.class.php +++ b/webapp/controller/StakingController.class.php @@ -79,7 +79,7 @@ class StakingController extends BaseAuthedController { foreach ($rows as $row) { if ($row['status'] == Staking::STAKING_STATUS) { if ($this->isTypeNft($type, $row)) { - array_push($items, Staking::toDto($info)); + array_push($items, Staking::toDto($row)); ++$stackedQuant; } } @@ -112,6 +112,33 @@ class StakingController extends BaseAuthedController { $transId = getReqVal('trans_id', 0); } + public function stakingPreview() + { + $tokenIdList = getReqVal('token_id_list', ''); + $contractAddressList = getReqVal('contract_address_list', ''); + $netId = getReqVal('net_id', ''); + if (count($tokenIdList) <= 0) { + myself()->_rspErr(1, 'paramater error'); + return; + } + if (count($tokenIdList) != count($contractAddressList)) { + myself()->_rspErr(1, 'paramater error'); + return; + } + $confirmedNfts = array(); + { + $nftList = Nft::getNftList(myself()-_getAddress()); + foreach ($nftList as $nft) { + if (in_array( + $nft['token_id'], + $tokenIdList + )) { + array_push($confirmedNfts, $nft); + } + } + } + } + private function isTypeNft($type, $dbInfo) { switch ($type) { diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index fe154ffc..3e1eee3c 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -4,8 +4,12 @@ namespace models; require_once("mt/Staking.php"); +require_once("models/User.php"); + use phpcommon\SqlHelper; +use mt; + class Staking extends BaseModel { const STAKING_STATUS = 0; @@ -64,6 +68,7 @@ class Staking extends BaseModel { $tokenId = $info[2]; $startTime = $info[3]; $stakeTime = $info[4]; + $userDb = User::findByAddress($address); SqlHelper::upsert( myself()->_getMysql(''), 't_staking', @@ -77,6 +82,7 @@ class Staking extends BaseModel { ), array( + 'account_id' => $userDb ? $userDb['account_id'] : '', 'address' => $address, 'token_id' => $tokenId, 'token_type' => '0', @@ -101,7 +107,7 @@ class Staking extends BaseModel { public static function repair721NftInfo($tokenId, $contractAddress, $netId, $startTime, &$itemId, &$tokenType) { - $row = SqlHelper::ormSelect( + $row = SqlHelper::ormSelectOne( myself()->_getMarketMysql(), 't_nft', array( @@ -141,6 +147,7 @@ class Staking extends BaseModel { $tokenId = $info[2]; $startTime = $info[3]; $stakeTime = $info[4]; + $userDb = User::findByAddress($address); SqlHelper::upsert( myself()->_getMysql(''), 't_staking', @@ -156,6 +163,7 @@ class Staking extends BaseModel { 'status' => self::REDEEM_STATUS, ), array( + 'account_id' => $userDb ? $userDb['account_id'] : '', 'address' => $address, 'token_id' => $tokenId, 'token_type' => '0',