diff --git a/server/light_backtask/task/contribution.go b/server/light_backtask/task/contribution.go index 18070829..dae94f52 100644 --- a/server/light_backtask/task/contribution.go +++ b/server/light_backtask/task/contribution.go @@ -19,6 +19,14 @@ type accountStacking struct { nfts []*jccommon.NftStacking } +func (this* accountStacking) calcScore() int64 { + return 0 +} + +func (this* accountStacking) getNftJsonData() string { + return "" +} + func (this* contribution) init() { this.lockMetas = []*mt.Contract{} mt.Table.Contract.Traverse(func (ele *mt.Contract) bool { @@ -84,7 +92,7 @@ func (this* contribution) internalStat(statTime int64, nowTime int64) bool { } q5.AppendSlice(¶ms, lockMeta.GetAddress()) } - sqlTpl += ") LIMIT 1000" + sqlTpl += ") ORDER BY idx LIMIT 1000" } err := f5.GetGoStyleDb().BatchLoadFullTable( constant.BCNFT_DB, @@ -102,7 +110,7 @@ func (this* contribution) internalStat(statTime int64, nowTime int64) bool { if err != nil { return false } - return this.saveToDb(addressHash) + return this.saveToDb(statDaySeconds, addressHash) } } @@ -119,7 +127,7 @@ func (this* contribution) calc() { } func (this* contribution) isStatEd(statDaySeconds int64) (error, bool) { - return nil, true + return nil, false } func (this* contribution) loadFromDb(addressHash *q5.ConcurrentMap[string, *accountStacking], @@ -128,6 +136,7 @@ func (this* contribution) loadFromDb(addressHash *q5.ConcurrentMap[string, *acco if accountAddress == "" { return true } + ownerAddress := ds.GetByName("owner_address") p := new(jccommon.NftStacking) p.NetId = q5.ToInt32(ds.GetByName("net_id")) p.ContractAddress = ds.GetByName("contract_address") @@ -139,7 +148,7 @@ func (this* contribution) loadFromDb(addressHash *q5.ConcurrentMap[string, *acco if lockMeta == nil { return true } - if lockMeta.GetAddress() != p.ContractAddress { + if lockMeta.GetAddress() != ownerAddress { return true } if a, ok := addressHash.Load(accountAddress); ok { @@ -149,10 +158,43 @@ func (this* contribution) loadFromDb(addressHash *q5.ConcurrentMap[string, *acco a.accountAddress = accountAddress a.nfts = []*jccommon.NftStacking{} q5.AppendSlice(&a.nfts, p) + addressHash.Store(accountAddress, a) } return true } -func (this* contribution) saveToDb(addressHash *q5.ConcurrentMap[string, *accountStacking]) bool { - return true +func (this* contribution) saveToDb( + statDaySeconds int64, + addressHash *q5.ConcurrentMap[string, *accountStacking]) bool { + var resultErr error + nowTime := f5.GetApp().GetRealSeconds() + addressHash.Range(func (k string, v *accountStacking) bool { + score := v.calcScore() + nftData := v.getNftJsonData() + f5.GetGoStyleDb().Upsert( + constant.BCNFT_DB, + "t_staking_daily_settlement", + [][]string{ + {"account_address", v.accountAddress}, + {"settle_date", q5.ToString(statDaySeconds)}, + }, + [][]string{ + {"last_contribution", q5.ToString(score)}, + {"last_nft_data", nftData}, + {"modifytime", q5.ToString(nowTime)}, + }, + [][]string{ + {"account_address", v.accountAddress}, + {"settle_date", q5.ToString(statDaySeconds)}, + {"contribution", q5.ToString(score)}, + {"nft_data", nftData}, + {"createtime", q5.ToString(nowTime)}, + {"modifytime", q5.ToString(nowTime)}, + }, + func (err error, lastInsertId int64, rowsAffected int64) { + resultErr = err + }) + return resultErr == nil + }) + return resultErr == nil } diff --git a/third_party/f5 b/third_party/f5 index bc474982..65c7e675 160000 --- a/third_party/f5 +++ b/third_party/f5 @@ -1 +1 @@ -Subproject commit bc4749825937d2673d23ae61f2c33c6a3fe1abfd +Subproject commit 65c7e675815c028e28434950daded77acda44ce5