This commit is contained in:
aozhiwei 2024-06-22 13:15:04 +08:00
parent 6c3ae9d9a8
commit 77101b6ce5

View File

@ -5,6 +5,7 @@ import (
"f5"
"time"
"fmt"
"jccommon"
"main/constant"
)
@ -13,13 +14,15 @@ type repairNft struct {
}
func (this* repairNft) init() {
go this.process()
go this.processNft()
go this.processOrder()
go this.processSale()
}
func (this* repairNft) unInit() {
}
func (this* repairNft) process() {
func (this* repairNft) processNft() {
var lastIdx int64
for true {
hasNextData := false
@ -44,10 +47,113 @@ SELECT * FROM nft WHERE idx > %d AND item_id = 0 LIMIT 1000`,
}
})
if hasNextData {
time.Sleep(time.Second * 5)
time.Sleep(time.Second * 10)
} else {
lastIdx = 0
time.Sleep(time.Second * 60 * 5)
}
}
}
func (this* repairNft) processOrder() {
var lastIdx int64
for true {
hasNextData := false
sql := fmt.Sprintf(`
SELECT * FROM nft WHERE idx > %d AND item_id = 0 LIMIT 1000`,
lastIdx,
)
f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB,
sql,
[]string{
},
func (err error, ds *f5.DataSet) {
if err == nil {
for ds.Next() {
idx := q5.ToInt64(ds.GetByName("idx"))
if idx > lastIdx {
lastIdx = idx
}
hasNextData = true
}
}
})
if hasNextData {
time.Sleep(time.Second * 10)
} else {
lastIdx = 0
time.Sleep(time.Second * 60 * 5)
}
}
}
func (this* repairNft) processSale() {
var lastIdx int64
for true {
hasNextData := false
sql := fmt.Sprintf(`
SELECT * FROM nft WHERE idx > %d AND item_id = 0 LIMIT 1000`,
lastIdx,
)
f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB,
sql,
[]string{
},
func (err error, ds *f5.DataSet) {
if err == nil {
for ds.Next() {
idx := q5.ToInt64(ds.GetByName("idx"))
if idx > lastIdx {
lastIdx = idx
}
hasNextData = true
}
}
})
if hasNextData {
time.Sleep(time.Second * 10)
} else {
lastIdx = 0
time.Sleep(time.Second * 60 * 5)
}
}
}
func (this* repairNft) getItemIdHeroQuality(netId int32, contractAddress string, tokenId string,
itemId *int32, heroQuality *int32) {
f5.GetGoStyleDb().OrmSelectOne(
constant.BCNFT_DB,
"t_nft",
[][]string {
{"net_id", q5.ToString(netId)},
{"contract_address", contractAddress},
{"token_id", tokenId},
},
func (err error, ds *f5.DataSet) {
if err != nil {
return
}
if ds.Next() {
*itemId = q5.ToInt32(ds.GetByName("item_id"))
tokenType := q5.ToInt32(ds.GetByName("token_type"))
if tokenType == jccommon.NFT_TYPE_CFHERO {
f5.GetGoStyleDb().OrmSelectOne(
constant.GAME_DB,
"t_hero",
[][]string {
{"token_id", tokenId},
},
func (err error, ds *f5.DataSet) {
if err != nil {
return
}
if ds.Next() {
*heroQuality = q5.ToInt32(ds.GetByName("quality"))
}
})
}
}
})
}