This commit is contained in:
aozhiwei 2023-08-29 17:04:10 +08:00
parent 77259bd1ec
commit 432cfd8f50

View File

@ -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 {