1
This commit is contained in:
parent
f09cf4c8b7
commit
9bd28deb0c
@ -6,6 +6,7 @@ require_once('mt/Item.php');
|
||||
require_once('mt/WhiteList.php');
|
||||
require_once('mt/Currency.php');
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/Parameter.php');
|
||||
|
||||
require_once('models/BoxOrder.php');
|
||||
require_once('models/Nft.php');
|
||||
@ -20,6 +21,11 @@ use models\BuyRecord;
|
||||
|
||||
const CURRENCY_DECIMALS = 8;
|
||||
|
||||
const PRESALE_NOT_STARTED = 0;
|
||||
const PRESALE_PREPARE = 1;
|
||||
const PRESALE_STARTED = 2;
|
||||
const PRESALE_SOLD_OUT = 3;
|
||||
|
||||
class MarketController extends BaseController {
|
||||
|
||||
private function isTestMode()
|
||||
@ -31,22 +37,36 @@ class MarketController extends BaseController {
|
||||
{
|
||||
$account = getReqVal('account', '');
|
||||
$currBatchMeta = mt\MarketBatch::getCurrentBatch();
|
||||
if (!$currBatchMeta) {
|
||||
myself()->_rspErr(500, 'server internal error');
|
||||
if ($currBatchMeta) {
|
||||
$presaleInfo = array(
|
||||
'batch_id' => 0,
|
||||
'countdown' => 0,
|
||||
'sold_num' => 0,
|
||||
'total_num' => 0,
|
||||
'state' => PRESALE_NOT_STARTED,
|
||||
'title' => $this->escapeString(mt\Parameter::getVal('pre_sale_not_started_title', '')),
|
||||
'hint' => $this->escapeString(mt\Parameter::getVal('pre_sale_not_started_hint', '')),
|
||||
'buyed' => 0
|
||||
);
|
||||
myself()->_rspData(array(
|
||||
'presale_info' => $presaleInfo
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
$countdown = max(0, $currBatchMeta['start_time'] - myself()->_getNowTime());
|
||||
$soldNum = min(BoxOrder::getSoldNum($currBatchMeta['id']), $currBatchMeta['number_of_props']);
|
||||
$buyed = $this->isTestMode() ? 0 : BoxOrder::isBuyed($account, $currBatchMeta['id']);
|
||||
$title = '';
|
||||
$state = 0;
|
||||
$presaleInfo = array(
|
||||
'batch_id' => $currBatchMeta['batch_id'],
|
||||
'countdown' => $countdown,
|
||||
'sold_num' => $soldNum,
|
||||
'total_num' => $currBatchMeta['number_of_props'],
|
||||
'state' => 2,
|
||||
'title' => '',
|
||||
'hint' => str_replace("\n", '\n', $currBatchMeta['hint']),
|
||||
'state' => $state,
|
||||
'title' => $title,
|
||||
'hint' => $this->escapeString($currBatchMeta['hint']),
|
||||
'buyed' => $buyed
|
||||
);
|
||||
|
||||
@ -339,4 +359,9 @@ class MarketController extends BaseController {
|
||||
return $nft;
|
||||
}
|
||||
|
||||
private function escapeString($str)
|
||||
{
|
||||
return str_replace("\n", '\n', $str);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user