game2006api/webapp/models/Staking.php
aozhiwei 017db6c828 1
2023-08-25 12:52:19 +08:00

97 lines
3.0 KiB
PHP

<?php
namespace models;
class Staking extends BaseModel {
const STAKING_STATUS = 0;
const UNSTAKE_STATUS = 1;
public static function all($address)
{
$rows = SqlHelper::ormSelect(
myself()->_getMysql(''),
't_staking',
array(
'address' => $address
)
);
return $rows;
}
public static function staked721($data, $netId)
{
$address = $data['address'];
foreach ($data['infos'] as $info) {
SqlHelper::upsert(
myself()->_getMysql(''),
't_staking',
array(
'token_id' => $info['tokenid'],
'contract_address' => $info['nft'],
'net_id' => $netId,
'start_time' => $info['start'],
),
array(
),
array(
'address' => $address,
'token_id' => $info['tokenid'],
'token_type' => '0',
'net_id' => $netId,
'contract_address' => $info['nft'],
'stacked_num' => 1,
'start_time' => $info['start'],
'stake_time' => $info['stakeTime'],
'status' => self::STAKING_STATUS,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
}
}
public static function repair721NftInfo($tokenId, $contractAddress, $netId, $startTime,
&$itemId, &$tokenType)
{
}
public static function redeem721($data, $netId, $unstakeTime)
{
$address = $data['address'];
foreach ($data['infos'] as $info) {
SqlHelper::upsert(
myself()->_getMysql(''),
't_staking',
array(
'token_id' => $info['tokenid'],
'contract_address' => $info['nft'],
'net_id' => $netId,
'start_time' => $info['start'],
),
array(
'unstake_time' => $unstakeTime,
'status' => self::UNSTAKE_STATUS,
),
array(
'address' => $address,
'token_id' => $info['tokenid'],
'token_type' => '0',
'net_id' => $netId,
'contract_address' => $info['nft'],
'stacked_num' => 1,
'start_time' => $info['start'],
'stake_time' => $info['stakeTime'],
'unstake_time' => $unstakeTime,
'status' => self::UNSTAKE_STATUS,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
}
}
}