vip details
This commit is contained in:
parent
4c62ce1368
commit
6e6be7492e
1
bin/marketserver/res/stakingVip@stakingVip.json
Symbolic link
1
bin/marketserver/res/stakingVip@stakingVip.json
Symbolic link
@ -0,0 +1 @@
|
||||
../../light_backtask/res/stakingVip@stakingVip.json
|
@ -3,7 +3,9 @@ package vip
|
||||
import (
|
||||
"f5"
|
||||
"main/constant"
|
||||
"main/mt"
|
||||
"main/service"
|
||||
"math/big"
|
||||
"q5"
|
||||
"strings"
|
||||
|
||||
@ -145,3 +147,91 @@ func (this *VIPApi) Bind(c *gin.Context) {
|
||||
|
||||
f5.RspErr(c, 0, "")
|
||||
}
|
||||
|
||||
func (this *VIPApi) Details(c *gin.Context) {
|
||||
accountAddress := c.GetString("account_address")
|
||||
if accountAddress == "" {
|
||||
f5.RspErr(c, 1, "bad request")
|
||||
return
|
||||
}
|
||||
|
||||
rspObj := struct {
|
||||
ErrCode int32 `json:"errcode"`
|
||||
ErrMsg string `json:"errmsg"`
|
||||
Info struct {
|
||||
Level int32 `json:"level"`
|
||||
Cur int64 `json:"curpoint"`
|
||||
Target int64 `json:"target"`
|
||||
} `json:"info"`
|
||||
}{}
|
||||
|
||||
{
|
||||
var dbErr error
|
||||
found := false
|
||||
sql := "SELECT * FROM t_vip_user WHERE account_address = ?"
|
||||
params := []string{
|
||||
accountAddress,
|
||||
}
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.BCNFT_DB,
|
||||
sql,
|
||||
params,
|
||||
func(err error, ds *f5.DataSet) {
|
||||
dbErr = err
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
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)
|
||||
if !ok {
|
||||
f5.GetSysLog().Warning("escec_balance err:%s", ds.GetByName("escec_balance"))
|
||||
}
|
||||
|
||||
escec_stacking, ok := bigintobj.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)
|
||||
|
||||
escec_convert, ok := bigintobj.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()
|
||||
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())
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if dbErr != nil {
|
||||
f5.RspErr(c, 500, "server internal error")
|
||||
return
|
||||
}
|
||||
|
||||
if !found {
|
||||
f5.RspErr(c, 1, "not vip")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(200, rspObj)
|
||||
}
|
||||
|
14
server/marketserver/mt/StakingVip.go
Normal file
14
server/marketserver/mt/StakingVip.go
Normal file
@ -0,0 +1,14 @@
|
||||
package mt
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"main/mtb"
|
||||
)
|
||||
|
||||
type StakingVip struct {
|
||||
mtb.StakingVip
|
||||
}
|
||||
|
||||
type StakingVipTable struct {
|
||||
f5.IdMetaTable[StakingVip]
|
||||
}
|
@ -19,6 +19,7 @@ type table struct {
|
||||
Currency *CurrencyTable
|
||||
AccountDb *AccountDbTable
|
||||
ConfDb *ConfDbTable
|
||||
StakingVip *StakingVipTable
|
||||
}
|
||||
|
||||
var Table = f5.New(func(this *table) {
|
||||
@ -85,4 +86,9 @@ var Table = f5.New(func(this *table) {
|
||||
this.FileName = "../res/recharge@recharge.json"
|
||||
this.PrimKey = "id"
|
||||
})
|
||||
|
||||
this.StakingVip = f5.New(func(this *StakingVipTable) {
|
||||
this.FileName = "../res/stakingVip@stakingVip.json"
|
||||
this.PrimKey = "rank"
|
||||
})
|
||||
})
|
||||
|
@ -139,6 +139,21 @@ type Web3SignCluster struct {
|
||||
_flags2_ uint64
|
||||
}
|
||||
|
||||
type StakingVip struct {
|
||||
rights string
|
||||
require int64
|
||||
thisPoint int64
|
||||
rank int32
|
||||
vip_name string
|
||||
rate float64
|
||||
vip_working_tips string
|
||||
vip_unworking_tips string
|
||||
id int32
|
||||
|
||||
_flags1_ uint64
|
||||
_flags2_ uint64
|
||||
}
|
||||
|
||||
func (this *MarketServerCluster) GetInstanceId() int32 {
|
||||
return this.instance_id
|
||||
}
|
||||
@ -595,6 +610,78 @@ func (this *Web3SignCluster) HasUrl() bool {
|
||||
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||
}
|
||||
|
||||
func (this *StakingVip) GetRights() string {
|
||||
return this.rights
|
||||
}
|
||||
|
||||
func (this *StakingVip) HasRights() bool {
|
||||
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||
}
|
||||
|
||||
func (this *StakingVip) GetRequire() int64 {
|
||||
return this.require
|
||||
}
|
||||
|
||||
func (this *StakingVip) HasRequire() bool {
|
||||
return (this._flags1_ & (uint64(1) << 2)) > 0
|
||||
}
|
||||
|
||||
func (this *StakingVip) GetThisPoint() int64 {
|
||||
return this.thisPoint
|
||||
}
|
||||
|
||||
func (this *StakingVip) HasThisPoint() bool {
|
||||
return (this._flags1_ & (uint64(1) << 3)) > 0
|
||||
}
|
||||
|
||||
func (this *StakingVip) GetRank() int32 {
|
||||
return this.rank
|
||||
}
|
||||
|
||||
func (this *StakingVip) HasRank() bool {
|
||||
return (this._flags1_ & (uint64(1) << 4)) > 0
|
||||
}
|
||||
|
||||
func (this *StakingVip) GetVipName() string {
|
||||
return this.vip_name
|
||||
}
|
||||
|
||||
func (this *StakingVip) HasVipName() bool {
|
||||
return (this._flags1_ & (uint64(1) << 5)) > 0
|
||||
}
|
||||
|
||||
func (this *StakingVip) GetRate() float64 {
|
||||
return this.rate
|
||||
}
|
||||
|
||||
func (this *StakingVip) HasRate() bool {
|
||||
return (this._flags1_ & (uint64(1) << 6)) > 0
|
||||
}
|
||||
|
||||
func (this *StakingVip) GetVipWorkingTips() string {
|
||||
return this.vip_working_tips
|
||||
}
|
||||
|
||||
func (this *StakingVip) HasVipWorkingTips() bool {
|
||||
return (this._flags1_ & (uint64(1) << 7)) > 0
|
||||
}
|
||||
|
||||
func (this *StakingVip) GetVipUnworkingTips() string {
|
||||
return this.vip_unworking_tips
|
||||
}
|
||||
|
||||
func (this *StakingVip) HasVipUnworkingTips() bool {
|
||||
return (this._flags1_ & (uint64(1) << 8)) > 0
|
||||
}
|
||||
|
||||
func (this *StakingVip) GetId() int32 {
|
||||
return this.id
|
||||
}
|
||||
|
||||
func (this *StakingVip) HasId() bool {
|
||||
return (this._flags1_ & (uint64(1) << 9)) > 0
|
||||
}
|
||||
|
||||
|
||||
func (this *MarketServerCluster) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.instance_id, "instance_id", &this._flags1_, 1, kv)
|
||||
@ -691,3 +778,15 @@ func (this *Web3ServiceCluster) LoadFromKv(kv map[string]interface{}) {
|
||||
func (this *Web3SignCluster) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.url, "url", &this._flags1_, 1, kv)
|
||||
}
|
||||
|
||||
func (this *StakingVip) LoadFromKv(kv map[string]interface{}) {
|
||||
f5.ReadMetaTableField(&this.rights, "rights", &this._flags1_, 1, kv)
|
||||
f5.ReadMetaTableField(&this.require, "require", &this._flags1_, 2, kv)
|
||||
f5.ReadMetaTableField(&this.thisPoint, "thisPoint", &this._flags1_, 3, kv)
|
||||
f5.ReadMetaTableField(&this.rank, "rank", &this._flags1_, 4, kv)
|
||||
f5.ReadMetaTableField(&this.vip_name, "vip_name", &this._flags1_, 5, kv)
|
||||
f5.ReadMetaTableField(&this.rate, "rate", &this._flags1_, 6, kv)
|
||||
f5.ReadMetaTableField(&this.vip_working_tips, "vip_working_tips", &this._flags1_, 7, kv)
|
||||
f5.ReadMetaTableField(&this.vip_unworking_tips, "vip_unworking_tips", &this._flags1_, 8, kv)
|
||||
f5.ReadMetaTableField(&this.id, "id", &this._flags1_, 9, kv)
|
||||
}
|
||||
|
@ -110,3 +110,16 @@ message Web3SignCluster
|
||||
{
|
||||
optional string url = 1;
|
||||
}
|
||||
|
||||
message StakingVip
|
||||
{
|
||||
optional string rights = 1;
|
||||
optional int64 require = 2;
|
||||
optional int64 thisPoint = 3;
|
||||
optional int32 rank = 4;
|
||||
optional string vip_name = 5;
|
||||
optional double rate = 6;
|
||||
optional string vip_working_tips = 7;
|
||||
optional string vip_unworking_tips = 8;
|
||||
optional int32 id = 9;
|
||||
}
|
@ -16,4 +16,7 @@ func (this *VIPRouter) InitRouter() {
|
||||
f5.GetApp().GetGinEngine().POST("/api/vip/bind",
|
||||
middleware.JwtAuth,
|
||||
api.VIPApi.Bind)
|
||||
f5.GetApp().GetGinEngine().GET("/api/vip/details",
|
||||
middleware.JwtAuth,
|
||||
api.VIPApi.Details)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user