1
This commit is contained in:
parent
ddba7238ac
commit
61d36d414c
@ -1,17 +1,77 @@
|
|||||||
|
const app = require('j7/app');
|
||||||
const BaseService = require('./baseservice');
|
const BaseService = require('./baseservice');
|
||||||
const metaFactory = require('../metadata/factory');
|
const metaFactory = require('../metadata/factory');
|
||||||
|
|
||||||
class Present extends BaseService {
|
class Present extends BaseService {
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
const {err, conn} = await app.getDbConn('MarketDb0');
|
||||||
|
if (!err) {
|
||||||
|
throw 'db error:' + err;
|
||||||
|
}
|
||||||
|
this.conn = conn;
|
||||||
const presentList = metaFactory.getMetaByKey('PresentList', '0')['list'];
|
const presentList = metaFactory.getMetaByKey('PresentList', '0')['list'];
|
||||||
for (let i in presentList) {
|
for (let i in presentList) {
|
||||||
const name = presentList[i];
|
const name = presentList[i];
|
||||||
|
const list = [];
|
||||||
metaFactory.traverseMetaList('Present' + name, (item) => {
|
metaFactory.traverseMetaList('Present' + name, (item) => {
|
||||||
|
list.push(item);
|
||||||
});
|
});
|
||||||
|
await this.processList(name, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async processList(name, list) {
|
||||||
|
for (let i in list){
|
||||||
|
const item = list[i];
|
||||||
|
await processOne(name, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async processOne(name, item) {
|
||||||
|
const gameId = 2006;
|
||||||
|
const seqId = 0;
|
||||||
|
const tokenId = 0;
|
||||||
|
const itemId = 0;
|
||||||
|
const tokenType = 0;
|
||||||
|
const sented = await this.isSented(name, item);
|
||||||
|
if (!sented) {
|
||||||
|
const nowTime = utils.getUtcTime();
|
||||||
|
const {err} = await this.conn.insert(
|
||||||
|
't_present',
|
||||||
|
[
|
||||||
|
['token_id', tokenId]
|
||||||
|
['batch_id', name],
|
||||||
|
['row_id', item['id']],
|
||||||
|
['seq_id', seqId],
|
||||||
|
['account', item['account']],
|
||||||
|
['game_id', gameId],
|
||||||
|
|
||||||
|
['bc_mint_itemid', itemId],
|
||||||
|
['bc_mint_token_type', tokenType],
|
||||||
|
|
||||||
|
['createtime', nowTime],
|
||||||
|
['modifytime', nowTime],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async isSented(name, item, seqId) {
|
||||||
|
const {err, row} = await this.conn.ormSelect(
|
||||||
|
't_present',
|
||||||
|
[
|
||||||
|
['batch_id', name],
|
||||||
|
['row_id', item['id']],
|
||||||
|
['seq_id', seqId],
|
||||||
|
]
|
||||||
|
);
|
||||||
|
if (err) {
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
return row ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = Present;
|
module.exports = Present;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user