From d54dab2ed55fb973d8010be42cdee14848c83053 Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 11 Jan 2023 16:34:19 +0800 Subject: [PATCH 1/5] ... --- webapp/controller/MarketController.class.php | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 5c264e16..34b46d18 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -962,27 +962,11 @@ class MarketController extends BaseController { 'name' => 'USDT', 'address' => '0xc22Ffa318051d8aF4E5f2E2732d7049486fcE093', )); - array_push($types, array( - 'name' => 'CEC', - 'address' => '0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7', - )); - array_push($types, array( - 'name' => 'CEG', - 'address' => '0xc22Ffa318051d8aF4E5f2E2732d7049486fcE093', - )); } else { array_push($types, array( 'name' => 'USDT', 'address' => '0xc22Ffa318051d8aF4E5f2E2732d7049486fcE093', )); - array_push($types, array( - 'name' => 'D CEC', - 'address' => '0x9561C133DD8580860B6b7E504bC5Aa500f0f06a7', - )); - array_push($types, array( - 'name' => 'D CEG', - 'address' => '0x59d3631c86BbE35EF041872d502F218A39FBa150', - )); } $this->_rspData(array( 'list' => $types, From 4a702773fc9a8f51f28021d19456155e0a8dd776 Mon Sep 17 00:00:00 2001 From: songliang Date: Wed, 11 Jan 2023 18:54:56 +0800 Subject: [PATCH 2/5] ... --- webapp/controller/MarketController.class.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 34b46d18..f9c48250 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -831,8 +831,11 @@ class MarketController extends BaseController { $nftDb = Nft::findNftByOwner($account, $row['token_id']); // 0x768b5faed6dc69816f33377d214ffaf00dcdd0cf if (!$nftDb) { - myself()->_rspErr(1, 'nft not exists'); - return; + $nftDb = Nft::findNftByOwner('0xfc628dd79137395f3c9744e33b1c5de554d94882', $row['token_id']); + if (!$nftDb) { + myself()->_rspErr(1, 'nft not exists'); + return; + } } } $nft = Nft::toDto($nftDb); From d9809bf9d30c2e0295f279eb7944898ae6f7f286 Mon Sep 17 00:00:00 2001 From: songliang Date: Sat, 28 Jan 2023 11:20:26 +0800 Subject: [PATCH 3/5] ... --- doc/Market.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/doc/Market.py b/doc/Market.py index 041bef12..e1fe883d 100644 --- a/doc/Market.py +++ b/doc/Market.py @@ -28,6 +28,21 @@ class CurrencyType(object): ['name', '', '货币名称'], ['address', '', '货币地址'], ] + +class TransactionRecord(object): + def __init__(self): + self.fields = [ + ['idx', 0, 'idx'], + ['createtime', 0, '交易成功时间'], + ['orderid', 0, 'market订单id'], + ['o_link', '', '合约订单id'], + ['seller', '', '卖家'], + ['buyer', '', '买家'], + ['tokenid', '', 'tokenid'], + ['amount', 0, '商品数量'], + ['name', '', '商品名称'], + ['type', 0, '商品类型'], + ] class Market(object): def __init__(self): @@ -418,5 +433,24 @@ class Market(object): _common.RspHead(), ['!list', [CurrencyType()], '货币类型列表'], ] + }, + { + 'name': 'getTransactionRecord', + 'desc': '获取交易记录', + 'group': 'Market', + 'url': 'webapp/index.php?c=Market&a=getTransactionRecord', + 'params': [ + ['account', '', '账号id'], + ['start', 0, '分页开始偏移'], + ['page_size', 0, '分页大小'], + ], + 'response': [ + _common.RspHead(), + ['total', 0, '交易记录总数'], + ['start', 0, '有效的分页偏移'], + ['page_size', 0, '有效的分页大小'], + ['!list', [TransactionRecord()], '交易记录列表'], + ] } + ] From 1fb85e0bcabff4215be2d3e07eae03d903fb3091 Mon Sep 17 00:00:00 2001 From: songliang Date: Sat, 28 Jan 2023 12:04:24 +0800 Subject: [PATCH 4/5] ... --- doc/Market.py | 2 +- webapp/controller/MarketController.class.php | 69 +++++++++++++++++++- 2 files changed, 69 insertions(+), 2 deletions(-) diff --git a/doc/Market.py b/doc/Market.py index e1fe883d..26141c6b 100644 --- a/doc/Market.py +++ b/doc/Market.py @@ -32,7 +32,7 @@ class CurrencyType(object): class TransactionRecord(object): def __init__(self): self.fields = [ - ['idx', 0, 'idx'], + ['idx', '', 'idx'], ['createtime', 0, '交易成功时间'], ['orderid', 0, 'market订单id'], ['o_link', '', '合约订单id'], diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index f9c48250..4042a593 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -976,6 +976,60 @@ class MarketController extends BaseController { )); } + public function getTransactionRecord() { + $account = strtolower(getReqVal('account', '')); + $start = getReqVal('start', 0); + $page_size = getReqVal('page_size', 10); + + $conn = myself()->_getMysql(''); + + $counts = $conn->execQuery( + 'SELECT count(*) as count FROM t_market_transaction_record '. + 'WHERE seller=:account OR buyer=:account ORDER BY createtime DESC', + array( + ':account' => $account, + ) + ); + + $total = $counts[0]['count']; + $page_end = $start + $page_size; + if ($page_end > $total) { + $page_end = $total; + $start = $total-1; + $start = intval($start / $page_size) * $page_size; + if ($start<0) $start = 0; + } + + $rows = $conn->execQuery( + 'SELECT * FROM t_market_transaction_record '. + 'WHERE seller=:account OR buyer=:account ORDER BY createtime DESC '. + 'LIMIT '.$start.','.$page_size, + array( + ':account' => $account, + ) + ); + + $this->_rspData(array( + "total" => $total, + "start" => $start, + "page_size" => $page_size, + 'nfts' => $rows, + )); + } + + private function addTransactionRecord($record) { + $conn = myself()->_getMysql(''); + + $r = SqlHelper::insert( + $conn, + 't_market_transaction_record', + $record + ); + if (!$r) { + $this->_rspErr(2, 'unknown error, orderId='.$record['orderid']); + } + } + public function eventSellOrder() { $tokenId = getReqVal('tokenId', ''); $owner = strtolower(getReqVal('owner', '')); @@ -1077,7 +1131,7 @@ class MarketController extends BaseController { $conn = myself()->_getMysql(''); // 1. check order status - $chk = SqlHelper::selectOne($conn, 't_market_store', array('status'), array('o_link' => $orderId)); + $chk = SqlHelper::selectOne($conn, 't_market_store', array('status','idx', 'c_name', 'c_type'), array('o_link' => $orderId)); if (empty($chk)) { $this->_rspErr(1, 'not found order, orderId='.$orderId); return; @@ -1094,6 +1148,19 @@ class MarketController extends BaseController { ) ); if ($r) { + // 增加交易记录 + $record = array( + 'createtime' => myself()->_getNowTime(), + 'orderid' => $chk['idx'], + 'o_link' => $orderId, + 'seller' => $seller, + 'buyer' => $buyer, + 'tokenid' => $tokenId, + 'amount' => $amount, + 'name' => $chk['c_name'], + 'type' => $chk['c_type'], + ); + $this->addTransactionRecord($record); $this->_rspOk(); return; } From ce9cf48da22358ba00d8b42899f22ba5c1e260e9 Mon Sep 17 00:00:00 2001 From: songliang Date: Sat, 28 Jan 2023 13:31:41 +0800 Subject: [PATCH 5/5] ... --- doc/Market.py | 1 + webapp/controller/MarketController.class.php | 22 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/doc/Market.py b/doc/Market.py index 26141c6b..c634f3d3 100644 --- a/doc/Market.py +++ b/doc/Market.py @@ -441,6 +441,7 @@ class Market(object): 'url': 'webapp/index.php?c=Market&a=getTransactionRecord', 'params': [ ['account', '', '账号id'], + ['type', 0, '物品类型 0:所有 1:英雄 2:武器 3:芯片 5:碎片'], ['start', 0, '分页开始偏移'], ['page_size', 0, '分页大小'], ], diff --git a/webapp/controller/MarketController.class.php b/webapp/controller/MarketController.class.php index 4042a593..31d2a2db 100644 --- a/webapp/controller/MarketController.class.php +++ b/webapp/controller/MarketController.class.php @@ -978,14 +978,26 @@ class MarketController extends BaseController { public function getTransactionRecord() { $account = strtolower(getReqVal('account', '')); + $type = getReqVal('type', 0); $start = getReqVal('start', 0); $page_size = getReqVal('page_size', 10); $conn = myself()->_getMysql(''); + $type_filter_fn = function ($f) { + if ($f==0) { + return ''; + } + else { + return 'AND type=' . $f; + } + }; + $counts = $conn->execQuery( 'SELECT count(*) as count FROM t_market_transaction_record '. - 'WHERE seller=:account OR buyer=:account ORDER BY createtime DESC', + 'WHERE (seller=:account OR buyer=:account) '. + $type_filter_fn($type). + ' ORDER BY createtime DESC', array( ':account' => $account, ) @@ -1002,7 +1014,9 @@ class MarketController extends BaseController { $rows = $conn->execQuery( 'SELECT * FROM t_market_transaction_record '. - 'WHERE seller=:account OR buyer=:account ORDER BY createtime DESC '. + 'WHERE (seller=:account OR buyer=:account) '. + $type_filter_fn($type). + ' ORDER BY createtime DESC '. 'LIMIT '.$start.','.$page_size, array( ':account' => $account, @@ -1131,7 +1145,7 @@ class MarketController extends BaseController { $conn = myself()->_getMysql(''); // 1. check order status - $chk = SqlHelper::selectOne($conn, 't_market_store', array('status','idx', 'c_name', 'c_type'), array('o_link' => $orderId)); + $chk = SqlHelper::selectOne($conn, 't_market_store', array('status','idx', 'c_name', 'token_type'), array('o_link' => $orderId)); if (empty($chk)) { $this->_rspErr(1, 'not found order, orderId='.$orderId); return; @@ -1158,7 +1172,7 @@ class MarketController extends BaseController { 'tokenid' => $tokenId, 'amount' => $amount, 'name' => $chk['c_name'], - 'type' => $chk['c_type'], + 'type' => $chk['token_type'], ); $this->addTransactionRecord($record); $this->_rspOk();