1
This commit is contained in:
parent
2dfe14c182
commit
2fec28e2cb
@ -3,6 +3,10 @@ const basewrap = require('./basewrap');
|
||||
|
||||
class Present extends basewrap.BaseWrap {
|
||||
|
||||
randItem() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Present;
|
||||
|
@ -1,11 +1,17 @@
|
||||
const app = require('j7/app');
|
||||
const utils = require('j7/utils');
|
||||
const bcutils = require('j7/bcutils');
|
||||
const BaseService = require('./baseservice');
|
||||
const metaFactory = require('../metadata/factory');
|
||||
|
||||
class Present extends BaseService {
|
||||
|
||||
async init() {
|
||||
this.gameId = 2006;
|
||||
this.nowTime = utils.getUtcTime();
|
||||
this.tokenTime = nowTime;
|
||||
this.idx = 1;
|
||||
|
||||
const {err, conn} = await app.getDbConn('MarketDb0');
|
||||
if (err) {
|
||||
throw 'db error:' + err;
|
||||
@ -24,46 +30,58 @@ class Present extends BaseService {
|
||||
|
||||
async processList(name, list) {
|
||||
for (let i in list){
|
||||
const item = list[i];
|
||||
await this.processOne(name, item);
|
||||
const presentMeta = list[i];
|
||||
const randItem = item.randItem();
|
||||
if (randItem) {
|
||||
const itemId = randItem['itemId'];
|
||||
const tokenType = randItem['tokenType'];
|
||||
await this.processOne(bcutils.BC_FUNC_GUILD,
|
||||
name,
|
||||
presentMeta,
|
||||
itemId,
|
||||
tokenType,
|
||||
seqId,
|
||||
this.genIdx());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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, seqId);
|
||||
async processOne(funcId, name, presentMeta, itemId, tokenType, seqId) {
|
||||
const tokenId = bcutils.genTokenId(
|
||||
this.gameId,
|
||||
funcId,
|
||||
this.nowTime,
|
||||
1,
|
||||
idx
|
||||
);
|
||||
const sented = await this.isSented(name, presentMeta, seqId);
|
||||
if (!sented) {
|
||||
const nowTime = utils.getUtcTime();
|
||||
const {err} = await this.conn.insert(
|
||||
't_present',
|
||||
[
|
||||
['token_id', tokenId],
|
||||
['batch_id', name],
|
||||
['row_id', item['id']],
|
||||
['row_id', presentMeta['id']],
|
||||
['seq_id', seqId],
|
||||
['account', item['account']],
|
||||
['account', presentMeta['account']],
|
||||
['game_id', gameId],
|
||||
|
||||
['bc_mint_itemid', itemId],
|
||||
['bc_mint_token_type', tokenType],
|
||||
|
||||
['createtime', nowTime],
|
||||
['modifytime', nowTime]
|
||||
['createtime', this.nowTime],
|
||||
['modifytime', this.nowTime]
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
async isSented(name, item, seqId) {
|
||||
async isSented(name, presentMeta, seqId) {
|
||||
const {err, row} = await this.conn.ormSelectOne(
|
||||
't_present',
|
||||
[
|
||||
['batch_id', name],
|
||||
['row_id', item['id']],
|
||||
['row_id', presentMeta['id']],
|
||||
['seq_id', seqId],
|
||||
]
|
||||
);
|
||||
@ -73,6 +91,15 @@ class Present extends BaseService {
|
||||
return row ? true : false;
|
||||
}
|
||||
|
||||
genIdx() {
|
||||
if (idx < bcutils.BC_MAX_TOKEN_IDX) {
|
||||
++idx;
|
||||
} else {
|
||||
idx = 1;
|
||||
++this.tokenTime;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = Present;
|
||||
|
2
third_party/j7
vendored
2
third_party/j7
vendored
@ -1 +1 @@
|
||||
Subproject commit 33f9c8d06a1ea4d8aa2cd682f1b33cd3baf8029a
|
||||
Subproject commit 5eb3c611daf61cdbbacb4e81c73e73ce2d919c06
|
Loading…
x
Reference in New Issue
Block a user