1
This commit is contained in:
parent
61827726dc
commit
8ebc8575eb
@ -4,7 +4,7 @@ namespace mt;
|
|||||||
|
|
||||||
use phpcommon;
|
use phpcommon;
|
||||||
|
|
||||||
class MarketBatch {
|
class BcShopBatch {
|
||||||
|
|
||||||
public static function get($id)
|
public static function get($id)
|
||||||
{
|
{
|
||||||
|
@ -1,2 +1,57 @@
|
|||||||
<?php
|
<?php
|
||||||
?>
|
|
||||||
|
namespace mt;
|
||||||
|
|
||||||
|
use phpcommon;
|
||||||
|
|
||||||
|
class MarketGoods {
|
||||||
|
|
||||||
|
public static function get($id)
|
||||||
|
{
|
||||||
|
return getXVal(self::getMetaList(), $id, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getBatchMetas($batchId)
|
||||||
|
{
|
||||||
|
self::mustBeBatchHash();
|
||||||
|
return getXVal(self::$batchHash, $batchId, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getOnSaleGoods($batchId, $idx, $itemId)
|
||||||
|
{
|
||||||
|
$metas = self::getBatchMetas($batchId);
|
||||||
|
if (!empty($metas)) {
|
||||||
|
foreach ($metas as $meta) {
|
||||||
|
if ($meta['id'] == $idx && $meta['item_id'] == $itemId) {
|
||||||
|
return $meta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static function getMetaList()
|
||||||
|
{
|
||||||
|
if (!self::$metaList) {
|
||||||
|
self::$metaList = getMetaTable('goods@bcshop.php');
|
||||||
|
}
|
||||||
|
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 $batchHash;
|
||||||
|
|
||||||
|
}
|
||||||
|
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
namespace mt;
|
namespace mt;
|
||||||
|
|
||||||
require_once('mt/AttrHelper.php');
|
|
||||||
require_once('mt/StrHelper.php');
|
|
||||||
|
|
||||||
use phpcommon;
|
use phpcommon;
|
||||||
|
|
||||||
class MarketGoods {
|
class MarketGoods {
|
||||||
@ -14,13 +11,6 @@ class MarketGoods {
|
|||||||
return getXVal(self::getMetaList(), $id, null);
|
return getXVal(self::getMetaList(), $id, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function traverseMeta($cb)
|
|
||||||
{
|
|
||||||
foreach (self::getMetaList() as $meta) {
|
|
||||||
$cb($meta);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function getBatchMetas($batchId)
|
public static function getBatchMetas($batchId)
|
||||||
{
|
{
|
||||||
self::mustBeBatchHash();
|
self::mustBeBatchHash();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user