...
This commit is contained in:
parent
d9809bf9d3
commit
1fb85e0bca
@ -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'],
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user