1
This commit is contained in:
parent
e262c8ce1e
commit
61827726dc
@ -1,7 +1,5 @@
|
||||
<?php
|
||||
|
||||
require_once('mt/MarketGoods.php');
|
||||
require_once('mt/MarketBatch.php');
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/Currency.php');
|
||||
require_once('mt/Hero.php');
|
||||
|
66
webapp/mt/BcShopBatch.php
Normal file
66
webapp/mt/BcShopBatch.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace mt;
|
||||
|
||||
use phpcommon;
|
||||
|
||||
class MarketBatch {
|
||||
|
||||
public static function get($id)
|
||||
{
|
||||
return getXVal(self::getMetaList(), $id, null);
|
||||
}
|
||||
|
||||
public static function getCurrentBatch()
|
||||
{
|
||||
self::mustBeSortedList();
|
||||
$currentMeta = null;
|
||||
foreach (self::$sortedList as $meta) {
|
||||
if (!$currentMeta) {
|
||||
$currentMeta = $meta;
|
||||
continue;
|
||||
}
|
||||
if (myself()->_getNowTime() > $meta['start_time']) {
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
return $currentMeta;
|
||||
}
|
||||
|
||||
public static function getCountdown($meta)
|
||||
{
|
||||
$countdown = max(0, $currBatchMeta['start_time'] - myself()->_getNowTime());
|
||||
return $countdown;
|
||||
}
|
||||
|
||||
protected static function getMetaList()
|
||||
{
|
||||
if (!self::$metaList) {
|
||||
self::$metaList = getMetaTable('batch@bcshop.php');
|
||||
}
|
||||
return self::$metaList;
|
||||
}
|
||||
|
||||
protected static function mustBeSortedList()
|
||||
{
|
||||
if (!self::$sortedList) {
|
||||
self::$sortedList = array();
|
||||
foreach (self::getMetaList() as $meta) {
|
||||
array_push(self::$sortedList, $meta);
|
||||
}
|
||||
usort(self::$sortedList, function ($a, $b) {
|
||||
if ($a['start_time'] == $b['start_time']) {
|
||||
die(json_encode(array(
|
||||
'errcode' => 500,
|
||||
'errmsg' => 'server internal error'
|
||||
)));
|
||||
}
|
||||
return $a['start_time'] < $b['start_time'];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected static $metaList;
|
||||
protected static $sortedList;
|
||||
|
||||
}
|
2
webapp/mt/BcShopGoods.php
Normal file
2
webapp/mt/BcShopGoods.php
Normal file
@ -0,0 +1,2 @@
|
||||
<?php
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user