contribution
This commit is contained in:
parent
b943c60cdd
commit
2f43c5e420
105
server/marketserver/api/v1/activity/contribution.go
Normal file
105
server/marketserver/api/v1/activity/contribution.go
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
package activity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"f5"
|
||||||
|
"main/constant"
|
||||||
|
"q5"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ContriApi struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cta *ContriApi) HistoryQuery(c *gin.Context) {
|
||||||
|
account := strings.ToLower(c.Param("account_address"))
|
||||||
|
if account == "" {
|
||||||
|
c.JSON(200, gin.H{
|
||||||
|
"errcode": 1,
|
||||||
|
"errmsg": "",
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
rspObj := struct {
|
||||||
|
Errcode int32 `json:"errcode"`
|
||||||
|
Msg int32 `json:"errmsg"`
|
||||||
|
CP string `json:"contributionPoint"`
|
||||||
|
Rows []interface{} `json:"rows"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
rspObj.CP = "12345.67"
|
||||||
|
item := struct {
|
||||||
|
Type int32 `json:"type"`
|
||||||
|
Time int32 `json:"give_time"`
|
||||||
|
CP string `json:"contribution_point"`
|
||||||
|
}{}
|
||||||
|
item.Type = 0
|
||||||
|
item.Time = int32(f5.GetApp().GetRealSeconds())
|
||||||
|
item.CP = "12345.67"
|
||||||
|
|
||||||
|
q5.NewSlice(&rspObj.Rows, 0, 10)
|
||||||
|
rspObj.Rows = append(rspObj.Rows, item)
|
||||||
|
|
||||||
|
{
|
||||||
|
sql := `
|
||||||
|
SELECT * FROM t_contribution_history WHERE idx > 0 AND account_id = ?
|
||||||
|
`
|
||||||
|
params := []string{
|
||||||
|
account,
|
||||||
|
}
|
||||||
|
f5.GetGoStyleDb().RawQuery(
|
||||||
|
constant.GAME_DB,
|
||||||
|
sql,
|
||||||
|
params,
|
||||||
|
func(err error, ds *f5.DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for ds.Next() {
|
||||||
|
p := struct {
|
||||||
|
Type int32 `json:"type"`
|
||||||
|
Time int32 `json:"give_time"`
|
||||||
|
CP string `json:"contribution_point"`
|
||||||
|
}{}
|
||||||
|
p.Type = q5.ToInt32(ds.GetByName("net_id"))
|
||||||
|
p.Time = q5.ToInt32(ds.GetByName(""))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(200, rspObj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cta *ContriApi) CECQuery(c *gin.Context) {
|
||||||
|
account := strings.ToLower(c.Param("account_address"))
|
||||||
|
if account == "" {
|
||||||
|
c.JSON(200, gin.H{
|
||||||
|
"errcode": 1,
|
||||||
|
"errmsg": "",
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
rspObj := struct {
|
||||||
|
Errcode int32 `json:"errcode"`
|
||||||
|
Msg int32 `json:"errmsg"`
|
||||||
|
CP string `json:"contributionPoint"`
|
||||||
|
Info struct {
|
||||||
|
MyCP string `json:"my_contribution"`
|
||||||
|
GCP string `json:"global_contribution"`
|
||||||
|
GCEC int64 `json:"total_cec_pool"`
|
||||||
|
MyCEC int64 `json:"my_expected_cec"`
|
||||||
|
} `json:"info"`
|
||||||
|
}{}
|
||||||
|
|
||||||
|
rspObj.CP = "12345.67"
|
||||||
|
rspObj.Info.MyCP = "12345.67"
|
||||||
|
rspObj.Info.GCP = "12345.67"
|
||||||
|
rspObj.Info.GCEC = 10000
|
||||||
|
rspObj.Info.MyCEC = 10000
|
||||||
|
|
||||||
|
c.JSON(200, rspObj)
|
||||||
|
}
|
@ -3,4 +3,5 @@ package activity
|
|||||||
type ApiGroup struct {
|
type ApiGroup struct {
|
||||||
StackingApi
|
StackingApi
|
||||||
BitGetApi
|
BitGetApi
|
||||||
|
ContriApi
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"q5"
|
|
||||||
"f5"
|
"f5"
|
||||||
"main/mt"
|
|
||||||
"jccommon"
|
"jccommon"
|
||||||
"main/constant"
|
"main/constant"
|
||||||
|
"main/mt"
|
||||||
|
"q5"
|
||||||
)
|
)
|
||||||
|
|
||||||
type app struct {
|
type app struct {
|
||||||
@ -87,6 +87,16 @@ func (this *app) registerDataSources() {
|
|||||||
mt.Table.GameDb.GetById(0).GetMaxOpenConns(),
|
mt.Table.GameDb.GetById(0).GetMaxOpenConns(),
|
||||||
mt.Table.GameDb.GetById(0).GetMaxIdleConns())
|
mt.Table.GameDb.GetById(0).GetMaxIdleConns())
|
||||||
|
|
||||||
|
f5.GetGoStyleDb().RegisterDataSource(
|
||||||
|
constant.ACCOUNT_DB,
|
||||||
|
mt.Table.AccountDb.GetById(0).GetHost(),
|
||||||
|
mt.Table.AccountDb.GetById(0).GetPort(),
|
||||||
|
mt.Table.AccountDb.GetById(0).GetUser(),
|
||||||
|
mt.Table.AccountDb.GetById(0).GetPasswd(),
|
||||||
|
mt.Table.AccountDb.GetById(0).GetDatabase(),
|
||||||
|
1,
|
||||||
|
mt.Table.AccountDb.GetById(0).GetMaxOpenConns(),
|
||||||
|
mt.Table.AccountDb.GetById(0).GetMaxIdleConns())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *app) HasTask() bool {
|
func (this *app) HasTask() bool {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package constant
|
package constant
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
ACCOUNT_DB = "accountdb"
|
||||||
BCNFT_DB = "bcnftdb"
|
BCNFT_DB = "bcnftdb"
|
||||||
BCEVENT_DB = "bceventdb"
|
BCEVENT_DB = "bceventdb"
|
||||||
GAME_DB = "gamedb"
|
GAME_DB = "gamedb"
|
||||||
|
15
server/marketserver/mt/AccountDb.go
Normal file
15
server/marketserver/mt/AccountDb.go
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package mt
|
||||||
|
|
||||||
|
import (
|
||||||
|
"f5"
|
||||||
|
"main/mtb"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AccountDb struct {
|
||||||
|
mtb.AccountDb
|
||||||
|
}
|
||||||
|
|
||||||
|
type AccountDbTable struct {
|
||||||
|
f5.IdMetaTable[AccountDb]
|
||||||
|
selfConf *AccountDb
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
package mt
|
package mt
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"q5"
|
|
||||||
"f5"
|
"f5"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"main/constant"
|
"main/constant"
|
||||||
|
"q5"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Currency struct {
|
type Currency struct {
|
||||||
@ -77,7 +77,7 @@ func (this *CurrencyTable) GetByNetIdAddress(netId int32, currencyAddress string
|
|||||||
var result *Currency
|
var result *Currency
|
||||||
currencyAddress = strings.ToLower(currencyAddress)
|
currencyAddress = strings.ToLower(currencyAddress)
|
||||||
currencysMeta.Range(
|
currencysMeta.Range(
|
||||||
func (key string, meta *Currency) bool {
|
func(key string, meta *Currency) bool {
|
||||||
if meta.GetContract().GetAddress() == currencyAddress {
|
if meta.GetContract().GetAddress() == currencyAddress {
|
||||||
result = meta
|
result = meta
|
||||||
return false
|
return false
|
||||||
@ -118,7 +118,7 @@ func (this *CurrencyTable) Load() {
|
|||||||
p.check()
|
p.check()
|
||||||
currencysMeta := this.GetByNetId(netId)
|
currencysMeta := this.GetByNetId(netId)
|
||||||
if currencysMeta == nil {
|
if currencysMeta == nil {
|
||||||
currencysMeta := new(q5.ConcurrentMap[string, *Currency])
|
currencysMeta = new(q5.ConcurrentMap[string, *Currency])
|
||||||
this.netIdHash.Store(netId, currencysMeta)
|
this.netIdHash.Store(netId, currencysMeta)
|
||||||
}
|
}
|
||||||
currencysMeta.Store(p.GetCurrencyName(), p)
|
currencysMeta.Store(p.GetCurrencyName(), p)
|
||||||
@ -129,13 +129,13 @@ func (this *CurrencyTable) Load() {
|
|||||||
|
|
||||||
func (this *CurrencyTable) PostInit1() {
|
func (this *CurrencyTable) PostInit1() {
|
||||||
this.netIdHash.Range(
|
this.netIdHash.Range(
|
||||||
func (key int32, val *q5.ConcurrentMap[string, *Currency]) bool {
|
func(key int32, val *q5.ConcurrentMap[string, *Currency]) bool {
|
||||||
netId := key
|
netId := key
|
||||||
val.Range(
|
val.Range(
|
||||||
func (key2 string, val2 *Currency) bool {
|
func(key2 string, val2 *Currency) bool {
|
||||||
currencyMeta := val2
|
currencyMeta := val2
|
||||||
Table.Recharge.Traverse(func(ele *Recharge) bool {
|
Table.Recharge.Traverse(func(ele *Recharge) bool {
|
||||||
if int64(ele.GetPrice()) * currencyMeta.GetExchangeRate() != int64(ele.GetDiamond()) {
|
if int64(ele.GetPrice())*currencyMeta.GetExchangeRate() != int64(ele.GetDiamond()) {
|
||||||
panic(fmt.Sprintf("Currency verifyerror net_id:%d id:%d", netId, ele.GetId()))
|
panic(fmt.Sprintf("Currency verifyerror net_id:%d id:%d", netId, ele.GetId()))
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
@ -146,7 +146,7 @@ func (this *CurrencyTable) PostInit1() {
|
|||||||
}
|
}
|
||||||
currencyMeta.contract = contractMeta
|
currencyMeta.contract = contractMeta
|
||||||
return true
|
return true
|
||||||
});
|
})
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@ type table struct {
|
|||||||
Web3SignCluster *Web3SignClusterTable
|
Web3SignCluster *Web3SignClusterTable
|
||||||
Recharge *RechargeTable
|
Recharge *RechargeTable
|
||||||
Currency *CurrencyTable
|
Currency *CurrencyTable
|
||||||
|
AccountDb *AccountDbTable
|
||||||
}
|
}
|
||||||
|
|
||||||
var Table = f5.New(func(this *table) {
|
var Table = f5.New(func(this *table) {
|
||||||
@ -40,6 +41,11 @@ var Table = f5.New(func(this *table) {
|
|||||||
this.PrimKey = ""
|
this.PrimKey = ""
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.AccountDb = f5.New(func(this *AccountDbTable) {
|
||||||
|
this.FileName = "../config/accountdb.mysql.json"
|
||||||
|
this.PrimKey = ""
|
||||||
|
})
|
||||||
|
|
||||||
this.Config = f5.New(func(this *ConfigTable) {
|
this.Config = f5.New(func(this *ConfigTable) {
|
||||||
this.FileName = "../config/config.json"
|
this.FileName = "../config/config.json"
|
||||||
this.PrimKey = ""
|
this.PrimKey = ""
|
||||||
|
@ -13,6 +13,19 @@ type MarketServerCluster struct {
|
|||||||
_flags2_ uint64
|
_flags2_ uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AccountDb struct {
|
||||||
|
host string
|
||||||
|
port int32
|
||||||
|
user string
|
||||||
|
passwd string
|
||||||
|
database string
|
||||||
|
max_open_conns int32
|
||||||
|
max_idle_conns int32
|
||||||
|
|
||||||
|
_flags1_ uint64
|
||||||
|
_flags2_ uint64
|
||||||
|
}
|
||||||
|
|
||||||
type NftDb struct {
|
type NftDb struct {
|
||||||
host string
|
host string
|
||||||
port int32
|
port int32
|
||||||
@ -137,6 +150,62 @@ func (this *MarketServerCluster) HasHttpListenPort() bool {
|
|||||||
return (this._flags1_ & (uint64(1) << 3)) > 0
|
return (this._flags1_ & (uint64(1) << 3)) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) GetHost() string {
|
||||||
|
return this.host
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) HasHost() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 1)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) GetPort() int32 {
|
||||||
|
return this.port
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) HasPort() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 2)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) GetUser() string {
|
||||||
|
return this.user
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) HasUser() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 3)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) GetPasswd() string {
|
||||||
|
return this.passwd
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) HasPasswd() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 4)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) GetDatabase() string {
|
||||||
|
return this.database
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) HasDatabase() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 5)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) GetMaxOpenConns() int32 {
|
||||||
|
return this.max_open_conns
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) HasMaxOpenConns() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 6)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) GetMaxIdleConns() int32 {
|
||||||
|
return this.max_idle_conns
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) HasMaxIdleConns() bool {
|
||||||
|
return (this._flags1_ & (uint64(1) << 7)) > 0
|
||||||
|
}
|
||||||
|
|
||||||
func (this *NftDb) GetHost() string {
|
func (this *NftDb) GetHost() string {
|
||||||
return this.host
|
return this.host
|
||||||
}
|
}
|
||||||
@ -464,6 +533,16 @@ func (this *MarketServerCluster) LoadFromKv(kv map[string]interface{}) {
|
|||||||
f5.ReadMetaTableField(&this.http_listen_port, "http_listen_port", &this._flags1_, 3, kv)
|
f5.ReadMetaTableField(&this.http_listen_port, "http_listen_port", &this._flags1_, 3, kv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *AccountDb) LoadFromKv(kv map[string]interface{}) {
|
||||||
|
f5.ReadMetaTableField(&this.host, "host", &this._flags1_, 1, kv)
|
||||||
|
f5.ReadMetaTableField(&this.port, "port", &this._flags1_, 2, kv)
|
||||||
|
f5.ReadMetaTableField(&this.user, "user", &this._flags1_, 3, kv)
|
||||||
|
f5.ReadMetaTableField(&this.passwd, "passwd", &this._flags1_, 4, kv)
|
||||||
|
f5.ReadMetaTableField(&this.database, "database", &this._flags1_, 5, kv)
|
||||||
|
f5.ReadMetaTableField(&this.max_open_conns, "max_open_conns", &this._flags1_, 6, kv)
|
||||||
|
f5.ReadMetaTableField(&this.max_idle_conns, "max_idle_conns", &this._flags1_, 7, kv)
|
||||||
|
}
|
||||||
|
|
||||||
func (this *NftDb) LoadFromKv(kv map[string]interface{}) {
|
func (this *NftDb) LoadFromKv(kv map[string]interface{}) {
|
||||||
f5.ReadMetaTableField(&this.host, "host", &this._flags1_, 1, kv)
|
f5.ReadMetaTableField(&this.host, "host", &this._flags1_, 1, kv)
|
||||||
f5.ReadMetaTableField(&this.port, "port", &this._flags1_, 2, kv)
|
f5.ReadMetaTableField(&this.port, "port", &this._flags1_, 2, kv)
|
||||||
|
@ -9,6 +9,17 @@ message MarketServerCluster
|
|||||||
optional int32 http_listen_port = 3;
|
optional int32 http_listen_port = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message AccountDb
|
||||||
|
{
|
||||||
|
optional string host = 1;
|
||||||
|
optional int32 port = 2;
|
||||||
|
optional string user = 3;
|
||||||
|
optional string passwd = 4;
|
||||||
|
optional string database = 5;
|
||||||
|
optional int32 max_open_conns = 6;
|
||||||
|
optional int32 max_idle_conns = 7;
|
||||||
|
}
|
||||||
|
|
||||||
message NftDb
|
message NftDb
|
||||||
{
|
{
|
||||||
optional string host = 1;
|
optional string host = 1;
|
||||||
|
16
server/marketserver/router/activity/contribution.go
Normal file
16
server/marketserver/router/activity/contribution.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package activity
|
||||||
|
|
||||||
|
import (
|
||||||
|
"f5"
|
||||||
|
v1 "main/api/v1"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ContributionRouter struct{}
|
||||||
|
|
||||||
|
func (this *ContributionRouter) InitRouter() {
|
||||||
|
api := v1.ApiGroupApp.ActivityApiGroup
|
||||||
|
f5.GetApp().GetGinEngine().GET("api/activity/contribution/history/:account_address",
|
||||||
|
api.ContriApi.HistoryQuery)
|
||||||
|
f5.GetApp().GetGinEngine().GET("/api/activity/cec/contribution/:account_address",
|
||||||
|
api.ContriApi.CECQuery)
|
||||||
|
}
|
@ -3,4 +3,5 @@ package activity
|
|||||||
type RouterGroup struct {
|
type RouterGroup struct {
|
||||||
StackingRouter
|
StackingRouter
|
||||||
BitGetRouter
|
BitGetRouter
|
||||||
|
ContributionRouter
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ func (this *routerMgr) Init() {
|
|||||||
this.user.UserRouter.InitRouter()
|
this.user.UserRouter.InitRouter()
|
||||||
this.activity.StackingRouter.InitRouter()
|
this.activity.StackingRouter.InitRouter()
|
||||||
this.activity.BitGetRouter.InitRouter()
|
this.activity.BitGetRouter.InitRouter()
|
||||||
|
this.activity.ContributionRouter.InitRouter()
|
||||||
this.event.EventRouter.InitRouter()
|
this.event.EventRouter.InitRouter()
|
||||||
this.recharge.RechargeRouter.InitRouter()
|
this.recharge.RechargeRouter.InitRouter()
|
||||||
|
|
||||||
|
@ -1,21 +1,231 @@
|
|||||||
package service
|
package service
|
||||||
|
|
||||||
type contribution struct {
|
import (
|
||||||
|
"f5"
|
||||||
|
"main/constant"
|
||||||
|
"q5"
|
||||||
|
)
|
||||||
|
|
||||||
|
type accountContricution struct {
|
||||||
|
history float64
|
||||||
|
loadhistory bool
|
||||||
|
contribution float64
|
||||||
|
gcTime int64
|
||||||
|
loweremail string
|
||||||
|
}
|
||||||
|
|
||||||
|
type contribution struct {
|
||||||
|
historyContribution float64
|
||||||
|
globalContribution float64
|
||||||
|
gcTime int64
|
||||||
|
|
||||||
|
accountContricutionlist q5.ConcurrentMap[string, *accountContricution]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *contribution) init() {
|
func (this *contribution) init() {
|
||||||
|
this.accountContricutionlist = q5.ConcurrentMap[string, *accountContricution]{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *contribution) unInit() {
|
func (this *contribution) unInit() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *contribution) GetAddressContribution(accountAddress string) (float64, error){
|
func (this *contribution) GetAddressContribution(accountAddress string) (float64, error) {
|
||||||
return 0, nil
|
accinfo, exist := this.accountContricutionlist.Load(accountAddress)
|
||||||
|
var beforcontribution float64 = 0
|
||||||
|
if nowseconds := f5.GetApp().GetRealSeconds(); !exist || (*accinfo).gcTime+60 < nowseconds {
|
||||||
|
if !exist {
|
||||||
|
*accinfo = new(accountContricution)
|
||||||
|
}
|
||||||
|
beforcontribution = (*accinfo).contribution
|
||||||
|
|
||||||
|
if (*accinfo).loweremail == "" {
|
||||||
|
sql := `SELECT account_id FROM t_user WHERE idx > 0 AND address = ?`
|
||||||
|
accountid := ""
|
||||||
|
f5.GetGoStyleDb().RawQuery(
|
||||||
|
constant.GAME_DB,
|
||||||
|
sql,
|
||||||
|
[]string{accountAddress},
|
||||||
|
func(err error, ds *f5.DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ds.Next() {
|
||||||
|
accountid = ds.GetByIndex(0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if accountid != "" {
|
||||||
|
sql := `SELECT lower_case_email FROM t_immutable_account WHERE idx > 0 AND account_id = ?`
|
||||||
|
f5.GetGoStyleDb().RawQuery(
|
||||||
|
constant.ACCOUNT_DB,
|
||||||
|
sql,
|
||||||
|
[]string{accountid},
|
||||||
|
func(err error, ds *f5.DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ds.Next() {
|
||||||
|
(*accinfo).loweremail = ds.GetByIndex(0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if !(*accinfo).loadhistory {
|
||||||
|
sql := `SELECT contribution FROM t_contribution WHERE idx > 0 and account_address = ?`
|
||||||
|
f5.GetGoStyleDb().RawQuery(
|
||||||
|
constant.BCNFT_DB,
|
||||||
|
sql,
|
||||||
|
[]string{accountAddress},
|
||||||
|
func(err error, ds *f5.DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ds.Next() {
|
||||||
|
(*accinfo).history, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
sql = `SELECT SUM(contribution) FROM t_staking_daily_settlement WHERE idx > 0 and account_address = ?`
|
||||||
|
f5.GetGoStyleDb().RawQuery(
|
||||||
|
constant.BCNFT_DB,
|
||||||
|
sql,
|
||||||
|
[]string{accountAddress},
|
||||||
|
func(err error, ds *f5.DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ds.Next() {
|
||||||
|
tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0))
|
||||||
|
(*accinfo).history += tmp
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
(*accinfo).loadhistory = true
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
sql := `SELECT SUM(contribution) FROM t_contribution WHERE idx > 0 AND user_identity = ?`
|
||||||
|
f5.GetGoStyleDb().RawQuery(
|
||||||
|
constant.GAME_DB,
|
||||||
|
sql,
|
||||||
|
[]string{accountAddress},
|
||||||
|
func(err error, ds *f5.DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ds.Next() {
|
||||||
|
(*accinfo).contribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
sql = `SELECT SUM(return_contribution) FROM t_recharge_return_contribution WHERE idx > 0 AND user_identity IN (?`
|
||||||
|
if (*accinfo).loweremail != "" {
|
||||||
|
sql += ", " + (*accinfo).loweremail
|
||||||
|
}
|
||||||
|
sql += ")"
|
||||||
|
|
||||||
|
f5.GetGoStyleDb().RawQuery(
|
||||||
|
constant.BCNFT_DB,
|
||||||
|
sql,
|
||||||
|
[]string{accountAddress},
|
||||||
|
func(err error, ds *f5.DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ds.Next() {
|
||||||
|
tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0))
|
||||||
|
(*accinfo).contribution += tmp
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
(*accinfo).contribution += (*accinfo).history
|
||||||
|
(*accinfo).gcTime = nowseconds
|
||||||
|
}
|
||||||
|
|
||||||
|
if beforcontribution != (*accinfo).contribution {
|
||||||
|
this.GetGlobalContribution(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (*accinfo).contribution, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *contribution) GetGlobalContribution() (float64, error){
|
func (this *contribution) GetGlobalContribution(instant bool) (float64, error) {
|
||||||
return 0, nil
|
if this.historyContribution < 0.000001 {
|
||||||
|
sql := `SELECT SUM(contribution) FROM t_contribution WHERE idx > 0`
|
||||||
|
f5.GetGoStyleDb().RawQuery(
|
||||||
|
constant.BCNFT_DB,
|
||||||
|
sql,
|
||||||
|
[]string{},
|
||||||
|
func(err error, ds *f5.DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ds.Next() {
|
||||||
|
this.historyContribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
sql = `SELECT SUM(contribution) FROM t_staking_daily_settlement WHERE idx > 0`
|
||||||
|
f5.GetGoStyleDb().RawQuery(
|
||||||
|
constant.BCNFT_DB,
|
||||||
|
sql,
|
||||||
|
[]string{},
|
||||||
|
func(err error, ds *f5.DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ds.Next() {
|
||||||
|
tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0))
|
||||||
|
this.historyContribution += tmp
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
if nowseconds := f5.GetApp().GetRealSeconds(); nowseconds > this.gcTime+60 || instant {
|
||||||
|
sql := `SELECT SUM(contribution) FROM t_contribution WHERE idx > 0`
|
||||||
|
f5.GetGoStyleDb().RawQuery(
|
||||||
|
constant.GAME_DB,
|
||||||
|
sql,
|
||||||
|
[]string{},
|
||||||
|
func(err error, ds *f5.DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ds.Next() {
|
||||||
|
this.globalContribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
sql = `SELECT SUM(return_contribution) FROM t_recharge_return_contribution WHERE idx > 0`
|
||||||
|
f5.GetGoStyleDb().RawQuery(
|
||||||
|
constant.BCNFT_DB,
|
||||||
|
sql,
|
||||||
|
[]string{},
|
||||||
|
func(err error, ds *f5.DataSet) {
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if ds.Next() {
|
||||||
|
tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0))
|
||||||
|
this.globalContribution += tmp
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
this.globalContribution += this.historyContribution
|
||||||
|
this.gcTime = nowseconds
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.globalContribution, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user