This commit is contained in:
aozhiwei 2023-08-03 19:42:22 +08:00
parent 0da84fcf49
commit 115bd86382
2 changed files with 40 additions and 48 deletions

View File

@ -41,8 +41,6 @@ class Market(object):
'group': 'Market',
'url': 'webapp/index.php?c=Market&a=listMyNfts',
'params': [
['account', '', '账号id'],
['token', '', 'token'],
['start', 0, '分页开始偏移'],
['page_size', 0, '分页大小'],
['order_method', 0, '排序方式 0:默认排序(当前指向1) 1:等级 2:能量值 3:星级 4:tokenid'],
@ -148,22 +146,4 @@ class Market(object):
_common.RspHead()
]
},
{
'name': 'buyNft',
'desc': '购买NFT',
'group': 'Market',
'url': 'webapp/index.php?c=Market&a=buyNft',
'params': [
['account', '', '账号id'],
['token', '', 'token'],
['nft_token', '', 'nft_token'],
['payment_token_address', '', 'payment_token_address'],
['nonce', '', 'nonce'],
['signature', '', '签名soliditySha3(type, payment_token_address, price, nonce), 签名的replace客户端做处理'],
['net_id', '', '网络id'],
],
'response': [
_common.RspHead()
]
}
]

View File

@ -397,50 +397,62 @@ class MarketController extends BaseAuthedController
public function listMyNfts()
{
$account = strtolower(getReqVal('account', ''));
$token = getReqVal('token', '');
$start = getReqVal('start', 0);
$page_size = getReqVal('page_size', 10);
$order_method = getReqVal('order_method', 0);
$order_asc = getReqVal('order_asc', 1);
$type = getReqVal('type', 1);
$job_filters = getReqVal('job_filters', '');
$address = $this->_getAddress();
if ($address != $account) {
$this->_rspErr(1, 'account not match');
if (empty($address)) {
myself()->_rspData(array(
'total' => 0,
'start' => 0,
'page_size' => 0,
'nfts' => array()
));
return;
}
if (empty($job_filters)) {
$job_filter_array = array();
$start = getReqVal('start', 0);
$pageSize = getReqVal('page_size', 10);
$orderMethod = getReqVal('order_method', 0);
$orderAsc = getReqVal('order_asc', 1);
$type = getReqVal('type', 1);
$jobFilters = getReqVal('job_filters', '');
if (empty($jobFilters)) {
$jobFilterArray = array();
} else {
$job_filter_array = explode('|', $job_filters);
$jobFilterArray = explode('|', $jobFilters);
}
$search_filters = getReqVal('search_filters', '');
if ($search_filters != '') {
$search_filter_array = explode('|', $search_filters);
$searchFilters = getReqVal('search_filters', '');
if ($searchFilters != '') {
$searchFilterArray = explode('|', $searchFilters);
} else {
$search_filter_array = array();
$searchFilterArray = array();
}
$lv_filter = getReqVal('lv_filter', 0);
$quality_filter = getReqVal('quality_filter', 0);
$durability_filter = getReqVal('durability_filter', 0);
$lvFilter = getReqVal('lv_filter', 0);
$qualityFilter = getReqVal('quality_filter', 0);
$durabilityFilter = getReqVal('durability_filter', 0);
$rows = $this->getNftListByAccountAndType($account, $type, $order_method, $order_asc, $job_filter_array, $search_filter_array, $lv_filter, $quality_filter, $durability_filter);
$rows = $this->getNftListByAccountAndType(
$account,
$type,
$orderMethod,
$orderAsc,
$jobFilterArray,
$searchFilterArray,
$lvFilter,
$qualityFilter,
$durabilityFilter);
$total = count($rows);
$page_end = $start + $page_size;
if ($page_end > $total) {
$page_end = $total;
$pageEnd = $start + $pageSize;
if ($pageEnd > $total) {
$pageEnd = $total;
$start = $total - 1;
$start = intval($start / $page_size) * $page_size;
$start = intval($start / $pageSize) * $pageSize;
if ($start < 0) $start = 0;
}
$nfts = array();
for ($x = $start; $x < $page_end; $x++) {
for ($x = $start; $x < $pageEnd; $x++) {
$row = $rows[$x];
// $this->attach_market_selling($row);
array_push($nfts, $row);
@ -449,7 +461,7 @@ class MarketController extends BaseAuthedController
$this->_rspData(array(
"total" => $total,
"start" => $start,
"page_size" => $page_size,
"page_size" => $pageSize,
'nfts' => $nfts,
));
}