From d238a699e932c7016bdf0a037910d16e125396da Mon Sep 17 00:00:00 2001 From: azw Date: Sun, 27 Aug 2023 16:08:06 +0800 Subject: [PATCH] 1 --- webapp/models/Staking.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/webapp/models/Staking.php b/webapp/models/Staking.php index 6bc9c1c9..4a765036 100644 --- a/webapp/models/Staking.php +++ b/webapp/models/Staking.php @@ -164,6 +164,29 @@ class Staking extends BaseModel { } } + public static function toDto($row) + { + $dto = array( + 'token_id' => $row['token_id'], + 'token_type' => $row['token_type'], + 'contract_address' => $row['contract_address'], + 'net_id' => $row['net_id'], + 'start_time' => $row['start_time'], + 'stake_time' => $row['stake_time'], + 'txhash' => $row['txhash'], + + 'item_id' => $row['item_id'], + ); + $yesterDay = myself()->_getNowDaySeconds() - 3600 * 24; + $passedDays = intval((myself()->_getNowDaySeconds() - + myself()->_getDaySeconds($row['start_time'])) / + 3600 / 24); + $saveDays = intval($row['stake_time'] / 3600 / 24); + $dto['stacked_days'] = max(0, $passedDays); + $dto['remain_days'] = max(0, $saveDays - $dto['stacked_days']); + return $dto; + } + public static function calcReward($row, &$reward) { $reward = 0;