Compare commits

...

8 Commits

Author SHA1 Message Date
26ff05bb84 fix 2024-10-15 17:57:07 +08:00
6cc1f1a507 fix 2024-10-11 10:52:51 +08:00
aozhiwei
1d39d36a23 1 2024-09-27 14:42:41 +08:00
aozhiwei
ffe69ce97a 1 2024-09-27 14:42:03 +08:00
e15df595d6 调整 2024-09-26 15:19:58 +08:00
5d39a4a29e fix 2024-09-26 15:01:28 +08:00
373eab8762 调整 2024-09-26 14:38:17 +08:00
bcfba92459 fix 2024-09-25 15:46:08 +08:00
5 changed files with 92 additions and 55 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,6 +67,7 @@ token_type <> ? AND last_lock_address = ? AND last_lock_time <= ? AND owner_addr
return
}
nfts := []*jccommon.NftStacking{}
if !mt.Table.Config.HideContributionPoint() {
for ds.Next() {
p := new(jccommon.NftStacking)
p.NetId = q5.ToInt32(ds.GetByName("net_id"))
@ -77,6 +78,7 @@ token_type <> ? AND last_lock_address = ? AND last_lock_time <= ? AND owner_addr
p.Quality = q5.ToInt32(ds.GetByName("quality"))
q5.AppendSlice(&nfts, p)
}
}
rspObj.ContributionPoint = fmt.Sprintf("%.2f", (jccommon.CalcContributionScore(nfts)))
c.JSON(200, rspObj)
})
@ -100,6 +102,7 @@ func (sa *StackingApi) ContributionQuery(c *gin.Context) {
accountAddress,
}
if !mt.Table.Config.HideContributionPoint() {
f5.GetGoStyleDb().RawQuery(
constant.BCNFT_DB,
sql,
@ -123,6 +126,7 @@ func (sa *StackingApi) ContributionQuery(c *gin.Context) {
}
})
}
}
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
}
}
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

@ -149,7 +149,7 @@ func (this *VIPApi) Bind(c *gin.Context) {
}
func (this *VIPApi) Details(c *gin.Context) {
accountAddress := c.GetString("account_address")
accountAddress := strings.ToLower(c.GetString("account_address"))
if accountAddress == "" {
f5.RspErr(c, 1, "bad request")
return
@ -167,7 +167,6 @@ func (this *VIPApi) Details(c *gin.Context) {
{
var dbErr error
found := false
sql := "SELECT * FROM t_vip_user WHERE account_address = ?"
params := []string{
accountAddress,
@ -183,42 +182,73 @@ func (this *VIPApi) Details(c *gin.Context) {
}
if ds.Next() {
found = true
rspObj.Info.Level = q5.SafeToInt32(ds.GetByName("vip_lv"))
cfg := mt.Table.StakingVip.GetById(q5.SafeToInt64(rspObj.Info.Level))
if cfg != nil {
rspObj.Info.Target = cfg.GetThisPoint()
bigintobj := new(big.Int)
escec_balance, ok := bigintobj.SetString(ds.GetByName("escec_balance"), 10)
balancestr := ds.GetByName("escec_balance")
if balancestr == "" {
balancestr = "0"
}
escec_balance, ok := new(big.Int).SetString(balancestr, 10)
if !ok {
f5.GetSysLog().Warning("escec_balance err:%s", ds.GetByName("escec_balance"))
f5.GetSysLog().Warning("%s escec_balance err:%s", accountAddress, ds.GetByName("escec_balance"))
escec_balance = new(big.Int).SetInt64(0)
}
escec_stacking, ok := bigintobj.SetString(ds.GetByName("escec_stacking"), 10)
stackingstr := ds.GetByName("escec_stacking")
if stackingstr == "" {
stackingstr = "0"
}
escec_stacking, ok := new(big.Int).SetString(stackingstr, 10)
if !ok {
f5.GetSysLog().Warning("escec_stacking err:%s", ds.GetByName("escec_stacking"))
f5.GetSysLog().Warning("%s escec_stacking err:%s", accountAddress, ds.GetByName("escec_stacking"))
escec_stacking = new(big.Int).SetInt64(0)
}
curExec := bigintobj.Add(escec_balance, escec_stacking)
curExec := new(big.Int).Add(escec_balance, escec_stacking)
escec_convert, ok := bigintobj.SetString(ds.GetByName("escec_convert"), 10)
convertstr := ds.GetByName("escec_convert")
if convertstr == "" {
convertstr = "0"
}
escec_convert, ok := new(big.Int).SetString(convertstr, 10)
if !ok {
f5.GetSysLog().Warning("escec_convert err:%s", ds.GetByName("escec_convert"))
f5.GetSysLog().Warning("%s escec_convert err:%s", accountAddress, ds.GetByName("escec_convert"))
escec_convert = new(big.Int).SetInt64(0)
}
last_convert_time := q5.SafeToInt64(ds.GetByName("last_convert_time"))
nowsecs := f5.GetApp().GetRealSeconds()
elaspse := bigintobj.SetInt64(nowsecs - last_convert_time)
depositExec := bigintobj.Mul(escec_convert, elaspse)
depositExec = bigintobj.Div(depositExec, bigintobj.SetInt64(365*24*3600))
depositExec = bigintobj.Sub(escec_convert, depositExec)
curExec = bigintobj.Add(curExec, depositExec)
convercurExec := bigintobj.Div(curExec, bigintobj.SetInt64(10^18)).Int64()
diff := nowsecs - last_convert_time
if diff < 0 {
diff = 0
f5.GetSysLog().Warning("%s last_convert_time err:%s, now:%d", accountAddress, ds.GetByName("last_convert_time"), nowsecs)
}
elapse := new(big.Int).SetInt64(diff)
depositExec := new(big.Int).Mul(escec_convert, elapse)
depositExec = depositExec.Div(depositExec, new(big.Int).SetInt64(365*24*3600))
if depositExec.Cmp(escec_convert) < 0 {
depositExec = new(big.Int).Sub(escec_convert, depositExec)
} else {
depositExec.SetInt64(0)
}
curExec = curExec.Add(curExec, depositExec)
convercurExec := new(big.Int).Div(curExec, new(big.Int).SetInt64(1000*1000*1000*1000*1000*1000)).Int64()
nextlvcfg := mt.Table.StakingVip.GetById(q5.SafeToInt64(rspObj.Info.Level + 1))
if nextlvcfg != nil && convercurExec >= cfg.GetRequire() {
rspObj.Info.Cur = cfg.GetThisPoint() * (convercurExec - cfg.GetRequire()) / (nextlvcfg.GetRequire() - cfg.GetRequire())
} else if nextlvcfg == nil {
rspObj.Info.Cur = rspObj.Info.Target
}
}
} else {
rspObj.Info.Level = 0
rspObj.Info.Cur = 0
cfg := mt.Table.StakingVip.GetById(q5.SafeToInt64(0))
if cfg != nil {
rspObj.Info.Target = cfg.GetThisPoint()
}
}
})
@ -226,11 +256,6 @@ func (this *VIPApi) Details(c *gin.Context) {
f5.RspErr(c, 500, "server internal error")
return
}
if !found {
f5.RspErr(c, 1, "not vip")
return
}
}
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()