143 lines
2.9 KiB
Go
143 lines
2.9 KiB
Go
package service
|
|
|
|
import (
|
|
"q5"
|
|
"f5"
|
|
"jccommon"
|
|
"main/constant"
|
|
)
|
|
|
|
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 GetGoldBullionByNetIdTokenId(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
|
|
}
|
|
|
|
func GetGoldBullionItemIdByTokenId(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
|
|
}
|
|
|
|
func GetNoOpenGoldBullionItemIdByTokenId(tokenId string, itemId *int32) bool {
|
|
result := false
|
|
f5.GetGoStyleDb().OrmSelectOne(
|
|
constant.GAME_DB,
|
|
"t_gold_bullion",
|
|
[][]string {
|
|
{"token_id", tokenId},
|
|
{"status", q5.ToString(jccommon.GOLD_BULLION_NO_OPEN)},
|
|
},
|
|
func (err error, ds *f5.DataSet) {
|
|
if err != nil {
|
|
return
|
|
}
|
|
if ds.Next() {
|
|
*itemId = q5.ToInt32(ds.GetByName("item_id"))
|
|
result = true
|
|
}
|
|
})
|
|
return result
|
|
}
|
|
|
|
func NftExists(netId int32, contractAddress string, tokenId string) bool {
|
|
result := false
|
|
f5.GetGoStyleDb().OrmSelectOne(
|
|
constant.BCNFT_DB,
|
|
"t_nft",
|
|
[][]string {
|
|
{"net_id", q5.ToString(netId)},
|
|
{"token_id", tokenId},
|
|
{"contract_address", contractAddress},
|
|
},
|
|
func (err error, ds *f5.DataSet) {
|
|
if err != nil {
|
|
return
|
|
}
|
|
if ds.Next() {
|
|
result = true
|
|
}
|
|
})
|
|
return result
|
|
}
|
|
|
|
func NftUpdateLock(netId int32, contractAddress string, tokenId string,
|
|
lockIdx int64, lockAddress string, lockSender string, lockTime int32) bool {
|
|
result := false
|
|
f5.GetGoStyleDb().UpsertEx(
|
|
constant.BCNFT_DB,
|
|
"t_nft",
|
|
[][]string {
|
|
{"net_id", q5.ToString(netId)},
|
|
{"token_id", tokenId},
|
|
{"contract_address", contractAddress},
|
|
},
|
|
[][]string {
|
|
{"last_lock_idx", q5.ToString(lockIdx)},
|
|
{"last_lock_address", lockAddress},
|
|
{"last_lock_sender", lockSender},
|
|
{"last_lock_time", q5.ToString(lockTime)},
|
|
},
|
|
[][]string {},
|
|
func (err error, lastInsertId int64, rowsAffected int64) {
|
|
if err != nil {
|
|
return
|
|
}
|
|
result = true
|
|
},
|
|
func (ds *f5.DataSet) bool {
|
|
return lockIdx > q5.ToInt64(ds.GetByName("last_lock_idx"))
|
|
})
|
|
return result
|
|
}
|