This commit is contained in:
aozhiwei 2022-04-16 23:24:19 +08:00
parent 2dfe14c182
commit 2fec28e2cb
3 changed files with 48 additions and 17 deletions

View File

@ -3,6 +3,10 @@ const basewrap = require('./basewrap');
class Present extends basewrap.BaseWrap { class Present extends basewrap.BaseWrap {
randItem() {
}
} }
module.exports = Present; module.exports = Present;

View File

@ -1,11 +1,17 @@
const app = require('j7/app'); const app = require('j7/app');
const utils = require('j7/utils'); const utils = require('j7/utils');
const bcutils = require('j7/bcutils');
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() {
this.gameId = 2006;
this.nowTime = utils.getUtcTime();
this.tokenTime = nowTime;
this.idx = 1;
const {err, conn} = await app.getDbConn('MarketDb0'); const {err, conn} = await app.getDbConn('MarketDb0');
if (err) { if (err) {
throw 'db error:' + err; throw 'db error:' + err;
@ -24,46 +30,58 @@ class Present extends BaseService {
async processList(name, list) { async processList(name, list) {
for (let i in list){ for (let i in list){
const item = list[i]; const presentMeta = list[i];
await this.processOne(name, item); 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) { async processOne(funcId, name, presentMeta, itemId, tokenType, seqId) {
const gameId = 2006; const tokenId = bcutils.genTokenId(
const seqId = 0; this.gameId,
const tokenId = 0; funcId,
const itemId = 0; this.nowTime,
const tokenType = 0; 1,
const sented = await this.isSented(name, item, seqId); idx
);
const sented = await this.isSented(name, presentMeta, seqId);
if (!sented) { if (!sented) {
const nowTime = utils.getUtcTime();
const {err} = await this.conn.insert( const {err} = await this.conn.insert(
't_present', 't_present',
[ [
['token_id', tokenId], ['token_id', tokenId],
['batch_id', name], ['batch_id', name],
['row_id', item['id']], ['row_id', presentMeta['id']],
['seq_id', seqId], ['seq_id', seqId],
['account', item['account']], ['account', presentMeta['account']],
['game_id', gameId], ['game_id', gameId],
['bc_mint_itemid', itemId], ['bc_mint_itemid', itemId],
['bc_mint_token_type', tokenType], ['bc_mint_token_type', tokenType],
['createtime', nowTime], ['createtime', this.nowTime],
['modifytime', nowTime] ['modifytime', this.nowTime]
] ]
); );
} }
} }
async isSented(name, item, seqId) { async isSented(name, presentMeta, seqId) {
const {err, row} = await this.conn.ormSelectOne( const {err, row} = await this.conn.ormSelectOne(
't_present', 't_present',
[ [
['batch_id', name], ['batch_id', name],
['row_id', item['id']], ['row_id', presentMeta['id']],
['seq_id', seqId], ['seq_id', seqId],
] ]
); );
@ -73,6 +91,15 @@ class Present extends BaseService {
return row ? true : false; return row ? true : false;
} }
genIdx() {
if (idx < bcutils.BC_MAX_TOKEN_IDX) {
++idx;
} else {
idx = 1;
++this.tokenTime;
}
}
} }
module.exports = Present; module.exports = Present;

2
third_party/j7 vendored

@ -1 +1 @@
Subproject commit 33f9c8d06a1ea4d8aa2cd682f1b33cd3baf8029a Subproject commit 5eb3c611daf61cdbbacb4e81c73e73ce2d919c06