This commit is contained in:
aozhiwei 2022-03-30 21:55:55 +08:00
parent 4871084992
commit ee8fd40d10

View File

@ -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()