Merge branch 'dev' of git.kingsome.cn:server/game2006go into dev
This commit is contained in:
commit
8bb0996d7d
11
README.md
11
README.md
@ -60,3 +60,14 @@ SMLogin
|
||||
# 参考
|
||||
|
||||
https://gorm.io/zh_CN/docs/
|
||||
|
||||
# bug
|
||||
|
||||
0x8308b66adccf350e5956cf3cf3570dd744ede760
|
||||
t_staking_daily_settlement
|
||||
10452
|
||||
idx: 10137
|
||||
|
||||
0xefdc640ecd4fcb2b4e91f9a934270d741d40d9e9
|
||||
|
||||
2024/07/29
|
||||
|
@ -1,5 +1,10 @@
|
||||
package jccommon
|
||||
|
||||
import (
|
||||
"q5"
|
||||
"f5"
|
||||
)
|
||||
|
||||
type ActivitySaleEvent struct {
|
||||
EventName string `json:"event_name"`
|
||||
EventId string `json:"event_id"`
|
||||
@ -95,6 +100,28 @@ type UserStackingPo struct {
|
||||
Contracts []*ContractStackingPo `json:"contracts"`
|
||||
}
|
||||
|
||||
type NftIdentity struct {
|
||||
NetId int32
|
||||
ContractAddress string
|
||||
TokenId string
|
||||
}
|
||||
|
||||
type NftIdentityAndExtData struct {
|
||||
NetId int32
|
||||
ContractAddress string
|
||||
TokenId string
|
||||
ItemId int32
|
||||
Quality int32
|
||||
}
|
||||
|
||||
func (this *NftIdentityAndExtData) LoadFromDb(ds *f5.DataSet) {
|
||||
this.NetId = q5.ToInt32(ds.GetByName("net_id"))
|
||||
this.ContractAddress = ds.GetByName("contract_address")
|
||||
this.TokenId = ds.GetByName("token_id")
|
||||
this.ItemId = q5.ToInt32(ds.GetByName("item_id"))
|
||||
this.Quality = q5.ToInt32(ds.GetByName("quality"))
|
||||
}
|
||||
|
||||
func NewNftStackingPo() *NftStackingPo {
|
||||
p := new(NftStackingPo)
|
||||
return p
|
||||
|
@ -180,3 +180,125 @@ func NftUpdateLock(netId int32, contractAddress string, tokenId string,
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
func RepairAllHeroNftQuality() error {
|
||||
var resultErr error
|
||||
nftDatas := []*jccommon.NftIdentityAndExtData{}
|
||||
{
|
||||
cb := func (err error, ds *f5.DataSet) {
|
||||
resultErr = err
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for ds.Next() {
|
||||
p := new(jccommon.NftIdentityAndExtData)
|
||||
p.LoadFromDb(ds)
|
||||
q5.AppendSlice(&nftDatas, p);
|
||||
}
|
||||
}
|
||||
f5.GetGoStyleDb().OrmSelect(
|
||||
constant.BCNFT_DB,
|
||||
"t_nft",
|
||||
[][]string{
|
||||
{"token_type", q5.ToString(jccommon.NFT_TYPE_CFHERO)},
|
||||
},
|
||||
cb)
|
||||
if resultErr == nil {
|
||||
f5.GetGoStyleDb().OrmSelect(
|
||||
constant.BCNFT_DB,
|
||||
"t_nft",
|
||||
[][]string{
|
||||
{"token_type", q5.ToString(jccommon.NFT_TYPE_CFHERO_NORMAL)},
|
||||
},
|
||||
cb)
|
||||
}
|
||||
}
|
||||
f5.GetSysLog().Info("nftutils.RepairAllHeroNftQuality start len:%d", len(nftDatas))
|
||||
procBatchFunc := func(batch []*jccommon.NftIdentityAndExtData) {
|
||||
if len(batch) <= 0 {
|
||||
return
|
||||
}
|
||||
sql := "SELECT token_id, hero_id, quality FROM t_hero WHERE token_id IN ("
|
||||
params := []string{}
|
||||
tokenIdQualityHash := map[string]*jccommon.NftIdentityAndExtData{}
|
||||
{
|
||||
inited := false
|
||||
for _, val := range batch {
|
||||
if !inited {
|
||||
sql += "?"
|
||||
inited = true
|
||||
} else {
|
||||
sql += ", ?"
|
||||
}
|
||||
q5.AppendSlice(¶ms, val.TokenId)
|
||||
tokenIdQualityHash[val.TokenId] = val
|
||||
}
|
||||
sql += ")"
|
||||
}
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.GAME_DB,
|
||||
sql,
|
||||
params,
|
||||
func (err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for ds.Next() {
|
||||
tokenId := ds.GetByName("token_id")
|
||||
itemId := q5.ToInt32(ds.GetByName("hero_id"))
|
||||
quality := q5.ToInt32(ds.GetByName("quality"))
|
||||
if val, ok := tokenIdQualityHash[tokenId]; ok && quality > val.Quality && itemId > 0 {
|
||||
f5.GetSysLog().Info("nftutils.RepairAllHeroNftQuality token_id:%s src_item_id:%d src_quality:%d new_item_id:%d, new_quality:%d",
|
||||
val.TokenId,
|
||||
val.ItemId,
|
||||
val.Quality,
|
||||
itemId,
|
||||
quality)
|
||||
UpdateNftItemIdQuality(
|
||||
val.NetId,
|
||||
val.ContractAddress,
|
||||
val.TokenId,
|
||||
itemId,
|
||||
quality)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
if resultErr == nil && len(nftDatas) > 0 {
|
||||
batch := []*jccommon.NftIdentityAndExtData{}
|
||||
for _, val := range nftDatas {
|
||||
if len(batch) < 100 {
|
||||
q5.AppendSlice(&batch, val)
|
||||
} else {
|
||||
procBatchFunc(batch)
|
||||
batch = []*jccommon.NftIdentityAndExtData{}
|
||||
}
|
||||
}
|
||||
if len(batch) > 0 {
|
||||
procBatchFunc(batch)
|
||||
}
|
||||
}
|
||||
f5.GetSysLog().Info("nftutils.RepairAllHeroNftQuality end err:%s", resultErr)
|
||||
return resultErr
|
||||
}
|
||||
|
||||
func UpdateNftItemIdQuality(netId int32, contractAddress string, tokenId string,
|
||||
itemId int32, quality int32) error {
|
||||
var resultErr error
|
||||
f5.GetGoStyleDb().Update(
|
||||
constant.BCNFT_DB,
|
||||
"t_nft",
|
||||
[][]string {
|
||||
{"net_id", q5.ToString(netId)},
|
||||
{"contract_address", contractAddress},
|
||||
{"token_id", tokenId},
|
||||
},
|
||||
[][]string {
|
||||
{"item_id", q5.ToString(itemId)},
|
||||
{"quality", q5.ToString(quality)},
|
||||
},
|
||||
func (err error, lastInsertId int64, rowsAffected int64) {
|
||||
resultErr = err
|
||||
})
|
||||
return resultErr
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"q5"
|
||||
"f5"
|
||||
"mt"
|
||||
"main/service"
|
||||
"jccommon"
|
||||
"main/constant"
|
||||
"time"
|
||||
@ -71,6 +72,7 @@ func (this* contribution) unInit() {
|
||||
}
|
||||
|
||||
func (this* contribution) stat(statTime int64, nowTime int64) {
|
||||
service.RepairAllHeroNftQuality()
|
||||
for true {
|
||||
if this.internalStat(statTime, nowTime) {
|
||||
return
|
||||
@ -98,10 +100,10 @@ func (this* contribution) internalStat(statTime int64, nowTime int64) bool {
|
||||
}
|
||||
{
|
||||
addressHash := new(q5.ConcurrentMap[string, *accountStacking])
|
||||
sqlTpl := "SELECT * FROM t_nft WHERE idx > %d AND token_type <> ? AND last_lock_time < ? AND owner_address IN ("
|
||||
sqlTpl := "SELECT * FROM t_nft WHERE idx > %d AND token_type <> ? AND last_lock_time <= ? AND owner_address IN ("
|
||||
params := []string{
|
||||
q5.ToString(jccommon.NFT_TYPE_GOLD_BULLION),
|
||||
q5.ToString(statTime),
|
||||
q5.ToString(statDaySeconds),
|
||||
}
|
||||
{
|
||||
inited := false
|
||||
|
@ -20,7 +20,7 @@ func (this *taskMgr) Init() {
|
||||
this.sysMail.init()
|
||||
this.repairOrder.init()
|
||||
//this.refreshMeta.init()
|
||||
//this.contribution.init()
|
||||
this.contribution.init()
|
||||
this.chainActivity.init()
|
||||
this.recharge.init()
|
||||
}
|
||||
@ -28,7 +28,7 @@ func (this *taskMgr) Init() {
|
||||
func (this *taskMgr) UnInit() {
|
||||
this.recharge.unInit()
|
||||
this.chainActivity.unInit()
|
||||
//this.contribution.unInit()
|
||||
this.contribution.unInit()
|
||||
//this.refreshMeta.unInit()
|
||||
this.repairOrder.unInit()
|
||||
this.sysMail.unInit()
|
||||
|
@ -114,9 +114,12 @@ func (sa *StackingApi) ContributionQuery(c *gin.Context) {
|
||||
ContributionPoint string `json:"contribution_point"`
|
||||
}{}
|
||||
for ds.Next() {
|
||||
obj.Date = q5.SafeToInt32(ds.GetByName("settle_date"))
|
||||
obj.ContributionPoint = ds.GetByName("contribution")
|
||||
rspObj.Rows = append(rspObj.Rows, obj)
|
||||
contributionPoint := q5.ToFloat64(ds.GetByName("contribution"))
|
||||
if contributionPoint > 0.00001 {
|
||||
obj.Date = q5.SafeToInt32(ds.GetByName("settle_date"))
|
||||
obj.ContributionPoint = ds.GetByName("contribution")
|
||||
rspObj.Rows = append(rspObj.Rows, obj)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user