From 77101b6ce5431eda33d3b033b699a345d7eca7df Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 22 Jun 2024 13:15:04 +0800 Subject: [PATCH] 1 --- server/backtask/task/repair_nft.go | 112 ++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 3 deletions(-) diff --git a/server/backtask/task/repair_nft.go b/server/backtask/task/repair_nft.go index 06f32ced..df0d6561 100644 --- a/server/backtask/task/repair_nft.go +++ b/server/backtask/task/repair_nft.go @@ -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")) + } + }) + } + } + }) +}