This commit is contained in:
aozhiwei 2023-06-13 15:32:26 +08:00
parent efa89241b0
commit 7256e7850f
3 changed files with 64 additions and 21 deletions

View File

@ -4,14 +4,10 @@ const BaseModel = require('./basemodel');
class Log extends BaseModel {
async add(params) {
const result = {
err: null,
seqId: 0
};
const nowTime = utils.getUtcTime();
const fields = [
['type', params['type']],
['subType', params['sub_type']],
['sub_type', params['sub_type']],
['net_id', params['net_id']],
['createtime', nowTime],
['modifytime', nowTime],

View File

@ -0,0 +1,43 @@
const utils = require('j7/utils');
const BaseModel = require('./basemodel');
class Transaction extends BaseModel {
async add(account, data, netId) {
const result = {
err: null,
seqId: 0
};
const nowTime = utils.getUtcTime();
const lastId = await this.getSession().marketConn
(
'insertEx',
't_transaction',
[
['account', account],
['data', data],
['net_id', netId],
['createtime', nowTime],
['modifytime', nowTime],
]
);
result['seqId'] = lastId;
return result;
}
async update(idx, fields) {
const err = await this.getSession().marketConn
(
'update',
't_transaction',
[
['idx', idx]
],
fields
);
return err;
}
}
module.exports = Transaction;

View File

@ -3,25 +3,17 @@ const BaseModel = require('./basemodel');
class UsedTokenId extends BaseModel {
async add(params) {
const result = {
err: null,
seqId: 0
};
async add(account, tokenId, transId, netId) {
const nowTime = utils.getUtcTime();
const fields = [
['type', params['type']],
['subType', params['sub_type']],
['net_id', params['net_id']],
['createtime', nowTime],
['modifytime', nowTime],
['account', account],
['token_id', tokenId],
['trans_id', transId],
['net_id', netId],
['confirmed', 1],
['createtime', nowTime],
['modifytime', nowTime],
];
for (i = 1; i <= 4; ++i) {
const key = 'param' + i;
if (utils.hasKey(params, key)) {
fields.push([key, params[key]]);
}
}
await this.getSession().marketConn
(
'insert',
@ -30,6 +22,18 @@ class UsedTokenId extends BaseModel {
);
}
async find(tokenId) {
const {err, row} = await this.getSession().marketConn
(
'ormSelectOne',
't_used_token_id',
[
['token_id', tokenId]
]
);
return row;
}
}
module.exports = UsedTokenId;