From ee8fd40d108a379ef08da3a1c7b84fc7ff814c4e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 30 Mar 2022 21:55:55 +0800 Subject: [PATCH] 1 --- webapp/models/Bag.php | 35 ++++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/webapp/models/Bag.php b/webapp/models/Bag.php index bc834406..06c10dba 100644 --- a/webapp/models/Bag.php +++ b/webapp/models/Bag.php @@ -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()