diff --git a/server/marketserver/api/v1/activity/stacking.go b/server/marketserver/api/v1/activity/stacking.go index d44e2ca1..237ed630 100644 --- a/server/marketserver/api/v1/activity/stacking.go +++ b/server/marketserver/api/v1/activity/stacking.go @@ -1,7 +1,13 @@ package activity import ( + "q5" + "f5" + "mt" + "jccommon" + "main/constant" "github.com/gin-gonic/gin" + "strings" ) type StackingApi struct { @@ -9,12 +15,50 @@ type StackingApi struct { } func (this *StackingApi) ExpectedDaily(c *gin.Context) { - //accountAddress := strings.ToLower(c.Param("account_address")) + accountAddress := strings.ToLower(c.Param("account_address")) rspObj := struct { ErrCode int32 `json:"errcode"` ErrMsg string `json:"errmsg"` ContributionPoint int64 `json:"contribution_point"` }{ } + { + sqlTpl := "SELECT * FROM t_nft WHERE token_type <> ? AND last_lock_address = ? AND owner_address IN (" + params := []string{ + q5.ToString(jccommon.NFT_TYPE_GOLD_BULLION), + accountAddress, + } + { + lockMetas := []*mt.Contract{} + mt.Table.Contract.Traverse(func (ele *mt.Contract) bool { + if ele.GetName() == jccommon.CONTRACT_NAME_NFTLock { + q5.AppendSlice(&lockMetas, ele) + } + return true + }) + if len(lockMetas)<= 0 { + c.JSON(200, rspObj) + return + } + inited := false + for _, lockMeta := range lockMetas { + if !inited { + inited = true + sqlTpl += "?" + } else { + sqlTpl += ",?" + } + q5.AppendSlice(¶ms, lockMeta.GetAddress()) + } + sqlTpl += ")" + } + f5.GetGoStyleDb().RawQuery( + constant.BCNFT_DB, + "", + params, + func (err error, ds *f5.DataSet) { + + }) + } c.JSON(200, rspObj) } diff --git a/server/marketserver/mt/Contract.go b/server/marketserver/mt/Contract.go index 6996e046..e5d406d1 100644 --- a/server/marketserver/mt/Contract.go +++ b/server/marketserver/mt/Contract.go @@ -107,3 +107,9 @@ func (this *ContractTable) GetByNetIdAddress(netId int32, address string) *Contr return nil } } + +func (this *ContractTable) Traverse(cb func(*Contract) bool) { + this.netIdNameHash.Range(func (k string, v *Contract) bool { + return cb(v) + }) +}