From e0a8062713534958e42c315aca0d59201e146434 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 29 Aug 2023 15:20:51 +0800 Subject: [PATCH 1/9] 1 --- doc/_common.py | 1 + sql/gamedb2006_migrate_230816_01.sql | 2 -- webapp/models/Staking.php | 1 + webapp/services/callback/GameItemMarketBuyOk.php | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/_common.py b/doc/_common.py index 9b716f84..1d02a6b6 100644 --- a/doc/_common.py +++ b/doc/_common.py @@ -1444,6 +1444,7 @@ class StakingDetail(object): ['order_id', '', 'order_id'], ['start_time', '', '质押开始时间'], ['stake_time', '', '质押时间'], + ['redeem_time', '', '赎回时间'], ['txhash', '', 'txhash'], ['item_id', 0, '道具id'], diff --git a/sql/gamedb2006_migrate_230816_01.sql b/sql/gamedb2006_migrate_230816_01.sql index f46b830f..a2ae571f 100644 --- a/sql/gamedb2006_migrate_230816_01.sql +++ b/sql/gamedb2006_migrate_230816_01.sql @@ -103,8 +103,6 @@ CREATE TABLE `t_staking` ( alter table t_bc_order add column `currency_name` varchar(60) NOT NULL DEFAULT '' COMMENT 'currency_name'; -alter table t_mall add column `currency_name` varchar(60) NOT NULL DEFAULT '' COMMENT 'currency_name'; - insert into version (version) values(2023081601); commit; diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index 1138ee52..2ff7a44f 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -199,6 +199,7 @@ class Staking extends BaseModel { 'order_id' => $row['order_id'], 'start_time' => $row['start_time'], 'stake_time' => $row['stake_time'], + 'redeem_time' => $row['redeem_time'], 'txhash' => $row['txhash'], 'item_id' => $row['item_id'], diff --git a/webapp/services/callback/GameItemMarketBuyOk.php b/webapp/services/callback/GameItemMarketBuyOk.php index 848699d3..503a39a5 100644 --- a/webapp/services/callback/GameItemMarketBuyOk.php +++ b/webapp/services/callback/GameItemMarketBuyOk.php @@ -83,7 +83,7 @@ class GameItemMarketBuyOk { )), 'param3' => json_encode($orderDb), )); - $currencyName = $orderDb['currency_name']; + $currencyName = $orderDb['currency']; EventService::mallConsume($accountId, $currencyName, $price); myself()->_rspOk(); } From 286590d352889f7048f3e49fdb31111a6eb7b218 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 29 Aug 2023 15:41:05 +0800 Subject: [PATCH 2/9] 1 --- webapp/services/BlockChainService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/services/BlockChainService.php b/webapp/services/BlockChainService.php index b3a36a33..c465e4c7 100644 --- a/webapp/services/BlockChainService.php +++ b/webapp/services/BlockChainService.php @@ -215,8 +215,8 @@ class BlockChainService { if (strlen($val) <= $decimals) { $floatPart = $val; } else { - $intPart = substr($val, 0, $decimals); - $floatPart = substr($val, $decimals); + $intPart = substr($val, 0, strlen($val) - $decimals); + $floatPart = substr($val, strlen($val) - $decimals); } return true; } From 301e6885832baa96e4ac75f39bd5727af9865e41 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 29 Aug 2023 15:51:58 +0800 Subject: [PATCH 3/9] 1 --- webapp/services/BlockChainService.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/webapp/services/BlockChainService.php b/webapp/services/BlockChainService.php index c465e4c7..b0cb21bb 100644 --- a/webapp/services/BlockChainService.php +++ b/webapp/services/BlockChainService.php @@ -218,6 +218,12 @@ class BlockChainService { $intPart = substr($val, 0, strlen($val) - $decimals); $floatPart = substr($val, strlen($val) - $decimals); } + /* + error_log(json_encode(array( + 'val' => $val, + 'int_part' => $intPart, + 'float_part' => $floatPart, + )));*/ return true; } From ed2b272dc587f0b2de03c458622b6ed050a3b5e8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 29 Aug 2023 16:13:17 +0800 Subject: [PATCH 4/9] 1 --- webapp/models/Staking.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index 2ff7a44f..4a5350c4 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -246,7 +246,7 @@ class Staking extends BaseModel { return 1; } - public static function getDailyInterest($stakeTime) + private static function getDailyInterest($stakeTime) { $months = intval($stakeTime / 3600 / 24 / 30); if ($months <= 0) { From 0b55409cc6cc1c2f1cfbab230cb7138a1a1a25c9 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 29 Aug 2023 16:29:20 +0800 Subject: [PATCH 5/9] 1 --- webapp/models/Staking.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index 4a5350c4..d044b106 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -212,9 +212,9 @@ class Staking extends BaseModel { myself()->_getDaySeconds($row['start_time'])) / 3600 / 24); $saveDays = intval($row['stake_time'] / 3600 / 24); - $dailyInterest = self::getDailyInterest($row['stake_time']); $dto['stacked_days'] = max(0, $passedDays); $dto['remain_days'] = max(0, $saveDays - $dto['stacked_days']); + $dailyInterest = self::getDailyInterest($row['stake_time'], $dto['remain_days']); $dto['daily_rewards'] = $dto['cec_value'] * $dailyInterest; /* error_log(json_encode(array( @@ -246,7 +246,7 @@ class Staking extends BaseModel { return 1; } - private static function getDailyInterest($stakeTime) + private static function getDailyInterest($stakeTime, $remainDays) { $months = intval($stakeTime / 3600 / 24 / 30); if ($months <= 0) { From 77259bd1ec3e15a8d7736dd6d02ec58d2ab35be8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 29 Aug 2023 16:41:42 +0800 Subject: [PATCH 6/9] 1 --- webapp/models/Staking.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index d044b106..1dd64459 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -215,6 +215,13 @@ class Staking extends BaseModel { $dto['stacked_days'] = max(0, $passedDays); $dto['remain_days'] = max(0, $saveDays - $dto['stacked_days']); $dailyInterest = self::getDailyInterest($row['stake_time'], $dto['remain_days']); + if ($saveDays >= 30 * 12 * 2) { + if ($dto['remain_days'] < 30 * 12) { + $dailyInterest *= 0.6; + } else { + $dailyInterest *= 0.4; + } + } $dto['daily_rewards'] = $dto['cec_value'] * $dailyInterest; /* error_log(json_encode(array( From 432cfd8f50722a30c9f1be3368ea3d6804c28213 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 29 Aug 2023 17:04:10 +0800 Subject: [PATCH 7/9] 1 --- webapp/models/Staking.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index 1dd64459..23960388 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -214,9 +214,11 @@ class Staking extends BaseModel { $saveDays = intval($row['stake_time'] / 3600 / 24); $dto['stacked_days'] = max(0, $passedDays); $dto['remain_days'] = max(0, $saveDays - $dto['stacked_days']); + $stakedDays = $dto['stacked_days']; $dailyInterest = self::getDailyInterest($row['stake_time'], $dto['remain_days']); + $srcDailyInterest = $dailyInterest; if ($saveDays >= 30 * 12 * 2) { - if ($dto['remain_days'] < 30 * 12) { + if ($stakedDays < 30 * 12) { $dailyInterest *= 0.6; } else { $dailyInterest *= 0.4; @@ -230,13 +232,19 @@ class Staking extends BaseModel { 'daily_interest' => $dailyInterest ))); */ + $srcDailyRewards = $dto['cec_value'] * $srcDailyInterest; $dto['cec_rewards'] = 0; $dto['total_rewards'] = 0; if ($dto['status'] == self::REDEEM_STATUS) { if ($dto['remain_days'] <= 0 ) { - $dto['cec_rewards'] = $dto['daily_rewards'] * $saveDays; + $dto['cec_rewards'] = $srcDailyRewards * $saveDays; } else { - $dto['cec_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']) * 0.25; + if ($saveDays >= 30 * 12 * 2) { + $dto['cec_rewards'] = $srcDailyRewards * min(30 * 12, $stakedDays) * 0.6 * 0.25; + $dto['cec_rewards'] += $srcDailyRewards * max(0, 30 * 12 * 2 - $stakedDays) * 0.6 * 0.25; + } else { + $dto['cec_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']) * 0.25; + } } $dto['total_rewards'] = $dto['cec_rewards']; } else { From 463981ebcce8635aa720c7c0f53a216e85107558 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 29 Aug 2023 17:10:03 +0800 Subject: [PATCH 8/9] 1 --- webapp/models/Staking.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index 23960388..9921fffa 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -241,7 +241,7 @@ class Staking extends BaseModel { } else { if ($saveDays >= 30 * 12 * 2) { $dto['cec_rewards'] = $srcDailyRewards * min(30 * 12, $stakedDays) * 0.6 * 0.25; - $dto['cec_rewards'] += $srcDailyRewards * max(0, 30 * 12 * 2 - $stakedDays) * 0.6 * 0.25; + $dto['cec_rewards'] += $srcDailyRewards * max(0, 30 * 12 * 2 - $stakedDays) * 0.4 * 0.25; } else { $dto['cec_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']) * 0.25; } @@ -249,8 +249,16 @@ class Staking extends BaseModel { $dto['total_rewards'] = $dto['cec_rewards']; } else { if ($dto['remain_days'] <= 0 ) { - $dto['cec_rewards'] = $dto['daily_rewards'] * $saveDays; + $dto['cec_rewards'] = $srcDailyRewards * $saveDays; + } else { + if ($saveDays >= 30 * 12 * 2) { + $dto['cec_rewards'] = $srcDailyRewards * min(30 * 12, $stakedDays) * 0.6 * 0.25; + $dto['cec_rewards'] += $srcDailyRewards * max(0, 30 * 12 * 2 - $stakedDays) * 0.4 * 0.25; + } else { + $dto['cec_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']) * 0.25; + } } + //$dto['total_rewards'] = $dto['cec_rewards']; $dto['total_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']); } return $dto; From 4aaf8174b9a85495a5740722f0a6f767656a5d7d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 29 Aug 2023 17:16:41 +0800 Subject: [PATCH 9/9] 1 --- webapp/models/Staking.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index 9921fffa..a9d20005 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -241,7 +241,7 @@ class Staking extends BaseModel { } else { if ($saveDays >= 30 * 12 * 2) { $dto['cec_rewards'] = $srcDailyRewards * min(30 * 12, $stakedDays) * 0.6 * 0.25; - $dto['cec_rewards'] += $srcDailyRewards * max(0, 30 * 12 * 2 - $stakedDays) * 0.4 * 0.25; + $dto['cec_rewards'] += $srcDailyRewards * max(0, $stakedDays - 30 * 12) * 0.4 * 0.25; } else { $dto['cec_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']) * 0.25; } @@ -252,14 +252,13 @@ class Staking extends BaseModel { $dto['cec_rewards'] = $srcDailyRewards * $saveDays; } else { if ($saveDays >= 30 * 12 * 2) { - $dto['cec_rewards'] = $srcDailyRewards * min(30 * 12, $stakedDays) * 0.6 * 0.25; - $dto['cec_rewards'] += $srcDailyRewards * max(0, 30 * 12 * 2 - $stakedDays) * 0.4 * 0.25; + $dto['cec_rewards'] = $srcDailyRewards * min(30 * 12, $stakedDays) * 0.6; + $dto['cec_rewards'] += $srcDailyRewards * max(0, $stakedDays - 30 * 12) * 0.4; } else { - $dto['cec_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']) * 0.25; + $dto['cec_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']); } } - //$dto['total_rewards'] = $dto['cec_rewards']; - $dto['total_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']); + $dto['total_rewards'] = $dto['cec_rewards']; } return $dto; }