From 255d38f47bc360366579cae9f6d91c9843a2a734 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 24 Aug 2023 20:41:39 +0800 Subject: [PATCH 01/20] 1 --- webapp/controller/StakingController.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/webapp/controller/StakingController.class.php b/webapp/controller/StakingController.class.php index b88cfa17..1932bdd8 100644 --- a/webapp/controller/StakingController.class.php +++ b/webapp/controller/StakingController.class.php @@ -104,6 +104,10 @@ class StackingController extends BaseAuthedController { $info['stake_time'] = $row['stake_time']; $info['txhash'] = $row['txhash']; $info['item_id'] = $row['item_id']; + $info['stacked_days'] = intval((myself()->_getNowDaySeconds() - + myself()->_getDaySeconds($row['start_time'])) / 3600 / 24); + $info['remain_days'] = max(0, intval($row['stake_time'] / 3600 / 24) - $info['stacked_days']); + array_push($items, $info); } @@ -132,7 +136,12 @@ class StackingController extends BaseAuthedController { $info['stake_time'] = $row['stake_time']; $info['txhash'] = $row['txhash']; $info['item_id'] = $row['item_id']; + $info['stacked_days'] = intval( + (myself()->_getNowDaySeconds() - + myself()->_getDaySeconds($row['start_time']) + 3600 *24) / 3600 / 24); + $info['remain_days'] = max(0, intval($row['stake_time'] / 3600 / 24) - $info['stacked_days']); + $info['total_rewards'] = $row['stacked_days'] *$info['daily_rewards']; array_push($items, $info); } } From 3bedee0520e3ff23a68b9834292887d711efb3bc Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 10:26:13 +0800 Subject: [PATCH 02/20] 1 --- doc/AccountVerify.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 doc/AccountVerify.py diff --git a/doc/AccountVerify.py b/doc/AccountVerify.py new file mode 100644 index 00000000..902da860 --- /dev/null +++ b/doc/AccountVerify.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +import _common + +class AccountVerify(object): + + def __init__(self): + self.apis = [ + { + 'method': 'GET', + 'name': 'canBind', + 'desc': '是否可绑定', + 'group': 'AccountVerify', + 'url': 'webapp/index.php?c=Battle&a=canBind', + 'params': [ + _common.ReqHead(), + ['guest_account', '', 'guest账号'], + ['target_plat', '', '绑定的目标账号渠道'], + ['target_account', '', '绑定的目标账号'], + ], + 'response': [ + _common.RspHead(), + ] + }, + ] From 120c917af956e337b7ca68dd59db4a89ff40b3d6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 10:28:53 +0800 Subject: [PATCH 03/20] 1 --- doc/AccountVerify.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/AccountVerify.py b/doc/AccountVerify.py index 902da860..a02ff5dd 100644 --- a/doc/AccountVerify.py +++ b/doc/AccountVerify.py @@ -11,7 +11,7 @@ class AccountVerify(object): 'name': 'canBind', 'desc': '是否可绑定', 'group': 'AccountVerify', - 'url': 'webapp/index.php?c=Battle&a=canBind', + 'url': 'webapp/index.php?c=AccountVerify&a=canBind', 'params': [ _common.ReqHead(), ['guest_account', '', 'guest账号'], From 783a2101c1599031e633d5454f9f097004101c08 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 11:25:21 +0800 Subject: [PATCH 04/20] 1 --- .../AccountVerifyController.class.php | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 webapp/controller/AccountVerifyController.class.php diff --git a/webapp/controller/AccountVerifyController.class.php b/webapp/controller/AccountVerifyController.class.php new file mode 100644 index 00000000..aabfbc8b --- /dev/null +++ b/webapp/controller/AccountVerifyController.class.php @@ -0,0 +1,38 @@ +_getMysql(''), + 't_user', + array( + 'account_id' => TAPTAP_CHANNEL . '_2006_' . $guestAccount + )); + if (!$row) { + myself()->_rspErr(1, 'guest_account not found'); + return; + } + } + { + $row = SqlHelper::ormSelectOne( + myself()->_getMysql(''), + 't_user', + array( + 'account_id' => BC_POLY_CHANNEL . '_2006_' . $targetPlat . '_' . $targetAccount + )); + if ($row) { + myself()->_rspErr(1, 'cannot bind'); + return; + } + } + } + +} From d5a4778826b52306d7af7cf753d531288de74327 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 11:44:30 +0800 Subject: [PATCH 05/20] 1 --- webapp/services/CallBack.php | 2 ++ webapp/services/callback/Redeem721.php | 23 +++++++++++++++++++++++ webapp/services/callback/Staked721.php | 25 +++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 webapp/services/callback/Redeem721.php create mode 100644 webapp/services/callback/Staked721.php diff --git a/webapp/services/CallBack.php b/webapp/services/CallBack.php index 38ea1a07..44122111 100644 --- a/webapp/services/CallBack.php +++ b/webapp/services/CallBack.php @@ -14,6 +14,8 @@ class CallBackService extends BaseService { 'MarketPriceUpdateOrderOk' => 'MarketPriceUpdateOrderOk', 'inappPurchase' => 'InAppPurchase', 'outappPurchase' => 'OutAppPurchase', + 'staked721' => 'Staked721', + 'redeem721' => 'Redeem721', ); public function dispatch($action) diff --git a/webapp/services/callback/Redeem721.php b/webapp/services/callback/Redeem721.php new file mode 100644 index 00000000..13a2372f --- /dev/null +++ b/webapp/services/callback/Redeem721.php @@ -0,0 +1,23 @@ + Date: Fri, 25 Aug 2023 12:43:12 +0800 Subject: [PATCH 06/20] 1 --- webapp/models/Staking.php | 68 ++++++++++++++++++++++++++ webapp/services/callback/Staked721.php | 10 ++-- 2 files changed, 75 insertions(+), 3 deletions(-) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index bc6fabe6..cd167e56 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -19,4 +19,72 @@ class Staking extends BaseModel { return $rows; } + public static function staked721($data, $netId) + { + $address = $data['address']; + foreach ($data['infos'] as $info) { + SqlHelper::upsert( + myself()->_getMysql(''), + 't_staking', + array( + 'token_id' => $info['tokenid'], + 'contract_address' => $info['nft'], + 'net_id' => $netId, + 'start_time' => $info['start'], + ), + array( + + ), + array( + 'address' => $address, + 'token_id' => $info['tokenid'], + 'token_type' => '0', + 'net_id' => $netId, + 'contract_address' => $info['nft'], + 'stacked_num' => 1, + 'start_time' => $info['start'], + 'stake_time' => $info['stakeTime'], + 'status' => self::STAKING_STATUS, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + } + } + + public static function redeem721($data, $netId, $unstakeTime) + { + $address = $data['address']; + foreach ($data['infos'] as $info) { + SqlHelper::upsert( + myself()->_getMysql(''), + 't_staking', + array( + 'token_id' => $info['tokenid'], + 'contract_address' => $info['nft'], + 'net_id' => $netId, + 'start_time' => $info['start'], + ), + array( + 'unstake_time' => $unstakeTime, + 'status' => self::UNSTAKE_STATUS, + ), + array( + 'address' => $address, + 'token_id' => $info['tokenid'], + 'token_type' => '0', + 'net_id' => $netId, + 'contract_address' => $info['nft'], + 'stacked_num' => 1, + 'start_time' => $info['start'], + 'stake_time' => $info['stakeTime'], + 'unstake_time' => $unstakeTime, + 'status' => self::UNSTAKE_STATUS, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + } + } + } diff --git a/webapp/services/callback/Staked721.php b/webapp/services/callback/Staked721.php index 31390fa6..decb2e08 100644 --- a/webapp/services/callback/Staked721.php +++ b/webapp/services/callback/Staked721.php @@ -1,18 +1,22 @@ Date: Fri, 25 Aug 2023 12:52:19 +0800 Subject: [PATCH 07/20] 1 --- webapp/models/Staking.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index cd167e56..7b0af405 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -52,6 +52,12 @@ class Staking extends BaseModel { } } + public static function repair721NftInfo($tokenId, $contractAddress, $netId, $startTime, + &$itemId, &$tokenType) + { + + } + public static function redeem721($data, $netId, $unstakeTime) { $address = $data['address']; From 535ae8800027b017a3be407353b852d845cdbd9f Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 13:18:34 +0800 Subject: [PATCH 08/20] 1 --- sql/gamedb2006_migrate_230816_01.sql | 1 + webapp/models/Staking.php | 43 +++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/sql/gamedb2006_migrate_230816_01.sql b/sql/gamedb2006_migrate_230816_01.sql index ed92b262..247f9a61 100644 --- a/sql/gamedb2006_migrate_230816_01.sql +++ b/sql/gamedb2006_migrate_230816_01.sql @@ -84,6 +84,7 @@ CREATE TABLE `t_staking` ( `unstake_time` bigint NOT NULL DEFAULT '0' COMMENT '解押结束时间', `status` int(11) NOT NULL COMMENT '0:质押中 1:已解押', `txhash` varchar(255) NOT NULL DEFAULT '' COMMENT 'txhash', + `nft_type` int(11) NOT NULL COMMENT '', `ceg_value` double NOT NULL DEFAULT '0' COMMENT 'ceg价值', `ceg_reward` double NOT NULL DEFAULT '0' COMMENT '利息', `createtime` int(11) NOT NULL COMMENT '创建时间', diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index 7b0af405..2a2cabfa 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -7,6 +7,8 @@ class Staking extends BaseModel { const STAKING_STATUS = 0; const UNSTAKE_STATUS = 1; + const NFT721 = 1; + public static function all($address) { $rows = SqlHelper::ormSelect( @@ -45,17 +47,51 @@ class Staking extends BaseModel { 'start_time' => $info['start'], 'stake_time' => $info['stakeTime'], 'status' => self::STAKING_STATUS, + 'nft_type' => self::NFT721, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), ) ); + $itemId = 0; + $tokenType = 0; + self::repair721NftInfo($info['tokenid'], $info['nft'], $netId, $info['start'], + $itemId, $tokenId); } } public static function repair721NftInfo($tokenId, $contractAddress, $netId, $startTime, &$itemId, &$tokenType) { - + $row = SqlHelper::ormSelect( + myself()->_getMarketMysql(), + 't_nft', + array( + 'token_id' => $tokenId, + 'contract_address' => $contractAddress, + 'net_id' => $netId, + ) + ); + if (!$row) { + return false; + } + $itemId = $row['item_id']; + $tokenType = $row['token_type']; + SqlHelper::update( + myself()->_getMysql(''), + 't_staking', + array( + 'token_id' => $tokenId, + 'contract_address' => $contractAddress, + 'net_id' => $netId, + 'start_time' => $startTime, + 'nft_type' => self::NFT721, + ), + array( + 'item_id' => $itemId, + 'token_type' => $tokenType + ) + ); + return true; } public static function redeem721($data, $netId, $unstakeTime) @@ -86,10 +122,15 @@ class Staking extends BaseModel { 'stake_time' => $info['stakeTime'], 'unstake_time' => $unstakeTime, 'status' => self::UNSTAKE_STATUS, + 'nft_type' => self::NFT721, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), ) ); + $itemId = 0; + $tokenType = 0; + self::repair721NftInfo($info['tokenid'], $info['nft'], $netId, $info['start'], + $itemId, $tokenId); } } From 95765d9d1431a33e163e022b725bb88cf0f4b181 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 13:22:01 +0800 Subject: [PATCH 09/20] 1 --- webapp/services/callback/Redeem721.php | 16 +++++++++++++--- webapp/services/callback/Staked721.php | 4 ++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/webapp/services/callback/Redeem721.php b/webapp/services/callback/Redeem721.php index 13a2372f..97dca747 100644 --- a/webapp/services/callback/Redeem721.php +++ b/webapp/services/callback/Redeem721.php @@ -2,22 +2,32 @@ namespace services; -require_once ('services/callback/common/SignatureService.php'); require_once('mt/Item.php'); require_once('mt/Hero.php'); require_once('mt/Parameter.php'); +require_once ('modules/Stacking.php'); + +require_once ('services/callback/common/SignatureService.php'); + +use phpcommon\SqlHelper; use mt\Item; use mt\Hero; use mt\Parameter; -use phpcommon\SqlHelper; -class Redeem721 { +use modules\Stacking; + +class Redeem721 +{ public function process() { SignatureService::web3ServiceCheck(); + $data = json_decode(getReqVal('data', ''), true); + $netId = getReqVal('net_id', ''); + Stacking::redeem721($data, $netId, myself()->_getNowTime()); + myself()->_rspOk(); } } diff --git a/webapp/services/callback/Staked721.php b/webapp/services/callback/Staked721.php index decb2e08..89631305 100644 --- a/webapp/services/callback/Staked721.php +++ b/webapp/services/callback/Staked721.php @@ -24,6 +24,10 @@ class Staked721 public function process() { SignatureService::web3ServiceCheck(); + $data = json_decode(getReqVal('data', ''), true); + $netId = getReqVal('net_id', ''); + Stacking::staked721($data, $netId); + myself()->_rspOk(); } } From 6d3fc1336fe60397b06ff3d11d01a6b9d18361c4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 14:27:54 +0800 Subject: [PATCH 10/20] 1 --- sql/gamedb2006_migrate_230816_01.sql | 2 +- webapp/models/Staking.php | 14 ++++++++------ webapp/services/callback/Redeem721.php | 4 +++- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/sql/gamedb2006_migrate_230816_01.sql b/sql/gamedb2006_migrate_230816_01.sql index 247f9a61..3a6bcf45 100644 --- a/sql/gamedb2006_migrate_230816_01.sql +++ b/sql/gamedb2006_migrate_230816_01.sql @@ -81,7 +81,7 @@ CREATE TABLE `t_staking` ( `stacked_num` varchar(60) NOT NULL DEFAULT '' COMMENT 'stacked_num', `start_time` bigint NOT NULL DEFAULT '0' COMMENT '质押开始时间', `stake_time` bigint NOT NULL DEFAULT '0' COMMENT '质押结束时间', - `unstake_time` bigint NOT NULL DEFAULT '0' COMMENT '解押结束时间', + `redeem_time` bigint NOT NULL DEFAULT '0' COMMENT '赎回时间', `status` int(11) NOT NULL COMMENT '0:质押中 1:已解押', `txhash` varchar(255) NOT NULL DEFAULT '' COMMENT 'txhash', `nft_type` int(11) NOT NULL COMMENT '', diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index 2a2cabfa..bd5eecd0 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -5,7 +5,7 @@ namespace models; class Staking extends BaseModel { const STAKING_STATUS = 0; - const UNSTAKE_STATUS = 1; + const REDEEM_STATUS = 1; const NFT721 = 1; @@ -94,7 +94,7 @@ class Staking extends BaseModel { return true; } - public static function redeem721($data, $netId, $unstakeTime) + public static function redeem721($data, $netId, $redeemTime, $txHash) { $address = $data['address']; foreach ($data['infos'] as $info) { @@ -108,8 +108,9 @@ class Staking extends BaseModel { 'start_time' => $info['start'], ), array( - 'unstake_time' => $unstakeTime, - 'status' => self::UNSTAKE_STATUS, + 'txhash' => $txHash, + 'redeem_time' => $redeemTime, + 'status' => self::REDEEM_STATUS, ), array( 'address' => $address, @@ -120,8 +121,9 @@ class Staking extends BaseModel { 'stacked_num' => 1, 'start_time' => $info['start'], 'stake_time' => $info['stakeTime'], - 'unstake_time' => $unstakeTime, - 'status' => self::UNSTAKE_STATUS, + 'txhash' => $txHash, + 'redeem_time' => $redeemTime, + 'status' => self::REDEEM_STATUS, 'nft_type' => self::NFT721, 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), diff --git a/webapp/services/callback/Redeem721.php b/webapp/services/callback/Redeem721.php index 97dca747..6036ae44 100644 --- a/webapp/services/callback/Redeem721.php +++ b/webapp/services/callback/Redeem721.php @@ -26,7 +26,9 @@ class Redeem721 SignatureService::web3ServiceCheck(); $data = json_decode(getReqVal('data', ''), true); $netId = getReqVal('net_id', ''); - Stacking::redeem721($data, $netId, myself()->_getNowTime()); + $redeemTime = getReqVal('redeem_time', ''); + $txHash = getReqVal('txhash', ''); + Stacking::redeem721($data, $netId, $redeemTime, $txHash); myself()->_rspOk(); } From 25dd07bc67df3ca2a733a2711638676d70c9ad20 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 14:29:08 +0800 Subject: [PATCH 11/20] 1 --- sql/gamedb2006_migrate_230816_01.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/gamedb2006_migrate_230816_01.sql b/sql/gamedb2006_migrate_230816_01.sql index 3a6bcf45..3a8c9cc0 100644 --- a/sql/gamedb2006_migrate_230816_01.sql +++ b/sql/gamedb2006_migrate_230816_01.sql @@ -90,7 +90,7 @@ CREATE TABLE `t_staking` ( `createtime` int(11) NOT NULL COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), - UNIQUE KEY `unikey` (`token_id`, `contract_address`, `net_id`, `start_time`) + UNIQUE KEY `unikey` (`token_id`, `contract_address`, `net_id`, `start_time`), KEY `address` (`address`) ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8; From e183c141061db1cdde295b09d6f721a0cb9c85f3 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 14:39:02 +0800 Subject: [PATCH 12/20] 1 --- webapp/controller/StakingController.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/controller/StakingController.class.php b/webapp/controller/StakingController.class.php index 1932bdd8..b57138d5 100644 --- a/webapp/controller/StakingController.class.php +++ b/webapp/controller/StakingController.class.php @@ -126,7 +126,7 @@ class StackingController extends BaseAuthedController { $toTime = getReqVal('to_time', ''); $rows = Stacking::all(myself()->_getAddress()); foreach ($rows as $row) { - if ($row['status'] == Stacking::UNSTAKE_STATUS) { + if ($row['status'] == Stacking::REDEEM_STATUS) { $info = array(); $info['token_id'] = $row['token_id']; $info['token_type'] = $row['token_type']; From 49ee8ade8727e05b3bf47a86846c90bfb532277c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 14:46:24 +0800 Subject: [PATCH 13/20] 1 --- webapp/models/Staking.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index bd5eecd0..cae758ba 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -11,6 +11,7 @@ class Staking extends BaseModel { public static function all($address) { + $result = array(); $rows = SqlHelper::ormSelect( myself()->_getMysql(''), 't_staking', @@ -18,7 +19,22 @@ class Staking extends BaseModel { 'address' => $address ) ); - return $rows; + foreach ($rows as $row) { + if ($row['nft_type'] == self::NFT721) { + if (!$row['item_id']) { + $itemId = 0; + $tokenType = 0; + if (!self::repair721NftInfo($row['token_id'], $row['contract_address'], $row['net_id'], + $row['start_time'], $itemId, $tokenType)) { + continue; + } + $row['item_id'] = $itemId; + $row['token_type'] = $tokenType; + } + } + array_push($result, $row); + } + return $result; } public static function staked721($data, $netId) From 0b59c96dd8b16b2c7f026cfade1e78ca877b7a96 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 14:51:09 +0800 Subject: [PATCH 14/20] 1 --- sql/gamedb2006_migrate_230816_01.sql | 4 ++-- webapp/controller/StakingController.class.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/gamedb2006_migrate_230816_01.sql b/sql/gamedb2006_migrate_230816_01.sql index 3a8c9cc0..aba6e2c0 100644 --- a/sql/gamedb2006_migrate_230816_01.sql +++ b/sql/gamedb2006_migrate_230816_01.sql @@ -85,8 +85,8 @@ CREATE TABLE `t_staking` ( `status` int(11) NOT NULL COMMENT '0:质押中 1:已解押', `txhash` varchar(255) NOT NULL DEFAULT '' COMMENT 'txhash', `nft_type` int(11) NOT NULL COMMENT '', - `ceg_value` double NOT NULL DEFAULT '0' COMMENT 'ceg价值', - `ceg_reward` double NOT NULL DEFAULT '0' COMMENT '利息', + `nft_value` double NOT NULL DEFAULT '0' COMMENT 'nft价值', + `nft_reward` double NOT NULL DEFAULT '0' COMMENT '利息', `createtime` int(11) NOT NULL COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', PRIMARY KEY (`idx`), diff --git a/webapp/controller/StakingController.class.php b/webapp/controller/StakingController.class.php index b57138d5..91887fb2 100644 --- a/webapp/controller/StakingController.class.php +++ b/webapp/controller/StakingController.class.php @@ -62,7 +62,7 @@ class StackingController extends BaseAuthedController { } else { $info['maturity_quant'] += $row['stacked_num']; } - $info['staking_value'] += $row['ceg_value']; + $info['staking_value'] += $row['nft_value']; } } break; @@ -74,7 +74,7 @@ class StackingController extends BaseAuthedController { } else { $info['maturity_quant'] += $row['stacked_num']; } - $info['staking_value'] += $row['ceg_value']; + $info['staking_value'] += $row['nft_value']; } } break; From cf1f24396fbe80932e37b5cd305c0943ea761e2e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 14:55:40 +0800 Subject: [PATCH 15/20] 1 --- sql/gamedb2006_migrate_230816_01.sql | 1 - 1 file changed, 1 deletion(-) diff --git a/sql/gamedb2006_migrate_230816_01.sql b/sql/gamedb2006_migrate_230816_01.sql index aba6e2c0..b9257fc3 100644 --- a/sql/gamedb2006_migrate_230816_01.sql +++ b/sql/gamedb2006_migrate_230816_01.sql @@ -85,7 +85,6 @@ CREATE TABLE `t_staking` ( `status` int(11) NOT NULL COMMENT '0:质押中 1:已解押', `txhash` varchar(255) NOT NULL DEFAULT '' COMMENT 'txhash', `nft_type` int(11) NOT NULL COMMENT '', - `nft_value` double NOT NULL DEFAULT '0' COMMENT 'nft价值', `nft_reward` double NOT NULL DEFAULT '0' COMMENT '利息', `createtime` int(11) NOT NULL COMMENT '创建时间', `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', From ac58fdd25eb06770b97532a557b64b36cd619cc7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 15:08:37 +0800 Subject: [PATCH 16/20] 1 --- webapp/mt/Staking.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 webapp/mt/Staking.php diff --git a/webapp/mt/Staking.php b/webapp/mt/Staking.php new file mode 100644 index 00000000..85d9f74b --- /dev/null +++ b/webapp/mt/Staking.php @@ -0,0 +1,24 @@ + Date: Fri, 25 Aug 2023 15:28:36 +0800 Subject: [PATCH 17/20] 1 --- webapp/controller/StakingController.class.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/webapp/controller/StakingController.class.php b/webapp/controller/StakingController.class.php index 91887fb2..98734916 100644 --- a/webapp/controller/StakingController.class.php +++ b/webapp/controller/StakingController.class.php @@ -1,5 +1,7 @@ Date: Fri, 25 Aug 2023 16:11:07 +0800 Subject: [PATCH 18/20] 1 --- webapp/models/Staking.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index cae758ba..edec6568 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -2,6 +2,8 @@ namespace models; +require_once("mt/Stacking.php"); + class Staking extends BaseModel { const STAKING_STATUS = 0; @@ -152,4 +154,13 @@ class Staking extends BaseModel { } } + public static function calcReward($row, &$reward) + { + $stakingMeta = mt\Staking::get($row['item_id']); + if (!$stakingMeta) { + return false; + } + return true; + } + } From f55f5422ad632ba09e1859876746b09a98956b0d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 16:41:51 +0800 Subject: [PATCH 19/20] 1 --- webapp/models/Staking.php | 4 +++- webapp/services/callback/Redeem721.php | 6 +++--- webapp/services/callback/Staked721.php | 6 +++--- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index edec6568..1951e9b2 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -2,7 +2,9 @@ namespace models; -require_once("mt/Stacking.php"); +require_once("mt/Staking.php"); + +use phpcommon\SqlHelper; class Staking extends BaseModel { diff --git a/webapp/services/callback/Redeem721.php b/webapp/services/callback/Redeem721.php index 6036ae44..cc02843f 100644 --- a/webapp/services/callback/Redeem721.php +++ b/webapp/services/callback/Redeem721.php @@ -6,7 +6,7 @@ require_once('mt/Item.php'); require_once('mt/Hero.php'); require_once('mt/Parameter.php'); -require_once ('modules/Stacking.php'); +require_once ('models/Staking.php'); require_once ('services/callback/common/SignatureService.php'); @@ -16,7 +16,7 @@ use mt\Item; use mt\Hero; use mt\Parameter; -use modules\Stacking; +use models\Staking; class Redeem721 { @@ -28,7 +28,7 @@ class Redeem721 $netId = getReqVal('net_id', ''); $redeemTime = getReqVal('redeem_time', ''); $txHash = getReqVal('txhash', ''); - Stacking::redeem721($data, $netId, $redeemTime, $txHash); + Staking::redeem721($data, $netId, $redeemTime, $txHash); myself()->_rspOk(); } diff --git a/webapp/services/callback/Staked721.php b/webapp/services/callback/Staked721.php index 89631305..cfd5b7fe 100644 --- a/webapp/services/callback/Staked721.php +++ b/webapp/services/callback/Staked721.php @@ -6,7 +6,7 @@ require_once('mt/Item.php'); require_once('mt/Hero.php'); require_once('mt/Parameter.php'); -require_once ('modules/Stacking.php'); +require_once ('models/Staking.php'); require_once ('services/callback/common/SignatureService.php'); @@ -16,7 +16,7 @@ use mt\Item; use mt\Hero; use mt\Parameter; -use modules\Stacking; +use models\Staking; class Staked721 { @@ -26,7 +26,7 @@ class Staked721 SignatureService::web3ServiceCheck(); $data = json_decode(getReqVal('data', ''), true); $netId = getReqVal('net_id', ''); - Stacking::staked721($data, $netId); + Staking::staked721($data, $netId); myself()->_rspOk(); } From 9b17bd4ec08627ada9b4832bdd0882914fc9c09a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 25 Aug 2023 16:47:44 +0800 Subject: [PATCH 20/20] 1 --- webapp/models/Staking.php | 44 +++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index 1951e9b2..4180700b 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -43,29 +43,33 @@ class Staking extends BaseModel { public static function staked721($data, $netId) { - $address = $data['address']; foreach ($data['infos'] as $info) { + $address = strtolower($info[0]); + $nftAddress = strtolower($info[1]); + $tokenId = $info[2]; + $startTime = $info[3]; + $stakeTime = $info[4]; SqlHelper::upsert( myself()->_getMysql(''), 't_staking', array( - 'token_id' => $info['tokenid'], - 'contract_address' => $info['nft'], + 'token_id' => $tokenId, + 'contract_address' => $nftAddress, 'net_id' => $netId, - 'start_time' => $info['start'], + 'start_time' => $nftAddress, ), array( ), array( 'address' => $address, - 'token_id' => $info['tokenid'], + 'token_id' => $tokenId, 'token_type' => '0', 'net_id' => $netId, - 'contract_address' => $info['nft'], + 'contract_address' => $nftAddress, 'stacked_num' => 1, - 'start_time' => $info['start'], - 'stake_time' => $info['stakeTime'], + 'start_time' => $startTime, + 'stake_time' => $stakeTime, 'status' => self::STAKING_STATUS, 'nft_type' => self::NFT721, 'createtime' => myself()->_getNowTime(), @@ -74,7 +78,7 @@ class Staking extends BaseModel { ); $itemId = 0; $tokenType = 0; - self::repair721NftInfo($info['tokenid'], $info['nft'], $netId, $info['start'], + self::repair721NftInfo($tokenId, $nftAddress, $netId, $startTime, $itemId, $tokenId); } } @@ -116,16 +120,20 @@ class Staking extends BaseModel { public static function redeem721($data, $netId, $redeemTime, $txHash) { - $address = $data['address']; foreach ($data['infos'] as $info) { + $address = strtolower($info[0]); + $nftAddress = strtolower($info[1]); + $tokenId = $info[2]; + $startTime = $info[3]; + $stakeTime = $info[4]; SqlHelper::upsert( myself()->_getMysql(''), 't_staking', array( - 'token_id' => $info['tokenid'], - 'contract_address' => $info['nft'], + 'token_id' => $tokenId, + 'contract_address' => $nftAddress, 'net_id' => $netId, - 'start_time' => $info['start'], + 'start_time' => $startTime, ), array( 'txhash' => $txHash, @@ -134,13 +142,13 @@ class Staking extends BaseModel { ), array( 'address' => $address, - 'token_id' => $info['tokenid'], + 'token_id' => $tokenId, 'token_type' => '0', 'net_id' => $netId, - 'contract_address' => $info['nft'], + 'contract_address' => $nftAddress, 'stacked_num' => 1, - 'start_time' => $info['start'], - 'stake_time' => $info['stakeTime'], + 'start_time' => $startTime, + 'stake_time' => $stakeTime, 'txhash' => $txHash, 'redeem_time' => $redeemTime, 'status' => self::REDEEM_STATUS, @@ -151,7 +159,7 @@ class Staking extends BaseModel { ); $itemId = 0; $tokenType = 0; - self::repair721NftInfo($info['tokenid'], $info['nft'], $netId, $info['start'], + self::repair721NftInfo($tokenId, $nftAddress, $netId, $startTime, $itemId, $tokenId); } }