From bcfba92459db3eed1151b2c5414829329d90feea Mon Sep 17 00:00:00 2001 From: yangduo Date: Wed, 25 Sep 2024 15:46:08 +0800 Subject: [PATCH] fix --- server/marketserver/api/v1/vip/vip.go | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/server/marketserver/api/v1/vip/vip.go b/server/marketserver/api/v1/vip/vip.go index 892c4390..57725089 100644 --- a/server/marketserver/api/v1/vip/vip.go +++ b/server/marketserver/api/v1/vip/vip.go @@ -188,35 +188,38 @@ func (this *VIPApi) Details(c *gin.Context) { 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) + escec_balance, ok := new(big.Int).SetString(ds.GetByName("escec_balance"), 10) if !ok { f5.GetSysLog().Warning("escec_balance err:%s", ds.GetByName("escec_balance")) } - escec_stacking, ok := bigintobj.SetString(ds.GetByName("escec_stacking"), 10) + escec_stacking, ok := new(big.Int).SetString(ds.GetByName("escec_stacking"), 10) if !ok { f5.GetSysLog().Warning("escec_stacking err:%s", ds.GetByName("escec_stacking")) } - 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) + escec_convert, ok := new(big.Int).SetString(ds.GetByName("escec_convert"), 10) if !ok { f5.GetSysLog().Warning("escec_convert err:%s", ds.GetByName("escec_convert")) } 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() + elapse := new(big.Int).SetInt64(nowsecs - last_convert_time) + 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()) + rspObj.Info.Cur = cfg.GetThisPoint() * (convercurExec - cfg.GetRequire()) / (nextlvcfg.GetRequire() - cfg.GetRequire()) } } }