searchSys(); } else { $this->_rspData(array( 'rows' => array(), 'page' => array( 'total' => 0, 'count' => 0, 'per_page' => 10, 'current_page' => 1, 'total_pages' => 0 ) )); } } public function buy() { } public function prebuy() { } public function sell() { } public function detail() { } private function searchSys() { $page = getReqVal('page', 1); $type = getReqVal('type', 0); $sort = getReqVal('sort', ''); $rows = array(); $pageInfo = array( 'total' => 0, 'count' => 0, 'per_page' => 10, 'current_page' => $page, 'total_pages' => 0 ); mt\Market::traverseMeta(function ($meta) use(&$rows, &$pageInfo) { $remainBuyableNum = Goods::getRemainBuyableNum($meta); if ($remainBuyableNum > 0) { ++$pageInfo['total']; if ($pageInfo['total'] >= $pageInfo['per_page'] * $pageInfo['current_page'] && count($rows) < $pageInfo['per_page']) { array_push($rows, $this->wrapNft($meta, $remainBuyableNum)); } } }); $pageInfo['count'] = count($rows); $pageInfo['total_pages'] = ceil($pageInfo['total'] / $pageInfo['per_page']); $this->_rspData(array( 'rows' => $rows, 'page' => $pageInfo )); } private function wrapNft($meta, $inventory) { $nft = array(); $nft['goods_id'] = 0; $nft['nft_id'] = ''; $nft['type'] = 0; $nft['token_id'] = ''; $nft['status'] = 0; $nft['inventory'] = 0; $nft['owner_address'] = ''; $nft['owner_id'] = ''; $nft['image_avatar'] = ''; $nft['image_full'] = ''; $nft['price'] = array( 'type' => 0, 'name' => '', 'value' => 0, 'decimals' => 0 ); $nft['created_at'] = 0; $nft['last_modified_at'] = 0; return $nft; } }