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..a9d20005 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'], @@ -211,9 +212,18 @@ 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']); + $stakedDays = $dto['stacked_days']; + $dailyInterest = self::getDailyInterest($row['stake_time'], $dto['remain_days']); + $srcDailyInterest = $dailyInterest; + if ($saveDays >= 30 * 12 * 2) { + if ($stakedDays < 30 * 12) { + $dailyInterest *= 0.6; + } else { + $dailyInterest *= 0.4; + } + } $dto['daily_rewards'] = $dto['cec_value'] * $dailyInterest; /* error_log(json_encode(array( @@ -222,20 +232,33 @@ 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, $stakedDays - 30 * 12) * 0.4 * 0.25; + } else { + $dto['cec_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']) * 0.25; + } } $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; + $dto['cec_rewards'] += $srcDailyRewards * max(0, $stakedDays - 30 * 12) * 0.4; + } else { + $dto['cec_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']); + } } - $dto['total_rewards'] = $dto['daily_rewards'] * ($saveDays - $dto['remain_days']); + $dto['total_rewards'] = $dto['cec_rewards']; } return $dto; } @@ -245,7 +268,7 @@ class Staking extends BaseModel { return 1; } - public static function getDailyInterest($stakeTime) + private static function getDailyInterest($stakeTime, $remainDays) { $months = intval($stakeTime / 3600 / 24 / 30); if ($months <= 0) { diff --git a/webapp/services/BlockChainService.php b/webapp/services/BlockChainService.php index b3a36a33..b0cb21bb 100644 --- a/webapp/services/BlockChainService.php +++ b/webapp/services/BlockChainService.php @@ -215,9 +215,15 @@ 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); } + /* + error_log(json_encode(array( + 'val' => $val, + 'int_part' => $intPart, + 'float_part' => $floatPart, + )));*/ return true; } 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(); }