1
This commit is contained in:
parent
af04637a82
commit
e0983bfb56
@ -6,10 +6,7 @@ require_once('mt/Item.php');
|
||||
require_once('mt/WhiteList.php');
|
||||
require_once('mt/Currency.php');
|
||||
|
||||
require_once('models/Goods.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Goods;
|
||||
|
||||
class MarketController extends BaseController {
|
||||
|
||||
@ -37,8 +34,8 @@ class MarketController extends BaseController {
|
||||
'batch_id' => $currBatchMeta['batch_id'],
|
||||
'countdown' => max(0, $currBatchMeta['_start_time_utc'] - myself()->_getNowTime()),
|
||||
'sold_num' => 0,
|
||||
'inventory_num' => 0,
|
||||
'hint' => $currBatchMeta['hint'],
|
||||
'inventory_num' => $currBatchMeta['number_of_props'],
|
||||
'hint' => str_replace("\n", '\n', $currBatchMeta['hint']),
|
||||
'buyed' => rand() % 2 < 1 ? 0 : 1
|
||||
);
|
||||
|
||||
|
@ -6,10 +6,7 @@ require_once('mt/Item.php');
|
||||
require_once('mt/WhiteList.php');
|
||||
require_once('mt/Currency.php');
|
||||
|
||||
require_once('models/Goods.php');
|
||||
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Goods;
|
||||
|
||||
class NewMarketController extends BaseController {
|
||||
|
||||
@ -37,8 +34,8 @@ class NewMarketController extends BaseController {
|
||||
'batch_id' => $currBatchMeta['batch_id'],
|
||||
'countdown' => max(0, $currBatchMeta['_start_time_utc'] - myself()->_getNowTime()),
|
||||
'sold_num' => 0,
|
||||
'inventory_num' => 0,
|
||||
'hint' => $currBatchMeta['hint'],
|
||||
'inventory_num' => $currBatchMeta['number_of_props'],
|
||||
'hint' => str_replace("\n", '\n', $currBatchMeta['hint']),
|
||||
'buyed' => rand() % 2 < 1 ? 0 : 1
|
||||
);
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace models;
|
||||
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/ChipQuality.php');
|
||||
require_once('mt/AttrHelper.php');
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
|
||||
class Goods extends BaseModel {
|
||||
|
||||
public static function getRemainBuyableNum($goodsMeta)
|
||||
{
|
||||
self::mustByBuyedNumHash();
|
||||
return max(0, $goodsMeta['number_of_props'] - getXVal(self::$buyedNumHash, $goodsMeta['id'], 0));
|
||||
}
|
||||
|
||||
private static function mustByBuyedNumHash()
|
||||
{
|
||||
if (!is_null(self::$buyedNumHash)) {
|
||||
return;
|
||||
}
|
||||
$rows = myself()->_getMarketMysql()->execQuery
|
||||
('SELECT goods_id, count(goods_idx) AS num FROM t_goods WHERE state=1 GROUP BY goods_id;',
|
||||
array(
|
||||
|
||||
));
|
||||
self::$buyedNumHash = array();
|
||||
foreach ($rows as $row) {
|
||||
self::$buyedNumHash[$row['goods_id']] = $row['num'];
|
||||
}
|
||||
}
|
||||
|
||||
private static $buyedNumHash;
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user