diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 88df4905..6283f8c9 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -30,44 +30,77 @@ class Chip extends BaseModel public static function getChipList($cb) { - $nft = SqlHelper::ormSelect( - myself()->_getMarketMysql(), - 't_nft', +// $nft = SqlHelper::ormSelect( +// myself()->_getMarketMysql(), +// 't_nft', +// array( +// 'owner_address' => myself()->_getOpenId(), +// 'token_type' =>Nft::CHIP_TYPE, +// 'deleted' => 0 +// ) +// ); +// foreach ($nft as $nftDb) { +// $row = SqlHelper::ormSelectOne( +// myself()->_getSelfMysql(), +// 't_chip', +// array( +// 'token_id' => $nftDb['token_id'], +// ) +// ); +// if (!$row) { +// $itemMeta = mt\Item::get($nftDb['item_id']); +// if ($itemMeta) { +// self::addChip($nftDb['item_id'], $nftDb['token_id']); +// $row = SqlHelper::ormSelectOne( +// myself()->_getSelfMysql(), +// 't_chip', +// array( +// 'token_id' => $nftDb['token_id'], +// ) +// ); +// } +// } +// if ($row) { +// $cb($row); +// } +// } + SqlHelper::ormSelect( + myself()->_getSelfMysql(), + 't_chip', array( - 'owner_address' => myself()->_getOpenId(), - 'token_type' =>Nft::CHIP_TYPE, - 'deleted' => 0 - ) - ); - error_log(json_encode( - array( - 'NFT___CHIP___COUNT'=> count($nft) - ) - )); - foreach ($nft as $nftDb) { - $row = SqlHelper::ormSelectOne( - myself()->_getSelfMysql(), - 't_chip', - array( - 'token_id' => $nftDb['token_id'], - ) - ); - if (!$row) { - $itemMeta = mt\Item::get($nftDb['item_id']); - if ($itemMeta) { - self::addChip($nftDb['item_id'], $nftDb['token_id']); - $row = SqlHelper::ormSelectOne( - myself()->_getSelfMysql(), - 't_chip', - array( - 'token_id' => $nftDb['token_id'], - ) - ); - } - } - if ($row) { + 'account_id' => myself()->_getAccountId() + ), + function ($row) use($cb) { $cb($row); } + ); + foreach (NftService::getChips(myself()->_getOpenId()) as $nftDb) { + if (! $nftDb['deleted']){ + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_chip', + array( + 'token_id' => $nftDb['token_id'], + ) + ); + if (!$row) { + $itemMeta = mt\Item::get($nftDb['item_id']); + if ($itemMeta) { + self::addChip($nftDb['item_id'], $nftDb['token_id']); + $row = SqlHelper::ormSelectOne( + myself()->_getSelfMysql(), + 't_chip', + array( + 'token_id' => $nftDb['token_id'], + ) + ); + } + + } + if ($row) { + $cb($row); + } + } } }