diff --git a/webapp/services/Phase3BoxService.php b/webapp/services/Phase3BoxService.php index df9bf71f..868f0e44 100644 --- a/webapp/services/Phase3BoxService.php +++ b/webapp/services/Phase3BoxService.php @@ -41,13 +41,48 @@ class Phase3BoxService { return; } if ($boxDb['state'] == Phase3Box::INIT_STATE) { + Phase3Box::give($account); } myself()->_rspOk(); } public static function queryPhase3Box($account, $boxId) { - myself()->_rspOk(); + $boxDb = Phase3Box::all($account); + if (!$boxDb) { + myself()->_rspErr(100, 'box not exists'); + return; + } + if ($boxDb['state'] == Phase3Box::INIT_STATE) { + myself()->_rspData(array( + 'state' => 0 + )); + return; + } + if ($boxDb['cec'] > 0) { + myself()->_rspData(array( + 'state' => 1, + 'cec' => $boxDb['cec'] + )); + return; + } else { + $nftDb = Nft::getNft($boxDb['token_id']); + if ($nftDb) { + myself()->_rspData(array( + 'state' => 1, + 'cec' => 0, + 'nfts' => array( + Nft::toDto($nftDb) + ) + )); + return; + } else { + myself()->_rspData(array( + 'state' => 0 + )); + return; + } + } } }