1
This commit is contained in:
parent
53b7d049c1
commit
594cfa2305
14
doc/Mall.py
14
doc/Mall.py
@ -13,14 +13,8 @@ class Mall(object):
|
||||
'url': 'webapp/index.php?c=Mall&a=productOnline',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['nft_token', '', 'nft_token'],
|
||||
['item_id', '', '道具id,'],
|
||||
['s_price', '', '出售价格USDT'],
|
||||
['amount', 0, '出售数量'],
|
||||
['payment_token_address', '', 'payment_token_address'],
|
||||
['nonce', '', 'nonce'],
|
||||
['signature', '', '签名soliditySha3(type, payment_token_address, price, nonce), 签名的replace客户端做处理'],
|
||||
['net_id', '', '网络id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead()
|
||||
@ -33,8 +27,6 @@ class Mall(object):
|
||||
'url': 'webapp/index.php?c=Mall&a=productOffline',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['account', '', '账号id'],
|
||||
['idx', '', '出售的idx'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead()
|
||||
@ -47,8 +39,7 @@ class Mall(object):
|
||||
'url': 'webapp/index.php?c=Mall&a=modifyPrice',
|
||||
'params':[
|
||||
_common.ReqHead(),
|
||||
['account', '', '账号id'],
|
||||
['idx', '', '出售的idx'],
|
||||
['goods_uuid', '', '出售的idx'],
|
||||
['s_price', '', '出售价格USDT'],
|
||||
],
|
||||
'response': [
|
||||
@ -62,8 +53,7 @@ class Mall(object):
|
||||
'url': 'webapp/index.php?c=Mall&a=buy',
|
||||
'params': [
|
||||
_common.ReqHead(),
|
||||
['account', '', '账号id'],
|
||||
['idx', '', '出售的idx'],
|
||||
['goods_uuid', '', '出售的idx'],
|
||||
['s_price', '', '出售价格USDT'],
|
||||
],
|
||||
'response': [
|
||||
|
@ -1,28 +1,15 @@
|
||||
<?php
|
||||
|
||||
require_once('mt/Item.php');
|
||||
require_once('mt/Hero.php');
|
||||
require_once('mt/Parameter.php');
|
||||
|
||||
require_once('models/Nft.php');
|
||||
require_once('models/Hero.php');
|
||||
require_once('models/Gun.php');
|
||||
require_once('models/Chip.php');
|
||||
require_once('models/Fragment.php');
|
||||
require_once('models/BcOrder.php');
|
||||
|
||||
require_once('services/BlockChainService.php');
|
||||
require_once('services/LogService.php');
|
||||
|
||||
require_once('phpcommon/bchelper.php');
|
||||
|
||||
use models\BcOrder;
|
||||
use phpcommon\SqlHelper;
|
||||
use models\Nft;
|
||||
use models\Hero;
|
||||
use models\Gun;
|
||||
use models\Chip;
|
||||
use models\Fragment;
|
||||
use models\Transaction;
|
||||
use services\LogService;
|
||||
|
||||
@ -341,148 +328,4 @@ class MallController extends BaseAuthedController {
|
||||
));
|
||||
}
|
||||
|
||||
private function Web3PriceLowFormat($price)
|
||||
{
|
||||
$bn2 = phpcommon\bnInit('1000000000000000000');
|
||||
$ret_price = phpcommon\bnDiv($price, $bn2);
|
||||
return phpcommon\bnToStr($ret_price);
|
||||
}
|
||||
|
||||
private function getNftGameData($nftRowInfo)
|
||||
{
|
||||
$t = $nftRowInfo['token_type'];
|
||||
$token_id = $nftRowInfo['token_id'];
|
||||
switch ($t) {
|
||||
case Nft::HERO_TYPE: {
|
||||
return $this->appendChipsInfo(Hero::toDtoInfo(Hero::findByTokenId2($token_id)));
|
||||
}
|
||||
break;
|
||||
case Nft::EQUIP_TYPE: {
|
||||
return $this->appendChipsInfo(Gun::toDtoInfo(Gun::findByTokenId2($token_id)));
|
||||
}
|
||||
break;
|
||||
case Nft::CHIP_TYPE: {
|
||||
return Chip::toDto(Chip::getChipByTokenId($token_id));
|
||||
}
|
||||
break;
|
||||
case Nft::FRAGMENT_TYPE: {
|
||||
return Fragment::ToDto($nftRowInfo);
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
}
|
||||
break;
|
||||
}
|
||||
return array('unknown' => 'unknown game data type, cannot find data');
|
||||
}
|
||||
|
||||
private function appendChipsInfo($detail)
|
||||
{
|
||||
$detail['chips_info'] = array();
|
||||
if (!empty($detail['chip_ids'])) {
|
||||
$chips = explode('|', $detail['chip_ids']);
|
||||
foreach ($chips as $chip) {
|
||||
$chip_info = "";
|
||||
if (!empty($chip)) {
|
||||
$chip_info = Chip::toDto(Chip::getChipByTokenId($chip));
|
||||
}
|
||||
array_push($detail['chips_info'], $chip_info);
|
||||
}
|
||||
}
|
||||
return $detail;
|
||||
}
|
||||
|
||||
private function attach_market_selling(&$row)
|
||||
{
|
||||
$conn = myself()->_getSelfMysql();
|
||||
|
||||
$rows = $conn->execQuery(
|
||||
'SELECT * FROM t_market_store ' .
|
||||
'WHERE token_id=:token_id AND owner_address=:owner_address AND status=:status',
|
||||
array(
|
||||
':token_id' => $row['token_id'],
|
||||
':owner_address' => $row['owner_address'],
|
||||
':status' => 0,
|
||||
)
|
||||
);
|
||||
|
||||
$count = 0;
|
||||
$link_array = array();
|
||||
foreach ($rows as $r) {
|
||||
$count += $r['amount'];
|
||||
array_push($link_array, $r['o_link']);
|
||||
}
|
||||
|
||||
$row['o_link'] = implode('|', $link_array);
|
||||
$row['selling'] = $count;
|
||||
}
|
||||
|
||||
private function listMySelledNfts($account, $type)
|
||||
{
|
||||
// error_log('listMySelledNfts ' . $account . ' ' . $type);
|
||||
|
||||
$conn = myself()->_getSelfMysql();
|
||||
|
||||
$rows = $conn->execQuery(
|
||||
'SELECT * FROM t_market_store ' .
|
||||
'WHERE owner_address=:account AND token_type=:token_type AND status=0 ',
|
||||
array(
|
||||
':account' => $account,
|
||||
':token_type' => $type,
|
||||
)
|
||||
);
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
private function getGoodsByIdx($idx)
|
||||
{
|
||||
$row = SqlHelper::selectOne(
|
||||
myself()->_getSelfMysql(),
|
||||
't_market_store',
|
||||
array('order_id', 'item_id', 'amount', 's_price', 'owner_address'),
|
||||
array(
|
||||
'idx' => $idx,
|
||||
'status' => 0,
|
||||
)
|
||||
);
|
||||
if (!$row) {
|
||||
return null;
|
||||
}
|
||||
if (!$row['item_id']) {
|
||||
return null;
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
private function markOrderBuyStatus($idx)
|
||||
{
|
||||
$r = SqlHelper::update(
|
||||
myself()->_getSelfMysql(),
|
||||
't_market_store',
|
||||
array(
|
||||
'idx' => $idx,
|
||||
),
|
||||
array(
|
||||
'status' => 3,
|
||||
'buytime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
if (!$r) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user