1
This commit is contained in:
parent
86342e1115
commit
53e9c94683
2
third_party/phpcommon
vendored
2
third_party/phpcommon
vendored
@ -1 +1 @@
|
|||||||
Subproject commit e658ed5f7e4112801e59206f6da6f01db7131cd1
|
Subproject commit a071cc2b7fcc2e5c9597d29d07378b4f29ace591
|
60
webapp/services/BlockChainService.php
Normal file
60
webapp/services/BlockChainService.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace services;
|
||||||
|
|
||||||
|
class BlockChainService {
|
||||||
|
|
||||||
|
public static function gameItemMallBuy($account, $price)
|
||||||
|
{
|
||||||
|
$params = array(
|
||||||
|
'c' => 'GameItemMall',
|
||||||
|
'a' => 'buy',
|
||||||
|
'account' => $account,
|
||||||
|
'price' => $price,
|
||||||
|
);
|
||||||
|
{
|
||||||
|
$url = self::getWeb3ServiceUrl();
|
||||||
|
$response = '';
|
||||||
|
if (!phpcommon\HttpClient::get
|
||||||
|
($url,
|
||||||
|
$params,
|
||||||
|
$response)) {
|
||||||
|
myself()->_rspErr(500, 'server internal error');
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
error_log($response);
|
||||||
|
$rspObj = json_decode($response, true);
|
||||||
|
if ($rspObj['errcode'] == 0) {
|
||||||
|
$transId = $rspObj['trans_id'];
|
||||||
|
Transaction::add(
|
||||||
|
$transId,
|
||||||
|
Transaction::MINT_721_ACTION_TYPE,
|
||||||
|
$tokenId,
|
||||||
|
$tokenType,
|
||||||
|
$itemUniId,
|
||||||
|
$itemId,
|
||||||
|
1
|
||||||
|
);
|
||||||
|
myself()->_rspData(array(
|
||||||
|
'trans_id' => $transId,
|
||||||
|
'params' => $rspObj['params']
|
||||||
|
));
|
||||||
|
} else {
|
||||||
|
myself()->_rspErr(500, 'server internal error');
|
||||||
|
die();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static function getWeb3ServiceUrl()
|
||||||
|
{
|
||||||
|
if (SERVER_ENV == _TEST) {
|
||||||
|
return 'http://127.0.0.1:7672/webapp/index.php';
|
||||||
|
}
|
||||||
|
$web3ServiceCluster = require_once('../config/web3service.cluster.php');
|
||||||
|
return $web3ServiceCluster[rand() % count($web3ServiceCluster)];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user