Merge branch 'hjb' of git.kingsome.cn:server/game2006api into hjb

This commit is contained in:
hujiabin 2023-08-28 16:25:51 +08:00
commit 1d4116aa91
6 changed files with 66 additions and 3 deletions

View File

@ -66,7 +66,23 @@ class Staking(object):
'response': [
_common.RspHead(),
['cec_rewards', 0, '该nft结算得到的ceg数量'],
['state', 0, '0:提前赎回 1:到期赎回'],
]
},
{
'name': 'stakingPreview',
'desc': '质押预览',
'group': 'Staking',
'url': 'webapp/index.php?c=Staking&a=stakingPreview',
'params': [
_common.ReqHead(),
['token_id_list', '', 'token_id多个|分割'],
['contract_address_list', '', 'contract_address多个|分割'],
['net_id', '', 'net_id'],
],
'response': [
_common.RspHead(),
['nft_value', 0, 'nft价值'],
['!items', [_common.StakingPreview()], ''],
]
},
]

View File

@ -1454,3 +1454,11 @@ class StakingDetail(object):
['stacked_days', 0, '该nft质押的总天数'],
['remain_days', 0, '该nft剩余质押天数'],
]
class StakingPreview(object):
def __init__(self):
self.fields = [
['time', 0, '天数'],
['interest', 0, '利息'],
]

View File

@ -81,6 +81,7 @@ CREATE TABLE `t_staking` (
`address` varchar(60) NOT NULL DEFAULT '' COMMENT 'address',
`order_id` varchar(60) COMMENT 'order_id',
`token_id` varchar(60) NOT NULL DEFAULT '' COMMENT 'token_id',
`item_id` int(11) NOT NULL COMMENT 'item_id',
`token_type` int(11) NOT NULL DEFAULT '0' COMMENT 'nft类型 1:英雄 2:枪支 3:芯片 6:荣誉 7:徽章',
`net_id` bigint NOT NULL DEFAULT '0' COMMENT 'net_id',
`contract_address` varchar(60) NOT NULL DEFAULT '' COMMENT 'contract_address',

View File

@ -181,6 +181,9 @@ class BaseAuthedController extends BaseController {
$this->addressActived = true;
if (SERVER_ENV != _ONLINE && empty($this->address)) {
$this->address = strtolower('0xa9ecB9F3A0b54d31ce4a035C89EC7Da4110beB59');
if (myself()->_getAccountId() == '6513_2006_3WOWIsmpcihK1KTnNP1Ky5MBOh7rt6Rl') {
$this->address = strtolower('0x0bb52209756e8d157f2e551a9adb8d9019b688b1');
}
}
}
return $this->address;

View File

@ -79,7 +79,7 @@ class StakingController extends BaseAuthedController {
foreach ($rows as $row) {
if ($row['status'] == Staking::STAKING_STATUS) {
if ($this->isTypeNft($type, $row)) {
array_push($items, Staking::toDto($info));
array_push($items, Staking::toDto($row));
++$stackedQuant;
}
}
@ -112,6 +112,33 @@ class StakingController extends BaseAuthedController {
$transId = getReqVal('trans_id', 0);
}
public function stakingPreview()
{
$tokenIdList = getReqVal('token_id_list', '');
$contractAddressList = getReqVal('contract_address_list', '');
$netId = getReqVal('net_id', '');
if (count($tokenIdList) <= 0) {
myself()->_rspErr(1, 'paramater error');
return;
}
if (count($tokenIdList) != count($contractAddressList)) {
myself()->_rspErr(1, 'paramater error');
return;
}
$confirmedNfts = array();
{
$nftList = Nft::getNftList(myself()-_getAddress());
foreach ($nftList as $nft) {
if (in_array(
$nft['token_id'],
$tokenIdList
)) {
array_push($confirmedNfts, $nft);
}
}
}
}
private function isTypeNft($type, $dbInfo)
{
switch ($type) {

View File

@ -4,8 +4,12 @@ namespace models;
require_once("mt/Staking.php");
require_once("models/User.php");
use phpcommon\SqlHelper;
use mt;
class Staking extends BaseModel {
const STAKING_STATUS = 0;
@ -64,6 +68,7 @@ class Staking extends BaseModel {
$tokenId = $info[2];
$startTime = $info[3];
$stakeTime = $info[4];
$userDb = User::findByAddress($address);
SqlHelper::upsert(
myself()->_getMysql(''),
't_staking',
@ -77,6 +82,7 @@ class Staking extends BaseModel {
),
array(
'account_id' => $userDb ? $userDb['account_id'] : '',
'address' => $address,
'token_id' => $tokenId,
'token_type' => '0',
@ -101,7 +107,7 @@ class Staking extends BaseModel {
public static function repair721NftInfo($tokenId, $contractAddress, $netId, $startTime,
&$itemId, &$tokenType)
{
$row = SqlHelper::ormSelect(
$row = SqlHelper::ormSelectOne(
myself()->_getMarketMysql(),
't_nft',
array(
@ -141,6 +147,7 @@ class Staking extends BaseModel {
$tokenId = $info[2];
$startTime = $info[3];
$stakeTime = $info[4];
$userDb = User::findByAddress($address);
SqlHelper::upsert(
myself()->_getMysql(''),
't_staking',
@ -156,6 +163,7 @@ class Staking extends BaseModel {
'status' => self::REDEEM_STATUS,
),
array(
'account_id' => $userDb ? $userDb['account_id'] : '',
'address' => $address,
'token_id' => $tokenId,
'token_type' => '0',