remove services/ActivateNftService.php
This commit is contained in:
parent
b2cc6b9991
commit
edd42c8ff7
@ -1,114 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace services;
|
||||
|
||||
require_once('phpcommon/bchelper.php');
|
||||
|
||||
require_once('models/Nft.php');
|
||||
require_once('models/ActivateNft.php');
|
||||
require_once('models/BuyRecord.php');
|
||||
require_once('models/ActivateNftEvent.php');
|
||||
|
||||
use phpcommon;
|
||||
use models\Nft;
|
||||
use models\ActivateNft;
|
||||
use models\BuyRecord;
|
||||
use models\ActivateNftEvent;
|
||||
|
||||
class ActivateNftService {
|
||||
|
||||
public static function activate($account, $tokenId, $netId)
|
||||
{
|
||||
if (!phpcommon\isValidOldOrderId($tokenId)) {
|
||||
myself()->_rspErr(2, 'invalid token_id');
|
||||
return;
|
||||
}
|
||||
$nftDb = Nft::getNft($tokenId);
|
||||
if (!$nftDb) {
|
||||
myself()->_rspErr(2, 'nft not found');
|
||||
return;
|
||||
}
|
||||
$actDb = ActivateNft::find($tokenId);
|
||||
if (!$actDb) {
|
||||
$newTokenId = phpcommon\oldOrderIdToNew($tokenId);
|
||||
error_log('oldTokenId:' . $tokenId . ' newTokenId:' . $newTokenId);
|
||||
ActivateNft::add($tokenId, $account, $newTokenId);
|
||||
}
|
||||
$actDb = ActivateNft::find($tokenId);
|
||||
if (!$actDb) {
|
||||
myself()->_rspErr(2, 'server internal error3');
|
||||
return;
|
||||
}
|
||||
{
|
||||
$params = array(
|
||||
'c' => 'BcService',
|
||||
'a' => 'activateNftSignature',
|
||||
'account' => $account,
|
||||
'old_token_id' => $tokenId,
|
||||
'old_token_type' => $nftDb['token_type'],
|
||||
'new_token_id' => $actDb['new_token_id'],
|
||||
);
|
||||
$url = self::getWeb3ServiceUrl();
|
||||
$response = '';
|
||||
if (!phpcommon\HttpClient::get
|
||||
($url,
|
||||
$params,
|
||||
$response)) {
|
||||
phpcommon\sendError(500, 'server internal error');
|
||||
die();
|
||||
return;
|
||||
}
|
||||
error_log(json_encode(array(
|
||||
'_REQUEST' => $_REQUEST,
|
||||
'params' => $params,
|
||||
'response' => $response
|
||||
)));
|
||||
$json = json_decode($response, true);
|
||||
myself()->_rspData(array(
|
||||
'nonce' => $json['nonce'],
|
||||
'signature' => $json['signature'],
|
||||
'new_token_id' => $actDb['new_token_id'],
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public static function queryResult($account, $tokenId, $netId)
|
||||
{
|
||||
$eventDb = ActivateNftEvent::find($tokenId);
|
||||
if (!$eventDb) {
|
||||
myself()->_rspData(array(
|
||||
'state' => 0,
|
||||
'nft'=> array()
|
||||
));
|
||||
return;
|
||||
}
|
||||
$oldNftDb = Nft::getNft($eventDb['old_token_id']);
|
||||
if (!$oldNftDb || phpcommon\isSameAddress($oldNftDb['owner_address'],
|
||||
$account)) {
|
||||
myself()->_rspData(array(
|
||||
'state' => 0,
|
||||
'nft'=> array()
|
||||
));
|
||||
return;
|
||||
}
|
||||
$nftDb = Nft::getNft($eventDb['new_token_id']);
|
||||
if (!$nftDb) {
|
||||
myself()->_rspData(array(
|
||||
'state' => 0,
|
||||
'nft'=> array()
|
||||
));
|
||||
return;
|
||||
}
|
||||
myself()->_rspData(array(
|
||||
'state' => 1,
|
||||
'nft'=> Nft::toDto($nftDb)
|
||||
));
|
||||
}
|
||||
|
||||
private static function getWeb3ServiceUrl()
|
||||
{
|
||||
$web3ServiceCluster = require_once('../config/web3service.cluster.php');
|
||||
return $web3ServiceCluster[rand() % count($web3ServiceCluster)];
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user