This commit is contained in:
aozhiwei 2022-04-16 23:53:28 +08:00
parent 2fec28e2cb
commit c5086a2e20
4 changed files with 37 additions and 19 deletions

View File

@ -1,10 +1,20 @@
const utils = require('j7/utils');
const bcutils = require('j7/bcutils');
const basewrap = require('./basewrap');
class Present extends basewrap.BaseWrap {
randItem() {
let item = null;
item = {
itemId: 3100,
tokenType: bcutils.HERO_TYPE
};
return item;
}
getCount() {
return 1;
}
}

View File

@ -1,11 +1,11 @@
{
"name": "web3server",
"name": "web3helper",
"version": "1.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "web3server",
"name": "web3helper",
"version": "1.0.0",
"dependencies": {
"@metamask/eth-sig-util": "^4.0.0",

View File

@ -9,9 +9,10 @@ class Present extends BaseService {
async init() {
this.gameId = 2006;
this.nowTime = utils.getUtcTime();
this.tokenTime = nowTime;
this.idx = 1;
this.tokenTime = this.nowTime;
this.idx = 0;
//console.log(utils.pad(undefined, 2));
const {err, conn} = await app.getDbConn('MarketDb0');
if (err) {
throw 'db error:' + err;
@ -31,22 +32,24 @@ class Present extends BaseService {
async processList(name, list) {
for (let i in list){
const presentMeta = list[i];
const randItem = item.randItem();
const randItem = presentMeta.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());
for (let ii = 0; ii < presentMeta.getCount(); ++ii) {
await this.processOne(bcutils.BC_FUNC_GUILD,
name,
presentMeta,
itemId,
tokenType,
ii + 1,
this.genIdx());
}
}
}
}
async processOne(funcId, name, presentMeta, itemId, tokenType, seqId) {
async processOne(funcId, name, presentMeta, itemId, tokenType, seqId, idx) {
const tokenId = bcutils.genTokenId(
this.gameId,
funcId,
@ -54,6 +57,7 @@ class Present extends BaseService {
1,
idx
);
console.log(tokenId);
const sented = await this.isSented(name, presentMeta, seqId);
if (!sented) {
const {err} = await this.conn.insert(
@ -63,8 +67,8 @@ class Present extends BaseService {
['batch_id', name],
['row_id', presentMeta['id']],
['seq_id', seqId],
['account', presentMeta['account']],
['game_id', gameId],
['account', bcutils.toNormalAddress(presentMeta['account'])],
['game_id', this.gameId],
['bc_mint_itemid', itemId],
['bc_mint_token_type', tokenType],
@ -92,12 +96,16 @@ class Present extends BaseService {
}
genIdx() {
if (idx < bcutils.BC_MAX_TOKEN_IDX) {
++idx;
let newIdx = this.idx;
if (this.idx < bcutils.BC_MAX_TOKEN_IDX) {
newIdx = this.idx;
++this.idx;
} else {
idx = 1;
this.idx = 0;
newIdx = this.idx;
++this.tokenTime;
}
return newIdx;
}
}

2
third_party/j7 vendored

@ -1 +1 @@
Subproject commit 5eb3c611daf61cdbbacb4e81c73e73ce2d919c06
Subproject commit 29150ac5c02664638c888598f658bf9349918926