1
This commit is contained in:
parent
4871084992
commit
ee8fd40d10
@ -5,6 +5,7 @@ namespace models;
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/ChipQuality.php');
|
||||
require_once('mt/AttrHelper.php');
|
||||
require_once('services/NftService.php');
|
||||
|
||||
use mt;
|
||||
use phpcommon\SqlHelper;
|
||||
@ -47,6 +48,7 @@ class Bag extends BaseModel {
|
||||
{
|
||||
return array(
|
||||
'item_uniid' => $row['idx'],
|
||||
'token_id' => $row['token_id'],
|
||||
'item_id' => $row['item_id'],
|
||||
'item_num' => $row['item_num'],
|
||||
'attr' => emptyReplace(json_decode($row['rand_attr'], true), array()),
|
||||
@ -56,19 +58,38 @@ class Bag extends BaseModel {
|
||||
public static function all()
|
||||
{
|
||||
$itemList = array();
|
||||
self::getItemList(function ($row) use(&$itemList) {
|
||||
if ($row['item_num'] > 0) {
|
||||
array_push($itemList, $row);
|
||||
}
|
||||
});
|
||||
return $itemList;
|
||||
}
|
||||
|
||||
public static function getItemList($cb)
|
||||
{
|
||||
SqlHelper::ormSelect(
|
||||
myself()->_getSelfMysql(),
|
||||
$this->_getSelfMysql(),
|
||||
't_bag',
|
||||
array(
|
||||
'account_id' => myself()->_getAccountId()
|
||||
'account_id' => $this->_getAccountId()
|
||||
),
|
||||
function ($row) use(&$itemList) {
|
||||
if ($row['item_num'] > 0) {
|
||||
array_push($itemList, $row);
|
||||
}
|
||||
function ($row) use($cb) {
|
||||
$cb($row);
|
||||
}
|
||||
);
|
||||
return $itemList;
|
||||
foreach (services\NftService::getChips() as $nftDb) {
|
||||
$row = SqlHelper::ormSelectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_bag',
|
||||
array(
|
||||
'token_id' => $nftDb['token_id'],
|
||||
)
|
||||
);
|
||||
if ($row) {
|
||||
$cb($row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function getAttrs()
|
||||
|
Loading…
x
Reference in New Issue
Block a user