1
This commit is contained in:
parent
ec31553a08
commit
ca75efd0bb
@ -85,3 +85,23 @@ func GetGoldBullionByNetIdTokenId(netId int32, tokenId string, itemId *int32) bo
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
func GetGoldBullionByTokenId(tokenId string, itemId *int32) bool {
|
||||
result := false
|
||||
f5.GetGoStyleDb().OrmSelectOne(
|
||||
constant.GAME_DB,
|
||||
"t_gold_bullion",
|
||||
[][]string {
|
||||
{"token_id", tokenId},
|
||||
},
|
||||
func (err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if ds.Next() {
|
||||
*itemId = q5.ToInt32(ds.GetByName("item_id"))
|
||||
result = true
|
||||
}
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
@ -1,24 +1,99 @@
|
||||
package spec_transfer721
|
||||
|
||||
import (
|
||||
"q5"
|
||||
"f5"
|
||||
"main/service"
|
||||
"main/constant"
|
||||
"mt"
|
||||
"jccommon"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type goldBullion struct {
|
||||
mailCfgHash *q5.ConcurrentMap[string, *jccommon.MailConfig]
|
||||
}
|
||||
|
||||
func (this* goldBullion) onMint(dbIdx int64, netId int32, contractAddress string, tokenId string,
|
||||
from string, to string) bool {
|
||||
return true
|
||||
ok := this.internalSendMail(dbIdx, to, constant.MAIL_GOLD_BULLION_MINT, tokenId)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (this* goldBullion) onLock(dbIdx int64, netId int32, contractAddress string, tokenId string,
|
||||
from string, to string) bool {
|
||||
return true
|
||||
ok := this.internalSendMail(dbIdx, from, constant.MAIL_GOLD_BULLION_LOCK, tokenId)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (this *goldBullion) onUnlock(dbIdx int64, netId int32, contractAddress string, tokenId string,
|
||||
from string, to string) bool {
|
||||
return true
|
||||
ok := this.internalSendMail(dbIdx, to, constant.MAIL_GOLD_BULLION_UNLOCK, tokenId)
|
||||
return ok
|
||||
}
|
||||
|
||||
func (this* goldBullion) internalSendMail(dbIdx int64, accountAddress string, mailName string, tokenId string) bool {
|
||||
var itemId int32
|
||||
if !service.GetGoldBullionByTokenId(tokenId, &itemId) {
|
||||
return true
|
||||
}
|
||||
itemMeta := mt.Table.Item.GetById(q5.ToInt64(itemId))
|
||||
if itemMeta == nil {
|
||||
return true
|
||||
}
|
||||
accountId := service.GetAccountIdByAddress(accountAddress)
|
||||
if accountId == "" {
|
||||
return true
|
||||
}
|
||||
mailMeta := mt.Table.Mail.GetByName(mailName)
|
||||
if mailMeta == nil {
|
||||
return true
|
||||
}
|
||||
mailCfg := this.getMailConfig(mailName)
|
||||
if mailCfg == nil {
|
||||
return true
|
||||
}
|
||||
nowTime := f5.GetApp().GetRealSeconds() + 3600 * 24 * 7
|
||||
subject := mailMeta.GetTitle()
|
||||
content := mailMeta.ReplaceContent(map[string]string{
|
||||
"${goldBullion.name}": itemMeta.GetRealName(),
|
||||
})
|
||||
uniKey := fmt.Sprintf("%s_%s_%d", mailName, tokenId, dbIdx)
|
||||
sendOk := service.SendSysMail(
|
||||
uniKey,
|
||||
accountId,
|
||||
subject,
|
||||
content,
|
||||
q5.ToInt32(nowTime),
|
||||
mailCfg.Tag1,
|
||||
mailCfg.Tag2)
|
||||
if sendOk {
|
||||
return service.UpdateSpecTransferStatus(dbIdx, 1)
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *goldBullion) getMailConfig(mailName string) *jccommon.MailConfig {
|
||||
if v, ok := this.mailCfgHash.Load(mailName); ok {
|
||||
return *v
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (this *goldBullion) registerMailConfig(mailName string, tag1 int32, tag2 int32) {
|
||||
p := new(jccommon.MailConfig)
|
||||
p.MailName = mailName
|
||||
p.Tag1 = tag1
|
||||
p.Tag2 = tag2
|
||||
this.mailCfgHash.Store(mailName, p)
|
||||
}
|
||||
|
||||
func newGoldBullion() *goldBullion {
|
||||
p := new(goldBullion)
|
||||
p.mailCfgHash = new(q5.ConcurrentMap[string, *jccommon.MailConfig])
|
||||
p.registerMailConfig(constant.MAIL_GOLD_BULLION_MINT, jccommon.MAIL_TAG1_GOLD_BULLION, jccommon.MAIL_TAG2_GOLD_BULLION_MINT)
|
||||
p.registerMailConfig(constant.MAIL_GOLD_BULLION_LOCK, jccommon.MAIL_TAG1_GOLD_BULLION, jccommon.MAIL_TAG2_GOLD_BULLION_LOCK)
|
||||
p.registerMailConfig(constant.MAIL_GOLD_BULLION_UNLOCK, jccommon.MAIL_TAG1_GOLD_BULLION, jccommon.MAIL_TAG2_GOLD_BULLION_UNLOCK)
|
||||
return p
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user