From 83668e039babb35139e6ba880c55100c21c523d8 Mon Sep 17 00:00:00 2001 From: hujiabin Date: Thu, 15 Dec 2022 14:58:43 +0800 Subject: [PATCH] 1 --- webapp/models/Fragment.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/webapp/models/Fragment.php b/webapp/models/Fragment.php index 6b446179..88ab16db 100644 --- a/webapp/models/Fragment.php +++ b/webapp/models/Fragment.php @@ -23,6 +23,27 @@ class Fragment extends BaseModel } public static function ToDto($row){ + $itemMeta = mt\Item::get($row['token_id']); + $name = 'XXX'; + $type=0; + if ($itemMeta && $itemMeta['type'] == mt\Item::FRAGMENT_TYPE){ + $name = $itemMeta['name']; + switch ($itemMeta['sub_type']){ + case 1 : + $type=1; + break; + case 2 : + $type = 2; + break; + case 3 : + $type=1; + break; + case 4 : + $type=2; + break; + default:$type=0; + } + } $dto = array( // 'owner_address' => $row['owner_address'], 'token_id' => $row['token_id'], @@ -36,7 +57,8 @@ class Fragment extends BaseModel $nft_address = SERVER_ENV == _ONLINE ? '0xFc21A863bFb4E4534B246078772e2074e076f0a7' : '0x0E696947A06550DEf604e82C26fd9E493e576337'; } $dto['nft_address'] = $nft_address; - $dto['name'] = mt\Item::get($row['token_id'])?mt\Item::get($row['token_id'])['name']:'XXX'; + $dto['name'] = $name; + $dto['type'] = $type; return $dto; }