调整
This commit is contained in:
parent
eff2547175
commit
8ae5aec135
@ -2,10 +2,10 @@ package activity
|
||||
|
||||
import (
|
||||
"f5"
|
||||
"fmt"
|
||||
"main/constant"
|
||||
"main/service"
|
||||
"q5"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
@ -31,14 +31,14 @@ func (cta *ContriApi) HistoryQuery(c *gin.Context) {
|
||||
}
|
||||
|
||||
rspObj := struct {
|
||||
Errcode int32 `json:"errcode"`
|
||||
Msg int32 `json:"errmsg"`
|
||||
CP string `json:"contributionPoint"`
|
||||
Rows []info `json:"rows"`
|
||||
Errcode int32 `json:"errcode"`
|
||||
Msg int32 `json:"errmsg"`
|
||||
CP string `json:"contributionPoint"`
|
||||
Rows []*info `json:"rows"`
|
||||
}{}
|
||||
|
||||
mycp, _ := service.Contribution.GetAddressContribution(account)
|
||||
rspObj.CP = q5.SafeToString(mycp)
|
||||
rspObj.CP = fmt.Sprintf("%.2f", mycp)
|
||||
q5.NewSlice(&rspObj.Rows, 0, 10)
|
||||
|
||||
if mycp > 0.000001 {
|
||||
@ -53,10 +53,11 @@ func (cta *ContriApi) HistoryQuery(c *gin.Context) {
|
||||
}
|
||||
|
||||
for ds.Next() {
|
||||
p := q5.NewSliceElement(&rspObj.Rows)
|
||||
p := new(info)
|
||||
p.Type = 1
|
||||
p.Time = q5.SafeToInt32(ds.GetByName("settle_date"))
|
||||
p.CP = ds.GetByName("contribution")
|
||||
p.CP = fmt.Sprintf("%.2f", q5.ToFloat64(ds.GetByName("contribution")))
|
||||
q5.AppendSlice(&rspObj.Rows, p)
|
||||
}
|
||||
})
|
||||
|
||||
@ -73,10 +74,11 @@ func (cta *ContriApi) HistoryQuery(c *gin.Context) {
|
||||
}
|
||||
|
||||
for ds.Next() {
|
||||
p := q5.NewSliceElement(&rspObj.Rows)
|
||||
p := new(info)
|
||||
p.Type = 2
|
||||
p.Time = q5.SafeToInt32(ds.GetByName("createtime"))
|
||||
p.CP = ds.GetByName("contribution")
|
||||
p.CP = fmt.Sprintf("%.2f", q5.ToFloat64(ds.GetByName("contribution")))
|
||||
q5.AppendSlice(&rspObj.Rows, p)
|
||||
}
|
||||
})
|
||||
|
||||
@ -97,17 +99,18 @@ func (cta *ContriApi) HistoryQuery(c *gin.Context) {
|
||||
}
|
||||
|
||||
for ds.Next() {
|
||||
p := q5.NewSliceElement(&rspObj.Rows)
|
||||
p := new(info)
|
||||
p.Type = 3
|
||||
p.Time = q5.SafeToInt32(ds.GetByName("pay_time"))
|
||||
p.CP = ds.GetByName("return_contribution")
|
||||
p.CP = fmt.Sprintf("%.2f", q5.ToFloat64(ds.GetByName("return_contribution")))
|
||||
q5.AppendSlice(&rspObj.Rows, p)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(rspObj.Rows, func(a int, b int) bool {
|
||||
return rspObj.Rows[a].Time > rspObj.Rows[b].Time
|
||||
q5.Sort(rspObj.Rows, func(a *info, b *info) bool {
|
||||
return a.Time > b.Time
|
||||
})
|
||||
|
||||
c.JSON(200, rspObj)
|
||||
@ -137,8 +140,8 @@ func (cta *ContriApi) CECQuery(c *gin.Context) {
|
||||
|
||||
totalgcp, _ := service.Contribution.GetGlobalContribution(false)
|
||||
mycp, _ := service.Contribution.GetAddressContribution(account)
|
||||
rspObj.Info.MyCP = q5.ToString(mycp)
|
||||
rspObj.Info.GCP = q5.ToString(totalgcp)
|
||||
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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user