Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
26ff05bb84 | |||
6cc1f1a507 | |||
![]() |
1d39d36a23 | ||
![]() |
ffe69ce97a | ||
e15df595d6 | |||
5d39a4a29e | |||
373eab8762 | |||
bcfba92459 |
@ -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,
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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())
|
||||
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)
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user