2024-08-17 16:25:51 +08:00

106 lines
2.1 KiB
Go

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)
}