1
This commit is contained in:
parent
d238a699e9
commit
1120c295a8
@ -166,6 +166,7 @@ class Staking extends BaseModel {
|
||||
|
||||
public static function toDto($row)
|
||||
{
|
||||
$stakingMeta = mt\Staking::get($row['item_id']);
|
||||
$dto = array(
|
||||
'token_id' => $row['token_id'],
|
||||
'token_type' => $row['token_type'],
|
||||
@ -176,14 +177,24 @@ class Staking extends BaseModel {
|
||||
'txhash' => $row['txhash'],
|
||||
|
||||
'item_id' => $row['item_id'],
|
||||
'cec_value' => $stakingMeta['cec_value']
|
||||
);
|
||||
$yesterDay = myself()->_getNowDaySeconds() - 3600 * 24;
|
||||
$passedDays = intval((myself()->_getNowDaySeconds() -
|
||||
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']);
|
||||
$dto['daily_rewards'] = $dto['cec_value'] * $dailyInterest;
|
||||
if ($dto['remain_days'] <= 0 ) {
|
||||
$dto['cec_rewards'] = $dto['daily_rewards'] * $saveDays;
|
||||
$dto['total_rewards'] = $dto['daily_rewards'] * $saveDays;
|
||||
} else {
|
||||
$dto['cec_rewards'] = 0;
|
||||
$dto['total_rewards'] = $dto['daily_rewards'] * ($saveDays - $passedDays);
|
||||
}
|
||||
return $dto;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user