This commit is contained in:
aozhiwei 2024-06-22 14:53:16 +08:00
parent fd5df2abff
commit def608e0b0
2 changed files with 69 additions and 1 deletions

View File

@ -43,3 +43,45 @@ func GetItemIdHeroQuality(netId int32, contractAddress string, tokenId string,
}
})
}
func GetHeroByTokenId(tokenId string, itemId *int32, heroQuality *int32) bool {
result := false
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() {
*itemId = q5.ToInt32(ds.GetByName("hero_id"))
*heroQuality = q5.ToInt32(ds.GetByName("quality"))
result = true
}
})
return result
}
func GetGoldBullionTokenId(netId int32, tokenId string, itemId *int32) bool {
result := false
f5.GetGoStyleDb().OrmSelectOne(
constant.GAME_DB,
"t_gold_bullion",
[][]string {
{"net_id", q5.ToString(netId)},
{"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
}

View File

@ -7,6 +7,7 @@ import (
"fmt"
"jccommon"
"main/constant"
"main/service"
)
type repairNft struct {
@ -92,10 +93,17 @@ SELECT * FROM nft WHERE idx > %d AND item_id = 0 LIMIT 1000`,
}
func (this* repairNft) repairNft(ds *f5.DataSet) bool {
netId := q5.ToInt32(ds.GetByName("net_id"))
contractAddress := ds.GetByName("contract_address")
tokenId := ds.GetByName("token_id")
switch q5.ToInt32(ds.GetByName("token_type")) {
case jccommon.NFT_TYPE_CFHERO:
{
var itemId int32
var quality int32
if service.GetHeroByTokenId(tokenId, &itemId, &quality) {
this.updateNftItemId(netId, contractAddress, tokenId, itemId)
}
}
case jccommon.NFT_TYPE_GOLD_BULLION:
{
@ -104,3 +112,21 @@ func (this* repairNft) repairNft(ds *f5.DataSet) bool {
}
return true
}
func (this* repairNft) updateNftItemId(netId int32, contractAddress string, tokenId string,
itemId int32) {
f5.GetGoStyleDb().Update(
constant.BCNFT_DB,
"t_nft",
[][]string {
{"net_id", q5.ToString(netId)},
{"contract_address", contractAddress},
{"token_id", tokenId},
{"item_id", q5.ToString(itemId)},
},
[][]string {
{"item_id", q5.ToString(itemId)},
},
func (err error, lastInsertId int64, rowsAffected int64) {
})
}