1
This commit is contained in:
parent
094407d41c
commit
ffb980f74e
127
doc/AAMarket.py
127
doc/AAMarket.py
@ -39,6 +39,23 @@ class AAMarket(object):
|
||||
['!rows', [_common.MarketGoods()], '数据'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'GET',
|
||||
'name': '/api/market/product/category/:net_id',
|
||||
'desc': '获取上架出售的NFTs分类数量',
|
||||
'group': '!AAMarket',
|
||||
'url': 'https://market-test.kingsome.cn/api/market/product/list/:net_id',
|
||||
'params': [
|
||||
[':net_id', 0, '链id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!data', [
|
||||
['item_id', 0, '道具id'],
|
||||
['num', 0, '商品数量'],
|
||||
], '分类数量'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'name': '/api/market/transaction/history/:net_id/:account_address',
|
||||
'desc': '获取账号交易历史',
|
||||
@ -76,4 +93,114 @@ class AAMarket(object):
|
||||
['!rows', [_common.NftInfo()], '数据'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'POST',
|
||||
'name': '/api/hero/use/:net_id',
|
||||
'desc': '使用英雄(带入游戏内)',
|
||||
'group': '!AAMarket',
|
||||
'url': 'https://market-test.kingsome.cn/api/hero/use/:net_id',
|
||||
'is_json_params': True,
|
||||
'request_params': [
|
||||
[':net_id', 0, '链id'],
|
||||
['account_address', '', '钱包地址'],
|
||||
],
|
||||
'params': [
|
||||
['!token_ids', [''], 'tokenId列表'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['trans_id', '', '事务id'],
|
||||
['!params', [''], '合约参数列表'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'POST',
|
||||
'name': '/api/guld_bullion/use/:net_id',
|
||||
'desc': '使用金砖(生成金币带入游戏内)',
|
||||
'group': '!AAMarket',
|
||||
'url': 'https://market-test.kingsome.cn/api/gold_bullion/use/:net_id',
|
||||
'is_json_params': True,
|
||||
'request_params': [
|
||||
[':net_id', 0, '链id'],
|
||||
['account_address', '', '钱包地址'],
|
||||
],
|
||||
'params': [
|
||||
['!token_ids', [''], 'tokenId列表'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['trans_id', '', '事务id'],
|
||||
['!params', [''], '合约参数列表'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'GET',
|
||||
'name': '/api/shopcart/list',
|
||||
'desc': '购物车-商品列表',
|
||||
'group': '!AAMarket',
|
||||
'url': 'https://market-test.kingsome.cn/api/shopcart/list',
|
||||
'headers': _common.JwtHeader,
|
||||
'permission': _common.LoginRequired,
|
||||
'params': [
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
['!data', [_common.MarketGoods()], '数据'],
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'POST',
|
||||
'name': '/api/shopcart/add',
|
||||
'desc': '购物车-添加商品',
|
||||
'group': '!AAMarket',
|
||||
'url': 'https://market-test.kingsome.cn/api/shopcart/add',
|
||||
'headers': _common.JwtHeader,
|
||||
'permission': _common.LoginRequired,
|
||||
'is_json_params': True,
|
||||
'params': [
|
||||
['net_id', 0, '链id'],
|
||||
['!tokens', [
|
||||
['token_id', '', 'token_id'],
|
||||
['token_type', 0, '1: hero 11:gold bullion'],
|
||||
], 'nft list']
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'POST',
|
||||
'name': '/api/shopcart/del',
|
||||
'desc': '购物车-删除商品',
|
||||
'group': '!AAMarket',
|
||||
'url': 'https://market-test.kingsome.cn/api/shopcart/del',
|
||||
'headers': _common.JwtHeader,
|
||||
'permission': _common.LoginRequired,
|
||||
'is_json_params': True,
|
||||
'params': [
|
||||
['net_id', 0, '链id'],
|
||||
['!tokens', [
|
||||
['token_id', '', 'token_id'],
|
||||
['token_type', 0, '1: hero 11:gold bullion'],
|
||||
], 'nft list']
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
]
|
||||
},
|
||||
{
|
||||
'method': 'POST',
|
||||
'name': '/api/shopcart/clear',
|
||||
'desc': '购物车-清空购物车',
|
||||
'group': '!AAMarket',
|
||||
'url': 'https://market-test.kingsome.cn/api/shopcart/clear',
|
||||
'headers': _common.JwtHeader,
|
||||
'permission': _common.LoginRequired,
|
||||
'params': [
|
||||
['net_id', 0, '链id'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
]
|
||||
},
|
||||
]
|
||||
|
@ -66,6 +66,7 @@ class BlockChain(object):
|
||||
'params': [
|
||||
['type', 0, '1:英雄 2:金砖'],
|
||||
['uniid', '', '唯一id'],
|
||||
['account_address', '', '钱包地址'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
@ -80,6 +81,7 @@ class BlockChain(object):
|
||||
'url': 'webapp/index.php?c=BlockChain&a=mintGoldBullion',
|
||||
'params': [
|
||||
['type', 0, '1:1w金币 2:10w金币'],
|
||||
['account_address', '', '钱包地址'],
|
||||
],
|
||||
'response': [
|
||||
_common.RspHead(),
|
||||
|
@ -22,6 +22,12 @@ class RspHead(object):
|
||||
self.fields[i][1] = value
|
||||
break
|
||||
|
||||
JwtHeader = [
|
||||
'Authorization Bearer {JwtToken}'
|
||||
]
|
||||
|
||||
LoginRequired = 'login required'
|
||||
|
||||
class Union(object):
|
||||
|
||||
def __init__(self, fields):
|
||||
|
@ -153,7 +153,8 @@ class BlockChainController extends BaseAuthedController {
|
||||
Nft::HERO_TYPE,
|
||||
$heroDb['hero_uniid'],
|
||||
$heroDb['hero_id'],
|
||||
$isMint);
|
||||
$isMint,
|
||||
null);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -169,15 +170,18 @@ class BlockChainController extends BaseAuthedController {
|
||||
{
|
||||
$type = getReqVal('type', 0);
|
||||
$itemId = 0;
|
||||
$goldNum = 0;
|
||||
switch ($type) {
|
||||
case 1:
|
||||
{
|
||||
$itemId = V_ITEM_GOLD_BULLION_1W;
|
||||
$goldNum = 10000;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
{
|
||||
$itemId = V_ITEM_GOLD_BULLION_10W;
|
||||
$goldNum = 10000 * 10;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -185,10 +189,70 @@ class BlockChainController extends BaseAuthedController {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($itemId) || empty($goldNum)) {
|
||||
return;
|
||||
}
|
||||
$costItems = array(
|
||||
array(
|
||||
'item_id' => V_ITEM_GOLD,
|
||||
'item_num' => $goldNum
|
||||
),
|
||||
);
|
||||
$lackItem = null;
|
||||
if (!$this->_hasEnoughItems($costItems, $lackItem)) {
|
||||
$this->_rspErr(3, 'gold not enough');
|
||||
return;
|
||||
}
|
||||
$tokenId = BuyRecord::genOrderId
|
||||
(
|
||||
GAME_ID,
|
||||
phpcommon\BC_FUNC_CREATION,
|
||||
myself()->_getNowTime(),
|
||||
myself()->_getAddress()
|
||||
);
|
||||
$okCb = function () use($tokenId, $itemId, $costItems, $lackItem) {
|
||||
$lackItem = null;
|
||||
if (!myself()->_hasEnoughItems($costItems, $lackItem)) {
|
||||
myself()->_rspErr(3, 'gold not enough');
|
||||
return false;
|
||||
}
|
||||
$goldBullionDb = SqlHelper::ormSelectOne
|
||||
(myself()->_getSelfMysql(),
|
||||
't_gold_bullion',
|
||||
array(
|
||||
'token_id' => $tokenId
|
||||
)
|
||||
);
|
||||
if (!empty($goldBullionDb)) {
|
||||
$this->_rspErr(500, 'server internal error');
|
||||
return false;
|
||||
}
|
||||
SqlHelper::insert
|
||||
(myself()->_getSelfMysql(),
|
||||
't_gold_bullion',
|
||||
array(
|
||||
'src_account_id' => myself()->_getAccountId(),
|
||||
'src_address' => myself()->_getAddress(),
|
||||
'token_id' => $tokenId,
|
||||
'net_id' => NET_ID,
|
||||
'item_id' => $itemId,
|
||||
'gold' => $goldNum,
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'modifytime' => myself()->_getNowTime(),
|
||||
)
|
||||
);
|
||||
return true;
|
||||
};
|
||||
$this->internalActivate721Nft(
|
||||
$tokenId,
|
||||
Nft::GOLD_BULLION_TYPE,
|
||||
0,
|
||||
$itemId,
|
||||
true,
|
||||
$okCb);
|
||||
}
|
||||
|
||||
private function internalActivate721Nft($tokenId, $tokenType, $itemUniId, $itemId, $isMint)
|
||||
private function internalActivate721Nft($tokenId, $tokenType, $itemUniId, $itemId, $isMint, $okCb)
|
||||
{
|
||||
$params = array(
|
||||
'c' => 'BcService',
|
||||
@ -228,6 +292,9 @@ class BlockChainController extends BaseAuthedController {
|
||||
1,
|
||||
1
|
||||
);
|
||||
if (!empty($okCb) && !$okCb()) {
|
||||
return;
|
||||
}
|
||||
myself()->_rspData(array(
|
||||
'trans_id' => $transId,
|
||||
'trans_req' => $rspObj['trans_req']
|
||||
|
Loading…
x
Reference in New Issue
Block a user