1
This commit is contained in:
parent
0811688c39
commit
5a93f1ed81
@ -45,7 +45,7 @@ class SystemCurrency(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.fields = [
|
self.fields = [
|
||||||
['name', '', '货币名称'],
|
['name', '', '货币名称'],
|
||||||
['original price', 0, '原价'],
|
['original_price', 0, '原价'],
|
||||||
['discount_price', 0, '折后价'],
|
['discount_price', 0, '折后价'],
|
||||||
['discount_rate', 0, '折扣百分比(0-100)'],
|
['discount_rate', 0, '折扣百分比(0-100)'],
|
||||||
['contract_address', 0, '合约地址'],
|
['contract_address', 0, '合约地址'],
|
||||||
|
@ -15,20 +15,131 @@ class MarketController extends BaseController {
|
|||||||
|
|
||||||
public function searchBox()
|
public function searchBox()
|
||||||
{
|
{
|
||||||
$currBatch = mt\MarketBatch::getCurrentBatch();
|
$page = getReqVal('page', 1);
|
||||||
myself()->_rspData($currBatch);
|
$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' => 0,
|
||||||
|
'hint' => $currBatchMeta['hint'],
|
||||||
|
'buyed' => 0
|
||||||
|
);
|
||||||
|
|
||||||
|
$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'],
|
||||||
|
'currency_list' => array(
|
||||||
|
array(
|
||||||
|
'name' => 'BNB',
|
||||||
|
'original_price' => 100,
|
||||||
|
'discount_price' => 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()
|
public function buyBox()
|
||||||
{
|
{
|
||||||
|
myself()->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getNftList()
|
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,
|
||||||
|
'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()
|
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,
|
||||||
|
'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
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,12 @@ class MarketGoods {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getBatchMetas($batchId)
|
||||||
|
{
|
||||||
|
self::mustBeBatchHash();
|
||||||
|
return getXVal(self::$batchHash, $batchId, null);
|
||||||
|
}
|
||||||
|
|
||||||
protected static function getMetaList()
|
protected static function getMetaList()
|
||||||
{
|
{
|
||||||
if (!self::$metaList) {
|
if (!self::$metaList) {
|
||||||
@ -29,6 +35,20 @@ class MarketGoods {
|
|||||||
return self::$metaList;
|
return self::$metaList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected static function mustBeBatchHash()
|
||||||
|
{
|
||||||
|
if (!self::$batchHash) {
|
||||||
|
self::$batchHash = array();
|
||||||
|
self::traverseMeta(function ($meta) {
|
||||||
|
if (!getXVal(self::$batchHash, $meta['batch_id'], null)) {
|
||||||
|
self::$batchHash[$meta['batch_id']] = array();
|
||||||
|
}
|
||||||
|
array_push(self::$batchHash[$meta['batch_id']], $meta);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected static $metaList;
|
protected static $metaList;
|
||||||
|
protected static $batchHash;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user