This commit is contained in:
aozhiwei 2024-06-23 20:48:05 +08:00
parent 64326e169b
commit 91dfd320ba
3 changed files with 37 additions and 4 deletions

View File

@ -5,30 +5,32 @@ import (
"main/service"
"main/constant"
"mt"
//"fmt"
)
type hero struct {
mailCfgHash *q5.ConcurrentMap[string, *mailConfig]
}
func (this* hero) onMint(dbIdx int64, netId int32, contractAddress string, tokenId string,
from string, to string) bool {
ok := this.internalSendMail(to, constant.MAIL_HERO_MINT, tokenId)
ok := this.internalSendMail(dbIdx, to, constant.MAIL_HERO_MINT, tokenId)
return ok
}
func (this* hero) onLock(dbIdx int64, netId int32, contractAddress string, tokenId string,
from string, to string) bool {
ok := this.internalSendMail(from, constant.MAIL_HERO_LOCK, tokenId)
ok := this.internalSendMail(dbIdx, from, constant.MAIL_HERO_LOCK, tokenId)
return ok
}
func (this *hero) onUnlock(dbIdx int64, netId int32, contractAddress string, tokenId string,
from string, to string) bool {
ok := this.internalSendMail(to, constant.MAIL_HERO_UNLOCK, tokenId)
ok := this.internalSendMail(dbIdx, to, constant.MAIL_HERO_UNLOCK, tokenId)
return ok
}
func (this* hero) internalSendMail(accountAddress string, mailName string, tokenId string) bool {
func (this* hero) internalSendMail(dbIdx int64, accountAddress string, mailName string, tokenId string) bool {
var itemId, heroQuality int32
if !service.GetHeroByTokenId(tokenId, &itemId, &heroQuality) {
return true
@ -45,10 +47,20 @@ func (this* hero) internalSendMail(accountAddress string, mailName string, token
if mailMeta == nil {
return true
}
//uniKey := fmt.Sprintf("%d_%s_%s", dbIdx, mailName, tokenId)
return true
}
func (this *hero) getMailConfigMeta(mailName string) *mailConfig {
if v, ok := this.mailCfgHash.Load(mailName); ok {
return *v
} else {
return nil
}
}
func newHero() *hero {
p := new(hero)
p.mailCfgHash = new(q5.ConcurrentMap[string, *mailConfig])
return p
}

View File

@ -8,3 +8,9 @@ type specTransfer721Handle interface {
onUnlock(dbIdx int64, netId int32, contractAddress string, tokenId string,
from string, to string) bool
}
type mailConfig struct {
mailName string
tag1 int32
tag2 int32
}

View File

@ -30,3 +30,18 @@ const (
CONTRACT_NAME_GoldBrick = "GoldBrick"
CONTRACT_NAME_NFTLock = "NFTLock"
)
const (
MAIL_TAG1_HERO = 100
MAIL_TAG1_GOLD_BULLION = 101
)
const (
MAIL_TAG2_HERO_MINT = 1
MAIL_TAG2_HERO_LOCK = 2
MAIL_TAG2_HERO_UNLOCK = 3
MAIL_TAG2_GOLD_BULLION_MINT = 1
MAIL_TAG2_GOLD_BULLION_LOCK = 2
MAIL_TAG2_GOLD_BULLION_UNLOCK = 3
)