...
This commit is contained in:
parent
d901f44ce7
commit
5e0364ed73
@ -35,7 +35,8 @@ use services\MarketService;
|
|||||||
use services\LuckyBoxService;
|
use services\LuckyBoxService;
|
||||||
use services\ActivateNftService;
|
use services\ActivateNftService;
|
||||||
|
|
||||||
class MarketController extends BaseController {
|
class MarketController extends BaseController
|
||||||
|
{
|
||||||
|
|
||||||
public function getPreSaleInfo()
|
public function getPreSaleInfo()
|
||||||
{
|
{
|
||||||
@ -79,8 +80,10 @@ class MarketController extends BaseController {
|
|||||||
$saleBox = $this->fillPresaleBox($currBatchMeta, $meta);
|
$saleBox = $this->fillPresaleBox($currBatchMeta, $meta);
|
||||||
if ($saleBox) {
|
if ($saleBox) {
|
||||||
++$pageInfo['total'];
|
++$pageInfo['total'];
|
||||||
if ($pageInfo['total'] > $startPos &&
|
if (
|
||||||
count($rows) < $pageInfo['per_page']) {
|
$pageInfo['total'] > $startPos &&
|
||||||
|
count($rows) < $pageInfo['per_page']
|
||||||
|
) {
|
||||||
array_push($rows, $saleBox);
|
array_push($rows, $saleBox);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -119,7 +122,8 @@ class MarketController extends BaseController {
|
|||||||
$paymentTokenAddress,
|
$paymentTokenAddress,
|
||||||
$price,
|
$price,
|
||||||
$nonce,
|
$nonce,
|
||||||
$signature);
|
$signature
|
||||||
|
);
|
||||||
|
|
||||||
$batchIdx = 0;
|
$batchIdx = 0;
|
||||||
$idx = 0;
|
$idx = 0;
|
||||||
@ -129,12 +133,14 @@ class MarketController extends BaseController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($type) ||
|
if (
|
||||||
|
empty($type) ||
|
||||||
empty($buyerAddress) ||
|
empty($buyerAddress) ||
|
||||||
empty($price) ||
|
empty($price) ||
|
||||||
empty($paymentTokenAddress) ||
|
empty($paymentTokenAddress) ||
|
||||||
empty($signature) ||
|
empty($signature) ||
|
||||||
empty($nonce)) {
|
empty($nonce)
|
||||||
|
) {
|
||||||
myself()->_rspErr(2, 'parameter error');
|
myself()->_rspErr(2, 'parameter error');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -192,15 +198,19 @@ class MarketController extends BaseController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MarketService::isTestMode() &&
|
if (
|
||||||
BoxOrder::isBuyed($buyerAddress, $currBatchMeta['id'])) {
|
!MarketService::isTestMode() &&
|
||||||
|
BoxOrder::isBuyed($buyerAddress, $currBatchMeta['id'])
|
||||||
|
) {
|
||||||
myself()->_rspErr(1, 'account can only choose 1 hero to purchase');
|
myself()->_rspErr(1, 'account can only choose 1 hero to purchase');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$orderId = BuyRecord::genOrderId($gameId,
|
$orderId = BuyRecord::genOrderId(
|
||||||
|
$gameId,
|
||||||
$funcId,
|
$funcId,
|
||||||
myself()->_getNowTime(),
|
myself()->_getNowTime(),
|
||||||
$buyerAddress);
|
$buyerAddress
|
||||||
|
);
|
||||||
|
|
||||||
$fieldsKv = array(
|
$fieldsKv = array(
|
||||||
'game_id' => $gameId,
|
'game_id' => $gameId,
|
||||||
@ -397,17 +407,18 @@ class MarketController extends BaseController {
|
|||||||
if (!$currencyMeta) {
|
if (!$currencyMeta) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
$boxId = phpcommon\genBoxId($batchMeta['id'],
|
$boxId = phpcommon\genBoxId(
|
||||||
|
$batchMeta['id'],
|
||||||
$goodsMeta['id'],
|
$goodsMeta['id'],
|
||||||
$goodsMeta['item_id']);
|
$goodsMeta['item_id']
|
||||||
|
);
|
||||||
|
|
||||||
$itemMeta = mt\Item::get($goodsMeta['item_id']);
|
$itemMeta = mt\Item::get($goodsMeta['item_id']);
|
||||||
$originalPrice = $goodsMeta['price'] * pow(10, MarketService::CURRENCY_DECIMALS);
|
$originalPrice = $goodsMeta['price'] * pow(10, MarketService::CURRENCY_DECIMALS);
|
||||||
$discountPrice = $goodsMeta['discount'] * 100 > 0 ?
|
$discountPrice = $goodsMeta['discount'] * 100 > 0 ?
|
||||||
$originalPrice * $goodsMeta['discount'] : $originalPrice;
|
$originalPrice * $goodsMeta['discount'] : $originalPrice;
|
||||||
$name = '';
|
$name = '';
|
||||||
$job = 0;
|
$job = 0; {
|
||||||
{
|
|
||||||
$heroMeta = mt\Hero::get($goodsMeta['item_id']);
|
$heroMeta = mt\Hero::get($goodsMeta['item_id']);
|
||||||
if ($heroMeta) {
|
if ($heroMeta) {
|
||||||
$name = emptyReplace($heroMeta['name'], 'Hill');
|
$name = emptyReplace($heroMeta['name'], 'Hill');
|
||||||
@ -429,7 +440,8 @@ class MarketController extends BaseController {
|
|||||||
'decimals' => MarketService::CURRENCY_DECIMALS,
|
'decimals' => MarketService::CURRENCY_DECIMALS,
|
||||||
'contract_address' => $currencyMeta['address'],
|
'contract_address' => $currencyMeta['address'],
|
||||||
)
|
)
|
||||||
));
|
)
|
||||||
|
);
|
||||||
return $saleBox;
|
return $saleBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -682,7 +694,6 @@ class MarketController extends BaseController {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $nfts;
|
return $nfts;
|
||||||
@ -833,9 +844,14 @@ class MarketController extends BaseController {
|
|||||||
if (!$nftDb) {
|
if (!$nftDb) {
|
||||||
$nftDb = Nft::findNftByOwner('0xfc628dd79137395f3c9744e33b1c5de554d94882', $row['token_id']);
|
$nftDb = Nft::findNftByOwner('0xfc628dd79137395f3c9744e33b1c5de554d94882', $row['token_id']);
|
||||||
if (!$nftDb) {
|
if (!$nftDb) {
|
||||||
|
if ($row['item_id']) {
|
||||||
|
|
||||||
|
} else {
|
||||||
myself()->_rspErr(1, 'nft not exists');
|
myself()->_rspErr(1, 'nft not exists');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$nft = Nft::toDto($nftDb);
|
$nft = Nft::toDto($nftDb);
|
||||||
@ -900,9 +916,97 @@ class MarketController extends BaseController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function sell() {
|
public function sell()
|
||||||
|
{
|
||||||
|
$self = myself();
|
||||||
|
if (!$self) {
|
||||||
|
$this->_rspErr(500, 'internal error, no self');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$account = strtolower(getReqVal('account', ''));
|
$account = strtolower(getReqVal('account', ''));
|
||||||
|
$token = getReqVal('token', '');
|
||||||
|
|
||||||
|
$nft_token = getReqVal('nft_token', '');
|
||||||
$item_id = getReqVal('item_id', '');
|
$item_id = getReqVal('item_id', '');
|
||||||
|
|
||||||
|
$s_price = getReqVal('s_price', '');
|
||||||
|
$amount = getReqVal('amount', 1);
|
||||||
|
|
||||||
|
$payment_token_address = getReqVal('payment_token_address', '');
|
||||||
|
$nonce = getReqVal('nonce', '');
|
||||||
|
$signature = getReqVal('signature', '');
|
||||||
|
$net_id = getReqVal('net_id', '');
|
||||||
|
|
||||||
|
$conn = $self->_getMarketMysql('');
|
||||||
|
|
||||||
|
$nftDb = null;
|
||||||
|
|
||||||
|
$c_name = null;
|
||||||
|
$c_job = null;
|
||||||
|
$c_lv = null;
|
||||||
|
$c_quality = null;
|
||||||
|
$c_durability = null;
|
||||||
|
$c_type = null;
|
||||||
|
$c_id = null;
|
||||||
|
|
||||||
|
if ($nft_token) {
|
||||||
|
$nftDb = Nft::findNftByOwner($account, $nft_token);
|
||||||
|
$nftDetail = Nft::toDto($nftDb);
|
||||||
|
$detail = $this->getNftGameData($nftDb);
|
||||||
|
$c_name = $nftDetail['info']['name'];
|
||||||
|
$c_job = isset($nftDetail['info']['job']) ? $nftDetail['info']['job']
|
||||||
|
: (isset($detail['chip_type']) ? $detail['chip_type']
|
||||||
|
: (isset($detail['type']) ? $detail['type']
|
||||||
|
: 0));
|
||||||
|
$c_lv = @$detail['gun_lv'] | @$detail['hero_lv'] | @$detail['chip_grade'];
|
||||||
|
$c_quality = isset($nftDetail['info']['quality']) ? $nftDetail['info']['quality'] : 0;
|
||||||
|
$c_durability = isset($nftDetail['info']['durability']) ? $nftDetail['info']['durability'] : (isset($detail['hero_tili']) ? $detail['hero_tili'] : 0);
|
||||||
|
$c_type = isset($detail['type']) ? $detail['type'] : 0;
|
||||||
|
$c_id = $nftDetail['item_id'];
|
||||||
|
} else {
|
||||||
|
if (!$this->decItems($account, $item_id, $amount)) {
|
||||||
|
$this->_rspErr(1, 'item not enough, item_id:' . $item_id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$itemMeta = mt\Item::get($item_id);
|
||||||
|
$c_name = $itemMeta['name'];
|
||||||
|
$c_job = 0;
|
||||||
|
$c_lv = 0;
|
||||||
|
$c_quality = $itemMeta['quality'];
|
||||||
|
$c_durability = 0;
|
||||||
|
$c_type = 0;
|
||||||
|
$c_id = $item_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
$r = SqlHelper::insert(
|
||||||
|
$conn,
|
||||||
|
't_market_store',
|
||||||
|
array(
|
||||||
|
'token_id' => $nft_token,
|
||||||
|
'item_id' => $item_id,
|
||||||
|
'owner_address' => $account,
|
||||||
|
'token_type' => 0,
|
||||||
|
'amount' => $amount,
|
||||||
|
'createtime' => $self->_getNowTime(),
|
||||||
|
'modifytime' => $self->_getNowTime(),
|
||||||
|
's_price' => $s_price,
|
||||||
|
'c_name' => $c_name,
|
||||||
|
'c_job' => $c_job,
|
||||||
|
'c_lv' => $c_lv,
|
||||||
|
'c_quality' => $c_quality,
|
||||||
|
'c_durability' => $c_durability,
|
||||||
|
'c_type' => $c_type,
|
||||||
|
'c_id' => $c_id,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->_rspOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sellMyNft()
|
||||||
|
{
|
||||||
|
|
||||||
|
$account = strtolower(getReqVal('account', ''));
|
||||||
$token = getReqVal('token', '');
|
$token = getReqVal('token', '');
|
||||||
$nft_token = getReqVal('nft_token', '');
|
$nft_token = getReqVal('nft_token', '');
|
||||||
$s_price = getReqVal('s_price', '');
|
$s_price = getReqVal('s_price', '');
|
||||||
@ -914,48 +1018,6 @@ class MarketController extends BaseController {
|
|||||||
|
|
||||||
$conn = myself()->_getMarketMysql('');
|
$conn = myself()->_getMarketMysql('');
|
||||||
|
|
||||||
$nftDb = Nft::findNftByOwner($account, $nft_token);
|
|
||||||
$nftDetail = Nft::toDto($nftDb);
|
|
||||||
$detail = $this->getNftGameData($nftDb);
|
|
||||||
$r = SqlHelper::insert(
|
|
||||||
$conn,
|
|
||||||
't_market_store',
|
|
||||||
array(
|
|
||||||
'token_id' => $nft_token,
|
|
||||||
'token_type' => $nftDetail['type'],
|
|
||||||
'owner' => $account,
|
|
||||||
'price' => $s_price,
|
|
||||||
'amount' => $amount,
|
|
||||||
'payment_token_address' => $payment_token_address,
|
|
||||||
'status' => 0,
|
|
||||||
'create_time' => time(),
|
|
||||||
'update_time' => time(),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
if (!$r) {
|
|
||||||
myself()->_rspErr(1, 'insert error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$this->_rspData(array(
|
|
||||||
'nft' => $nftDetail,
|
|
||||||
'detail' => $detail,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function sellMyNft() {
|
|
||||||
|
|
||||||
$account = strtolower(getReqVal('account', ''));
|
|
||||||
$token = getReqVal('token', '');
|
|
||||||
$nft_token = getReqVal('nft_token', '');
|
|
||||||
$s_price = getReqVal('s_price', '');
|
|
||||||
$amount = getReqVal('amount', 1);
|
|
||||||
$payment_token_address = getReqVal('payment_token_address', '');
|
|
||||||
$nonce = getReqVal('nonce', '');
|
|
||||||
$signature = getReqVal('signature', '');
|
|
||||||
$net_id = getReqVal('net_id', '');
|
|
||||||
|
|
||||||
$conn = myself()->_getMysql('');
|
|
||||||
|
|
||||||
$nftDb = Nft::findNftByOwner($account, $nft_token);
|
$nftDb = Nft::findNftByOwner($account, $nft_token);
|
||||||
$nftDetail = Nft::toDto($nftDb);
|
$nftDetail = Nft::toDto($nftDb);
|
||||||
$detail = $this->getNftGameData($nftDb);
|
$detail = $this->getNftGameData($nftDb);
|
||||||
@ -985,7 +1047,8 @@ class MarketController extends BaseController {
|
|||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buyNft() {
|
public function buyNft()
|
||||||
|
{
|
||||||
$account = strtolower(getReqVal('account', ''));
|
$account = strtolower(getReqVal('account', ''));
|
||||||
$token = getReqVal('token', '');
|
$token = getReqVal('token', '');
|
||||||
$nft_token = getReqVal('nft_token', '');
|
$nft_token = getReqVal('nft_token', '');
|
||||||
@ -1000,7 +1063,8 @@ class MarketController extends BaseController {
|
|||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getSupportedCurrencyTypes() {
|
public function getSupportedCurrencyTypes()
|
||||||
|
{
|
||||||
$types = array();
|
$types = array();
|
||||||
if (SERVER_ENV == _ONLINE) {
|
if (SERVER_ENV == _ONLINE) {
|
||||||
array_push($types, array(
|
array_push($types, array(
|
||||||
@ -1018,19 +1082,19 @@ class MarketController extends BaseController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTransactionRecord() {
|
public function getTransactionRecord()
|
||||||
|
{
|
||||||
$account = strtolower(getReqVal('account', ''));
|
$account = strtolower(getReqVal('account', ''));
|
||||||
$type = getReqVal('type', 0);
|
$type = getReqVal('type', 0);
|
||||||
$start = getReqVal('start', 0);
|
$start = getReqVal('start', 0);
|
||||||
$page_size = getReqVal('page_size', 10);
|
$page_size = getReqVal('page_size', 10);
|
||||||
|
|
||||||
$conn = myself()->_getMysql('');
|
$conn = myself()->_getMarketMysql('');
|
||||||
|
|
||||||
$type_filter_fn = function ($f) {
|
$type_filter_fn = function ($f) {
|
||||||
if ($f == 0) {
|
if ($f == 0) {
|
||||||
return '';
|
return '';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return 'AND type=' . $f;
|
return 'AND type=' . $f;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1073,8 +1137,9 @@ class MarketController extends BaseController {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function addTransactionRecord($record) {
|
private function addTransactionRecord($record)
|
||||||
$conn = myself()->_getMysql('');
|
{
|
||||||
|
$conn = myself()->_getMarketMysql('');
|
||||||
|
|
||||||
$r = SqlHelper::insert(
|
$r = SqlHelper::insert(
|
||||||
$conn,
|
$conn,
|
||||||
@ -1086,7 +1151,8 @@ class MarketController extends BaseController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eventSellOrder() {
|
public function eventSellOrder()
|
||||||
|
{
|
||||||
$tokenId = getReqVal('tokenId', '');
|
$tokenId = getReqVal('tokenId', '');
|
||||||
$owner = strtolower(getReqVal('owner', ''));
|
$owner = strtolower(getReqVal('owner', ''));
|
||||||
$nftToken = getReqVal('nftToken', '');
|
$nftToken = getReqVal('nftToken', '');
|
||||||
@ -1095,7 +1161,8 @@ class MarketController extends BaseController {
|
|||||||
$currency = getReqVal('currency', '');
|
$currency = getReqVal('currency', '');
|
||||||
$price = getReqVal('price', '');
|
$price = getReqVal('price', '');
|
||||||
|
|
||||||
error_log("eventSellOrder:" . json_encode(
|
error_log(
|
||||||
|
"eventSellOrder:" . json_encode(
|
||||||
array(
|
array(
|
||||||
'tokenId' => $tokenId,
|
'tokenId' => $tokenId,
|
||||||
'owner' => $owner,
|
'owner' => $owner,
|
||||||
@ -1159,7 +1226,8 @@ class MarketController extends BaseController {
|
|||||||
$this->_rspOk();
|
$this->_rspOk();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eventBuyOrder() {
|
public function eventBuyOrder()
|
||||||
|
{
|
||||||
$tokenId = getReqVal('tokenId', '');
|
$tokenId = getReqVal('tokenId', '');
|
||||||
$orderId = getReqVal('orderId', '');
|
$orderId = getReqVal('orderId', '');
|
||||||
$nftToken = getReqVal('nftToken', '');
|
$nftToken = getReqVal('nftToken', '');
|
||||||
@ -1169,7 +1237,8 @@ class MarketController extends BaseController {
|
|||||||
$erc20 = getReqVal('erc20', '');
|
$erc20 = getReqVal('erc20', '');
|
||||||
$price = getReqVal('price', '');
|
$price = getReqVal('price', '');
|
||||||
|
|
||||||
error_log("eventBuyOrder:" . json_encode(
|
error_log(
|
||||||
|
"eventBuyOrder:" . json_encode(
|
||||||
array(
|
array(
|
||||||
'tokenId' => $tokenId,
|
'tokenId' => $tokenId,
|
||||||
'orderId' => $orderId,
|
'orderId' => $orderId,
|
||||||
@ -1224,11 +1293,13 @@ class MarketController extends BaseController {
|
|||||||
$this->_rspErr(1, 'order status error, order=' . $orderId);
|
$this->_rspErr(1, 'order status error, order=' . $orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eventCancelOrder() {
|
public function eventCancelOrder()
|
||||||
|
{
|
||||||
$orderId = getReqVal('orderId', '');
|
$orderId = getReqVal('orderId', '');
|
||||||
$nftToken = getReqVal('nftToken', '');
|
$nftToken = getReqVal('nftToken', '');
|
||||||
$tokenId = getReqVal('tokenId', '');
|
$tokenId = getReqVal('tokenId', '');
|
||||||
error_log("eventCancelOrder:" . json_encode(
|
error_log(
|
||||||
|
"eventCancelOrder:" . json_encode(
|
||||||
array(
|
array(
|
||||||
'orderId' => $orderId,
|
'orderId' => $orderId,
|
||||||
'nftToken' => $nftToken,
|
'nftToken' => $nftToken,
|
||||||
@ -1265,13 +1336,15 @@ class MarketController extends BaseController {
|
|||||||
$this->_rspErr(1, 'order status error, order=' . $orderId);
|
$this->_rspErr(1, 'order status error, order=' . $orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function eventPriceUpdateOrder() {
|
public function eventPriceUpdateOrder()
|
||||||
|
{
|
||||||
$orderId = getReqVal('orderId', '');;
|
$orderId = getReqVal('orderId', '');;
|
||||||
$nftToken = getReqVal('nftToken', '');
|
$nftToken = getReqVal('nftToken', '');
|
||||||
$tokenId = getReqVal('tokenId', '');
|
$tokenId = getReqVal('tokenId', '');
|
||||||
$priceOld = getReqVal('priceOld', '');
|
$priceOld = getReqVal('priceOld', '');
|
||||||
$price = getReqVal('price', '');
|
$price = getReqVal('price', '');
|
||||||
error_log("eventPriceUpdateOrder:" . json_encode(
|
error_log(
|
||||||
|
"eventPriceUpdateOrder:" . json_encode(
|
||||||
array(
|
array(
|
||||||
'orderId' => $orderId,
|
'orderId' => $orderId,
|
||||||
'nftToken' => $nftToken,
|
'nftToken' => $nftToken,
|
||||||
@ -1312,29 +1385,36 @@ class MarketController extends BaseController {
|
|||||||
$this->_rspErr(1, 'price update failed, orderId=' . $orderId);
|
$this->_rspErr(1, 'price update failed, orderId=' . $orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getNftGameData($nftRowInfo) {
|
private function getNftGameData($nftRowInfo)
|
||||||
|
{
|
||||||
$t = $nftRowInfo['token_type'];
|
$t = $nftRowInfo['token_type'];
|
||||||
$token_id = $nftRowInfo['token_id'];
|
$token_id = $nftRowInfo['token_id'];
|
||||||
switch ($t) {
|
switch ($t) {
|
||||||
case Nft::HERO_TYPE: {
|
case Nft::HERO_TYPE: {
|
||||||
return $this->appendChipsInfo(Hero::toDtoInfo(Hero::findByTokenId2($token_id)));
|
return $this->appendChipsInfo(Hero::toDtoInfo(Hero::findByTokenId2($token_id)));
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
case Nft::EQUIP_TYPE: {
|
case Nft::EQUIP_TYPE: {
|
||||||
return $this->appendChipsInfo(Gun::toDtoInfo(Gun::findByTokenId2($token_id)));
|
return $this->appendChipsInfo(Gun::toDtoInfo(Gun::findByTokenId2($token_id)));
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
case Nft::CHIP_TYPE: {
|
case Nft::CHIP_TYPE: {
|
||||||
return Chip::toDto(Chip::getChipByTokenId($token_id));
|
return Chip::toDto(Chip::getChipByTokenId($token_id));
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
case Nft::FRAGMENT_TYPE: {
|
case Nft::FRAGMENT_TYPE: {
|
||||||
return Fragment::ToDto($nftRowInfo);
|
return Fragment::ToDto($nftRowInfo);
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
default: {
|
default: {
|
||||||
} break;
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return array('unknown' => 'unknown game data type, cannot find data');
|
return array('unknown' => 'unknown game data type, cannot find data');
|
||||||
}
|
}
|
||||||
|
|
||||||
private function appendChipsInfo($detail) {
|
private function appendChipsInfo($detail)
|
||||||
|
{
|
||||||
$detail['chips_info'] = array();
|
$detail['chips_info'] = array();
|
||||||
if (!empty($detail['chip_ids'])) {
|
if (!empty($detail['chip_ids'])) {
|
||||||
$chips = explode('|', $detail['chip_ids']);
|
$chips = explode('|', $detail['chip_ids']);
|
||||||
@ -1349,7 +1429,8 @@ class MarketController extends BaseController {
|
|||||||
return $detail;
|
return $detail;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function attach_market_selling(&$row) {
|
private function attach_market_selling(&$row)
|
||||||
|
{
|
||||||
$conn = myself()->_getMarketMysql('');
|
$conn = myself()->_getMarketMysql('');
|
||||||
|
|
||||||
$rows = $conn->execQuery(
|
$rows = $conn->execQuery(
|
||||||
@ -1390,4 +1471,92 @@ class MarketController extends BaseController {
|
|||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function decItems($address, $item_id, $amount)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getCostItem($address, $item_id)
|
||||||
|
{
|
||||||
|
$self = myself();
|
||||||
|
if (!$self) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$userInfo = $this->getUserInfo($address, array('gold'));
|
||||||
|
$count = $this->getItemCount($item_id, $userInfo);
|
||||||
|
|
||||||
|
return array(
|
||||||
|
'item_id' => $item_id,
|
||||||
|
'item_amount' => $count
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getItemCount($item_id, $userInfo)
|
||||||
|
{
|
||||||
|
switch ($item_id) {
|
||||||
|
case V_ITEM_GOLD: {
|
||||||
|
return $userInfo['gold'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getUserInfo($address, $fields)
|
||||||
|
{
|
||||||
|
$self = myself();
|
||||||
|
if (!$self) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $account_id = $this->getAccountId($address);
|
||||||
|
// if (!$account_id) {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
$conn = $self->_getMysql($address);
|
||||||
|
$row = SqlHelper::selectOne(
|
||||||
|
$conn,
|
||||||
|
't_user',
|
||||||
|
$fields,
|
||||||
|
array(
|
||||||
|
'address' => $address
|
||||||
|
)
|
||||||
|
);
|
||||||
|
if (empty($row)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $row;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getAccountId($address)
|
||||||
|
{
|
||||||
|
$self = myself();
|
||||||
|
if (!$self) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$row = SqlHelper::selectOne(
|
||||||
|
$self->_getMysql($address),
|
||||||
|
't_user',
|
||||||
|
array('account_id'),
|
||||||
|
array(
|
||||||
|
'address' => $address
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return $row['account_id'];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function normalizeWeb3Price($price)
|
||||||
|
{
|
||||||
|
$bn1 = phpcommon\bnInit($price * pow(10, 8));
|
||||||
|
$bn2 = phpcommon\bnInit('1000000000000000000');
|
||||||
|
$ret_price = phpcommon\bnDiv(phpcommon\bnMul($bn1, $bn2), pow(10, 8));
|
||||||
|
|
||||||
|
// error_log('normalizeWeb3Price: ' . $ret_price . ' ' . $price * pow(10, 8));
|
||||||
|
return phpcommon\bnToStr($ret_price);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user