From 432cfd8f50722a30c9f1be3368ea3d6804c28213 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 29 Aug 2023 17:04:10 +0800 Subject: [PATCH] 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 {