This commit is contained in:
aozhiwei 2024-09-27 14:42:41 +08:00
commit 1d39d36a23
4 changed files with 44 additions and 32 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"main/constant"
"main/service"
"main/mt"
"q5"
"strings"
@ -38,7 +39,7 @@ func (cta *ContriApi) HistoryQuery(c *gin.Context) {
rspObj.CP = fmt.Sprintf("%.2f", mycp)
q5.NewSlice(&rspObj.Rows, 0, 10)
if mycp > 0.000001 {
if mycp > 0.000001 && !mt.Table.Config.HideContributionPoint() {
sql := `SELECT * FROM t_staking_daily_settlement WHERE idx > 0 and account_address = ?`
f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB,

View File

@ -67,15 +67,17 @@ token_type <> ? AND last_lock_address = ? AND last_lock_time <= ? AND owner_addr
return
}
nfts := []*jccommon.NftStacking{}
for ds.Next() {
p := new(jccommon.NftStacking)
p.NetId = q5.ToInt32(ds.GetByName("net_id"))
p.ContractAddress = ds.GetByName("contract_address")
p.TokenType = q5.ToInt32(ds.GetByName("token_type"))
p.TokenId = ds.GetByName("token_id")
p.ItemId = q5.ToInt32(ds.GetByName("item_id"))
p.Quality = q5.ToInt32(ds.GetByName("quality"))
q5.AppendSlice(&nfts, p)
if !mt.Table.Config.HideContributionPoint() {
for ds.Next() {
p := new(jccommon.NftStacking)
p.NetId = q5.ToInt32(ds.GetByName("net_id"))
p.ContractAddress = ds.GetByName("contract_address")
p.TokenType = q5.ToInt32(ds.GetByName("token_type"))
p.TokenId = ds.GetByName("token_id")
p.ItemId = q5.ToInt32(ds.GetByName("item_id"))
p.Quality = q5.ToInt32(ds.GetByName("quality"))
q5.AppendSlice(&nfts, p)
}
}
rspObj.ContributionPoint = fmt.Sprintf("%.2f", (jccommon.CalcContributionScore(nfts)))
c.JSON(200, rspObj)
@ -100,28 +102,30 @@ func (sa *StackingApi) ContributionQuery(c *gin.Context) {
accountAddress,
}
f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB,
sql,
params,
func(err error, ds *f5.DataSet) {
if err != nil {
c.JSON(200, rspObj)
return
}
obj := struct {
Date int32 `json:"date"`
ContributionPoint string `json:"contribution_point"`
}{}
for ds.Next() {
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)
if !mt.Table.Config.HideContributionPoint() {
f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB,
sql,
params,
func(err error, ds *f5.DataSet) {
if err != nil {
c.JSON(200, rspObj)
return
}
}
})
obj := struct {
Date int32 `json:"date"`
ContributionPoint string `json:"contribution_point"`
}{}
for ds.Next() {
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)
}
}
})
}
}
c.JSON(200, rspObj)
}

View File

@ -5,6 +5,7 @@ import (
"fmt"
"main/constant"
"main/service"
"main/mt"
"q5"
"strings"
@ -127,7 +128,9 @@ func (this *UserApi) Info(c *gin.Context) {
return
}
}
rspObj.ContributionPoint = fmt.Sprintf("%.2f", contributionPoint)
if !mt.Table.Config.HideContributionPoint() {
rspObj.ContributionPoint = fmt.Sprintf("%.2f", contributionPoint)
}
rspObj.Gold = fmt.Sprintf("%.2f", gold)
rspObj.Diamond = fmt.Sprintf("%.2f", diamond)
c.JSON(200, rspObj)

View File

@ -22,6 +22,10 @@ func (this *ConfigTable) GetJwksUri() string {
return this.selfConf.GetJwksUri()
}
func (this *ConfigTable) HideContributionPoint() bool {
return true
}
/*
func (this *ConfigTable) GetEmailBuyerPassportAddress() string {
return this.selfConf.GetEmailBuyerPassportAddress()