This commit is contained in:
aozhiwei 2024-06-18 14:04:58 +08:00
parent 62c5d98479
commit 40d769e55e
4 changed files with 58 additions and 9 deletions

View File

@ -63,6 +63,11 @@ function getNftTableName(tokenType) {
return 't_chip'; return 't_chip';
} }
break; break;
case bcconst.BC_NFT_GOLD_BULLION:
{
return 't_gold_bullion';
}
break;
default: default:
{ {
return ''; return '';

View File

@ -9,8 +9,8 @@ class Transfer extends BaseEventProcess {
async start() { async start() {
const returnValues = this.getReturnValues(); const returnValues = this.getReturnValues();
const from = returnValues['from']; const from = bcutils.toNormalAddress(returnValues['from']);
const to = returnValues['to']; const to = bcutils.toNormalAddress(returnValues['to']);
const tokenId = returnValues['tokenId']; const tokenId = returnValues['tokenId'];
await this.mustBeMint(to, tokenId, bcconst.BC_NFT_HERO); await this.mustBeMint(to, tokenId, bcconst.BC_NFT_HERO);
@ -25,7 +25,7 @@ class Transfer extends BaseEventProcess {
if (airDropMeta) { if (airDropMeta) {
await this.apiMint(to, tokenId, airDropMeta); await this.apiMint(to, tokenId, airDropMeta);
} else { } else {
await this.ingameActivate(tokenId, bcconst.BC_NFT_HERO); await this.ingameActivate(from, to, tokenId, bcconst.BC_NFT_HERO);
} }
} else { } else {
await this.add721NftRefresh await this.add721NftRefresh

View File

@ -9,13 +9,13 @@ class Transfer extends BaseEventProcess {
async start() { async start() {
const returnValues = this.getReturnValues(); const returnValues = this.getReturnValues();
const from = returnValues['from']; const from = bcutils.toNormalAddress(returnValues['from']);
const to = returnValues['to']; const to = bcutils.toNormalAddress(returnValues['to']);
const tokenId = returnValues['tokenId']; const tokenId = returnValues['tokenId'];
await this.mustBeMint(to, tokenId, bcconst.BC_NFT_GOLD_BULLION); await this.mustBeMint(to, tokenId, bcconst.BC_NFT_GOLD_BULLION);
if (bcutils.isSysAddress(from)) { if (bcutils.isSysAddress(from)) {
await this.ingameActivate(tokenId, bcconst.BC_NFT_GOLD_BULLION); await this.ingameActivate(from, to, tokenId, bcconst.BC_NFT_GOLD_BULLION);
} else { } else {
await this.add721NftRefresh await this.add721NftRefresh
( (

View File

@ -396,7 +396,7 @@ class BaseEventProcess {
} }
} }
async ingameActivate(tokenId, tokenType) { async ingameActivate(from, to, tokenId, tokenType) {
const logHead = this.genLogHead(' ingameActivate '); const logHead = this.genLogHead(' ingameActivate ');
const tblName = bchelper.getNftTableName(tokenType); const tblName = bchelper.getNftTableName(tokenType);
if (!tblName) { if (!tblName) {
@ -404,11 +404,13 @@ class BaseEventProcess {
return; return;
} }
if (tokenType == bcconst.BC_NFT_HERO) { if (tokenType == bcconst.BC_NFT_HERO) {
await this.ingameActivateHero(tblName, tokenId, tokenType); await this.ingameActivateHero(from, to, tblName, tokenId, tokenType);
} else if (tokenType == bcconst.BC_NFT_GOLD_BULLION) {
await this.ingameActivateGoldBullion(from, to, tblName, tokenId, tokenType);
} }
} }
async ingameActivateHero(tblName, tokenId, tokenType) { async ingameActivateHero(from, to, tblName, tokenId, tokenType) {
const logHead = this.genLogHead(' ingameActivateHero '); const logHead = this.genLogHead(' ingameActivateHero ');
const nowTime = utils.getUtcTime(); const nowTime = utils.getUtcTime();
{ {
@ -458,6 +460,48 @@ class BaseEventProcess {
} }
} }
async ingameActivateGoldBullion(from, to, tblName, tokenId, tokenType) {
const logHead = this.genLogHead(' ingameActivateGoldBullion ');
const nowTime = utils.getUtcTime();
const {err, row} = await this.gameDbConn(
'ormSelectOne',
tblName,
[
['token_id', tokenId],
]
);
if (err) {
this.throwError(logHead + err);
}
if (!row) {
await this.addLog([
['type', 'ingameActivateGoldError'],
['subtype', 'token_id.notfound'],
['net_id', this.getNetId()],
['param1', tokenId],
['createtime', nowTime],
['modifytime', nowTime],
]);
return;
}
if (!row['activated']) {
const {err} = await this.gameDbConn(
'update',
tblName,
[
['token_id', tokenId],
],
[
['activated', 1],
['activate_time', nowTime],
]
);
if (err) {
this.throwError(logHead + err);
}
}
}
async addLog(fieldsKv) { async addLog(fieldsKv) {
const {err} = await this.bcEventDbConn( const {err} = await this.bcEventDbConn(
'insert', 'insert',