This commit is contained in:
aozhiwei 2022-04-02 16:16:45 +08:00
parent 831bca8455
commit bbefbf1303
2 changed files with 15 additions and 9 deletions

View File

@ -32,24 +32,23 @@ class MarketController extends BaseController {
const PRESALE_STARTED = 2;
const PRESALE_SOLD_OUT = 3;
private function isTestMode()
{
return isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443 && SERVER_ENV == _TEST;
}
public function getPreSaleInfo()
{
$account = getReqVal('account', '');
$currBatchMeta = mt\MarketBatch::getCurrentBatch();
if (!$currBatchMeta) {
$title = $this->escapeString(
mt\Parameter::getVal('pre_sale_not_started_title', ''));
$hint = $this->escapeString(
mt\Parameter::getVal('pre_sale_not_started_hint', ''));
$presaleInfo = array(
'batch_id' => 0,
'countdown' => 0,
'sold_num' => 0,
'total_num' => 0,
'state' => self::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', '')),
'title' => $title,
'hint' => $hint,
'buyable_list' => array(),
//'buyed' => 0
);
@ -62,7 +61,7 @@ class MarketController extends BaseController {
$countdown = max(0, $currBatchMeta['start_time'] - myself()->_getNowTime());
$soldNum = min(BoxOrder::getSoldNum($currBatchMeta['id']), $currBatchMeta['number_of_props']);
$totalNum = $currBatchMeta['number_of_props'];
$buyed = $this->isTestMode() ? 0 : BoxOrder::isBuyed($account, $currBatchMeta['id']);
$buyed = MarketService::isTestMode() ? 0 : BoxOrder::isBuyed($account, $currBatchMeta['id']);
$title = '';
$state = self::PRESALE_PREPARE;
if ($countdown > 0) {
@ -287,7 +286,7 @@ class MarketController extends BaseController {
return;
}
/*if (!$this->isTestMode() && BoxOrder::isBuyed($buyerAddress, $currBatchMeta['id'])) {
/*if (!MarketService::isTestMode() && BoxOrder::isBuyed($buyerAddress, $currBatchMeta['id'])) {
myself()->_rspErr(1, 'account can only choose 1 hero to purchase');
return;
}*/

View File

@ -2,10 +2,17 @@
namespace services;
require_once('mt/Parameter.php');
class MarketService extends BaseService {
const TOKEN_SALT = 'B8E6BD4F-FD7B-E2B8-6688-80A2D8632064';
public static function isTestMode()
{
return isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443 && SERVER_ENV == _TEST;
}
public static function isValidToken($account, $token)
{
$deToken = base64_decode($token);