149 lines
4.7 KiB
PHP
149 lines
4.7 KiB
PHP
<?php
|
|
|
|
require_once('mt/MarketGoods.php');
|
|
require_once('mt/MarketBatch.php');
|
|
require_once('mt/Item.php');
|
|
require_once('mt/WhiteList.php');
|
|
require_once('mt/Currency.php');
|
|
require_once('mt/Hero.php');
|
|
|
|
use phpcommon\SqlHelper;
|
|
|
|
class MarketController extends BaseController {
|
|
|
|
public function searchBox()
|
|
{
|
|
$page = getReqVal('page', 1);
|
|
$type = getReqVal('type', 0);
|
|
$sort = getReqVal('sort', '');
|
|
|
|
$currBatchMeta = mt\MarketBatch::getCurrentBatch();
|
|
if (!$currBatchMeta) {
|
|
myself()->_rspErr(500, 'server internal error');
|
|
return;
|
|
}
|
|
|
|
$rows = array();
|
|
$pageInfo = array(
|
|
'total' => 0,
|
|
'count' => 0,
|
|
'per_page' => 10,
|
|
'current_page' => $page,
|
|
'total_pages' => 0
|
|
);
|
|
$presaleInfo = array(
|
|
'batch_id' => $currBatchMeta['batch_id'],
|
|
'countdown' => max(0, $currBatchMeta['_start_time_utc'] - myself()->_getNowTime()),
|
|
'sold_num' => 0,
|
|
'inventory_num' => $currBatchMeta['number_of_props'],
|
|
'hint' => str_replace("\n", '\n', $currBatchMeta['hint']),
|
|
'buyed' => rand() % 2 < 1 ? 0 : 1
|
|
);
|
|
|
|
$batchMetas = mt\MarketGoods::getBatchMetas($currBatchMeta['batch_id']);
|
|
if ($batchMetas) {
|
|
foreach ($batchMetas as $meta) {
|
|
$saleBox = array(
|
|
'box_id' => $meta['item_id'],
|
|
'item_id' => $meta['item_id'],
|
|
'name' => emptyReplace($heroMeta['name'], 'Hill'),
|
|
'job' => emptyReplace($heroMeta['hero_job'], 'Warrior'),
|
|
'currency_list' => array(
|
|
array(
|
|
'name' => 'BNB',
|
|
'original_price' => 100,
|
|
'discount_price' => 80,
|
|
'discount_rate' => 80,
|
|
'contract_address' => '0xCfEB869F69431e42cdB54A4F4f105C19C080A601',
|
|
)
|
|
)
|
|
);
|
|
++$pageInfo['total'];
|
|
if ($pageInfo['total'] > $pageInfo['per_page'] * ($pageInfo['current_page'] - 1) &&
|
|
count($rows) < $pageInfo['per_page']) {
|
|
array_push($rows, $saleBox);
|
|
}
|
|
}
|
|
}
|
|
|
|
$pageInfo['count'] = count($rows);
|
|
$pageInfo['total_pages'] = ceil($pageInfo['total'] / $pageInfo['per_page']);
|
|
myself()->_rspData(array(
|
|
'rows' => $rows,
|
|
'page' => $pageInfo,
|
|
'presale_info' => $presaleInfo,
|
|
));
|
|
}
|
|
|
|
public function buyBox()
|
|
{
|
|
myself()->_rspOk();
|
|
}
|
|
|
|
public function getNftList()
|
|
{
|
|
$account = getReqVal('account', '');
|
|
$nftList = array();
|
|
for ($i = 0; $i < 10; ++$i) {
|
|
$nft = array(
|
|
'token_id' => $i + 1,
|
|
'owner_address' => $account,
|
|
'owner_name' => '',
|
|
'item_id' => 30100 + $i * 100,
|
|
'currency_list' => array(),
|
|
'transaction_recrod' => array(),
|
|
'info' => array(
|
|
'name' => 'hero' . $i,
|
|
'job' => 'Warrior',
|
|
'level' => 1,
|
|
'quality' => 1,
|
|
'hp' => 100,
|
|
'speed' => 100,
|
|
'atk' => 1,
|
|
'def' => 100,
|
|
'advanced_count' => 0,
|
|
'lucky' => 0,
|
|
'success_rate' => 0
|
|
),
|
|
'mint_time' => myself()->_getNowTime()
|
|
);
|
|
array_push($nftList, $nft);
|
|
}
|
|
myself()->_rspData(array(
|
|
'nfts' => $nftList
|
|
));
|
|
}
|
|
|
|
public function getNftDetail()
|
|
{
|
|
$account = getReqVal('account', '');
|
|
$i = 0;
|
|
$nft = array(
|
|
'token_id' => $i + 1,
|
|
'owner_address' => $account,
|
|
'owner_name' => '',
|
|
'item_id' => 30100 + $i * 100,
|
|
'currency_list' => array(),
|
|
'transaction_recrod' => array(),
|
|
'info' => array(
|
|
'name' => 'hero' . $i,
|
|
'job' => 'Warrior',
|
|
'level' => 1,
|
|
'quality' => 1,
|
|
'hp' => 100,
|
|
'speed' => 100,
|
|
'atk' => 1,
|
|
'def' => 100,
|
|
'advanced_count' => 0,
|
|
'lucky' => 0,
|
|
'success_rate' => 0
|
|
),
|
|
'mint_time' => myself()->_getNowTime()
|
|
);
|
|
myself()->_rspData(array(
|
|
'info' => $nft
|
|
));
|
|
}
|
|
|
|
}
|