This commit is contained in:
aozhiwei 2023-08-25 13:18:34 +08:00
parent 017db6c828
commit 535ae88000
2 changed files with 43 additions and 1 deletions

View File

@ -84,6 +84,7 @@ CREATE TABLE `t_staking` (
`unstake_time` bigint NOT NULL DEFAULT '0' COMMENT '解押结束时间',
`status` int(11) NOT NULL COMMENT '0:质押中 1:已解押',
`txhash` varchar(255) NOT NULL DEFAULT '' COMMENT 'txhash',
`nft_type` int(11) NOT NULL COMMENT '',
`ceg_value` double NOT NULL DEFAULT '0' COMMENT 'ceg价值',
`ceg_reward` double NOT NULL DEFAULT '0' COMMENT '利息',
`createtime` int(11) NOT NULL COMMENT '创建时间',

View File

@ -7,6 +7,8 @@ class Staking extends BaseModel {
const STAKING_STATUS = 0;
const UNSTAKE_STATUS = 1;
const NFT721 = 1;
public static function all($address)
{
$rows = SqlHelper::ormSelect(
@ -45,17 +47,51 @@ class Staking extends BaseModel {
'start_time' => $info['start'],
'stake_time' => $info['stakeTime'],
'status' => self::STAKING_STATUS,
'nft_type' => self::NFT721,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
$itemId = 0;
$tokenType = 0;
self::repair721NftInfo($info['tokenid'], $info['nft'], $netId, $info['start'],
$itemId, $tokenId);
}
}
public static function repair721NftInfo($tokenId, $contractAddress, $netId, $startTime,
&$itemId, &$tokenType)
{
$row = SqlHelper::ormSelect(
myself()->_getMarketMysql(),
't_nft',
array(
'token_id' => $tokenId,
'contract_address' => $contractAddress,
'net_id' => $netId,
)
);
if (!$row) {
return false;
}
$itemId = $row['item_id'];
$tokenType = $row['token_type'];
SqlHelper::update(
myself()->_getMysql(''),
't_staking',
array(
'token_id' => $tokenId,
'contract_address' => $contractAddress,
'net_id' => $netId,
'start_time' => $startTime,
'nft_type' => self::NFT721,
),
array(
'item_id' => $itemId,
'token_type' => $tokenType
)
);
return true;
}
public static function redeem721($data, $netId, $unstakeTime)
@ -86,10 +122,15 @@ class Staking extends BaseModel {
'stake_time' => $info['stakeTime'],
'unstake_time' => $unstakeTime,
'status' => self::UNSTAKE_STATUS,
'nft_type' => self::NFT721,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
$itemId = 0;
$tokenType = 0;
self::repair721NftInfo($info['tokenid'], $info['nft'], $netId, $info['start'],
$itemId, $tokenId);
}
}