1
This commit is contained in:
commit
1b4ff79bdc
@ -2,7 +2,9 @@ package activity
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"fmt"
|
||||
"main/constant"
|
||||
"main/service"
|
||||
"q5"
|
||||
"strings"
|
||||
|
||||
@ -22,54 +24,95 @@ func (cta *ContriApi) HistoryQuery(c *gin.Context) {
|
||||
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 info struct {
|
||||
Type int32 `json:"type"`
|
||||
Time int32 `json:"give_time"`
|
||||
CP string `json:"contribution_point"`
|
||||
}
|
||||
|
||||
rspObj := struct {
|
||||
Errcode int32 `json:"errcode"`
|
||||
Msg int32 `json:"errmsg"`
|
||||
CP string `json:"contributionPoint"`
|
||||
Rows []*info `json:"rows"`
|
||||
}{}
|
||||
item.Type = 0
|
||||
item.Time = int32(f5.GetApp().GetRealSeconds())
|
||||
item.CP = "12345.67"
|
||||
|
||||
mycp, _ := service.Contribution.GetAddressContribution(account)
|
||||
rspObj.CP = fmt.Sprintf("%.2f", mycp)
|
||||
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,
|
||||
}
|
||||
if mycp > 0.000001 {
|
||||
sql := `SELECT * FROM t_staking_daily_settlement WHERE idx > 0 and account_address = ?`
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.GAME_DB,
|
||||
constant.BCNFT_DB,
|
||||
sql,
|
||||
params,
|
||||
[]string{account},
|
||||
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(""))
|
||||
p := new(info)
|
||||
p.Type = 1
|
||||
p.Time = q5.SafeToInt32(ds.GetByName("settle_date"))
|
||||
p.CP = fmt.Sprintf("%.2f", q5.ToFloat64(ds.GetByName("contribution")))
|
||||
q5.AppendSlice(&rspObj.Rows, p)
|
||||
}
|
||||
})
|
||||
|
||||
{
|
||||
loweremail, accountid := service.Contribution.GetEmailAccountId(account)
|
||||
sql := `SELECT * FROM t_contribution_history WHERE idx > 0 AND account_id = ?`
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.GAME_DB,
|
||||
sql,
|
||||
[]string{accountid},
|
||||
func(err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for ds.Next() {
|
||||
p := new(info)
|
||||
p.Type = 2
|
||||
p.Time = q5.SafeToInt32(ds.GetByName("createtime"))
|
||||
p.CP = fmt.Sprintf("%.2f", q5.ToFloat64(ds.GetByName("contribution")))
|
||||
q5.AppendSlice(&rspObj.Rows, p)
|
||||
}
|
||||
})
|
||||
|
||||
sql = `SELECT * FROM t_recharge_return_contribution WHERE idx > 0 AND user_identity IN (?`
|
||||
|
||||
if loweremail != "" {
|
||||
sql += ", " + loweremail
|
||||
}
|
||||
sql += ")"
|
||||
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.BCNFT_DB,
|
||||
sql,
|
||||
[]string{account},
|
||||
func(err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for ds.Next() {
|
||||
p := new(info)
|
||||
p.Type = 3
|
||||
p.Time = q5.SafeToInt32(ds.GetByName("pay_time"))
|
||||
p.CP = fmt.Sprintf("%.2f", q5.ToFloat64(ds.GetByName("return_contribution")))
|
||||
q5.AppendSlice(&rspObj.Rows, p)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
q5.Sort(rspObj.Rows, func(a *info, b *info) bool {
|
||||
return a.Time > b.Time
|
||||
})
|
||||
|
||||
c.JSON(200, rspObj)
|
||||
}
|
||||
|
||||
@ -95,11 +138,12 @@ func (cta *ContriApi) CECQuery(c *gin.Context) {
|
||||
} `json:"info"`
|
||||
}{}
|
||||
|
||||
rspObj.CP = "12345.67"
|
||||
rspObj.Info.MyCP = "12345.67"
|
||||
rspObj.Info.GCP = "12345.67"
|
||||
rspObj.Info.GCEC = 10000
|
||||
rspObj.Info.MyCEC = 10000
|
||||
totalgcp, _ := service.Contribution.GetGlobalContribution(false)
|
||||
mycp, _ := service.Contribution.GetAddressContribution(account)
|
||||
rspObj.Info.MyCP = fmt.Sprintf("%.2f", mycp)
|
||||
rspObj.Info.GCP = fmt.Sprintf("%.2f", totalgcp)
|
||||
rspObj.Info.GCEC = 500000
|
||||
rspObj.Info.MyCEC = q5.SafeToInt64(float64(rspObj.Info.GCEC) * (mycp) / totalgcp)
|
||||
|
||||
c.JSON(200, rspObj)
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ type accountContricution struct {
|
||||
contribution float64
|
||||
gcTime int64
|
||||
loweremail string
|
||||
accountid string
|
||||
}
|
||||
|
||||
type contribution struct {
|
||||
@ -30,19 +31,29 @@ func (this *contribution) unInit() {
|
||||
|
||||
}
|
||||
|
||||
func (this *contribution) GetEmailAccountId(accountAddress string) (string, string) {
|
||||
accinfo, exist := this.accountContricutionlist.Load(accountAddress)
|
||||
if exist {
|
||||
return (*accinfo).loweremail, (*accinfo).accountid
|
||||
}
|
||||
|
||||
return "", ""
|
||||
}
|
||||
|
||||
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)
|
||||
info := new(accountContricution)
|
||||
this.accountContricutionlist.Store(accountAddress, info)
|
||||
accinfo = &info
|
||||
}
|
||||
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,
|
||||
@ -53,16 +64,16 @@ func (this *contribution) GetAddressContribution(accountAddress string) (float64
|
||||
}
|
||||
|
||||
if ds.Next() {
|
||||
accountid = ds.GetByIndex(0)
|
||||
(*accinfo).accountid = ds.GetByIndex(0)
|
||||
}
|
||||
})
|
||||
|
||||
if accountid != "" {
|
||||
if (*accinfo).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},
|
||||
[]string{(*accinfo).accountid},
|
||||
func(err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
return
|
||||
@ -110,12 +121,12 @@ func (this *contribution) GetAddressContribution(accountAddress string) (float64
|
||||
(*accinfo).loadhistory = true
|
||||
}
|
||||
|
||||
{
|
||||
sql := `SELECT SUM(contribution) FROM t_contribution WHERE idx > 0 AND user_identity = ?`
|
||||
if (*accinfo).accountid != "" {
|
||||
sql := `SELECT contribution FROM t_contribution WHERE idx > 0 AND account_id = ?`
|
||||
f5.GetGoStyleDb().RawQuery(
|
||||
constant.GAME_DB,
|
||||
sql,
|
||||
[]string{accountAddress},
|
||||
[]string{(*accinfo).accountid},
|
||||
func(err error, ds *f5.DataSet) {
|
||||
if err != nil {
|
||||
return
|
||||
@ -125,8 +136,10 @@ func (this *contribution) GetAddressContribution(accountAddress string) (float64
|
||||
(*accinfo).contribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
sql = `SELECT SUM(return_contribution) FROM t_recharge_return_contribution WHERE idx > 0 AND user_identity IN (?`
|
||||
{
|
||||
sql := `SELECT SUM(return_contribution) FROM t_recharge_return_contribution WHERE idx > 0 AND user_identity IN (?`
|
||||
if (*accinfo).loweremail != "" {
|
||||
sql += ", " + (*accinfo).loweremail
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user