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 utils = require('j7/utils');
const bcutils = require('j7/bcutils');
const basewrap = require('./basewrap'); const basewrap = require('./basewrap');
class Present extends basewrap.BaseWrap { class Present extends basewrap.BaseWrap {
randItem() { 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", "version": "1.0.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "web3server", "name": "web3helper",
"version": "1.0.0", "version": "1.0.0",
"dependencies": { "dependencies": {
"@metamask/eth-sig-util": "^4.0.0", "@metamask/eth-sig-util": "^4.0.0",

View File

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

2
third_party/j7 vendored

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