This commit is contained in:
aozhiwei 2023-08-28 12:06:28 +08:00
parent 31b87c2643
commit 68050c0079

View File

@ -3,12 +3,12 @@
require_once("mt/Staking.php"); require_once("mt/Staking.php");
require_once("models/Nft.php"); require_once("models/Nft.php");
require_once("models/Stacking.php"); require_once("models/Staking.php");
use models\Nft; use models\Nft;
use models\Statcking; use models\Staking;
class StackingController extends BaseAuthedController { class StakingController extends BaseAuthedController {
const PLANET_TYPE = 1; const PLANET_TYPE = 1;
const BADGE_TYPE = 2; const BADGE_TYPE = 2;
@ -32,14 +32,14 @@ class StackingController extends BaseAuthedController {
'is_open' => 0 'is_open' => 0
), ),
); );
$rows = Stacking::all(myself()->_getAddress()); $rows = Staking::all(myself()->_getAddress());
$this->fillStackingInfo($info, 'planet', $rows); $this->fillStakingInfo($info, 'planet', $rows);
$this->fillStackingInfo($info, 'badge', $rows); $this->fillStakingInfo($info, 'badge', $rows);
$this->fillStackingInfo($info, 'cec', $rows); $this->fillStakingInfo($info, 'cec', $rows);
myself()->_rspData($info); myself()->_rspData($info);
} }
private function fillStackingInfo(&$info, $fieldName, $rows) private function fillStakingInfo(&$info, $fieldName, $rows)
{ {
$stackingInfo = $info[$fieldName]; $stackingInfo = $info[$fieldName];
$stackingInfo['staked_quant'] = 0; $stackingInfo['staked_quant'] = 0;
@ -51,7 +51,7 @@ class StackingController extends BaseAuthedController {
$stakingMeta = mt\Staking::get($row['item_id']); $stakingMeta = mt\Staking::get($row['item_id']);
if ($this->isTypeNft($stackingInfo['type'], $row) && $stakingMeta) { if ($this->isTypeNft($stackingInfo['type'], $row) && $stakingMeta) {
$stakingDto = Staking::toDto($row); $stakingDto = Staking::toDto($row);
if ($stakingDto['status'] == Stacking::STAKING_STATUS) { if ($stakingDto['status'] == Staking::STAKING_STATUS) {
if ($stakingDto['remain_days'] <= 0) { if ($stakingDto['remain_days'] <= 0) {
$stackingInfo['maturity_quant'] += $stakingDto['stacked_num']; $stackingInfo['maturity_quant'] += $stakingDto['stacked_num'];
} else { } else {
@ -75,11 +75,11 @@ class StackingController extends BaseAuthedController {
$type = getReqVal('type', ''); $type = getReqVal('type', '');
$stackedQuant = 0; $stackedQuant = 0;
$items = array(); $items = array();
$rows = Stacking::all(myself()->_getAddress()); $rows = Staking::all(myself()->_getAddress());
foreach ($rows as $row) { foreach ($rows as $row) {
if ($row['status'] == Stacking::STAKING_STATUS) { if ($row['status'] == Staking::STAKING_STATUS) {
if ($this->isTypeNft($type, $row)) { if ($this->isTypeNft($type, $row)) {
array_push($items, Stacking::toDto($info)); array_push($items, Staking::toDto($info));
++$stackedQuant; ++$stackedQuant;
} }
} }
@ -96,9 +96,9 @@ class StackingController extends BaseAuthedController {
$items = array(); $items = array();
$fromTime = getReqVal('from_time', ''); $fromTime = getReqVal('from_time', '');
$toTime = getReqVal('to_time', ''); $toTime = getReqVal('to_time', '');
$rows = Stacking::all(myself()->_getAddress()); $rows = Staking::all(myself()->_getAddress());
foreach ($rows as $row) { foreach ($rows as $row) {
if ($row['status'] == Stacking::REDEEM_STATUS) { if ($row['status'] == Staking::REDEEM_STATUS) {
array_push($items, Staking::toDto($info)); array_push($items, Staking::toDto($info));
} }
} }