From 0b8f8f396171b28232bdc356c9c6d9c34317535a Mon Sep 17 00:00:00 2001 From: yangduo Date: Sun, 18 Aug 2024 15:52:01 +0800 Subject: [PATCH] fix --- .../api/v1/activity/contribution.go | 4 ++-- .../marketserver/api/v1/recharge/recharge.go | 6 +++--- server/marketserver/api/v1/user/user.go | 2 +- server/marketserver/service/contribution.go | 20 ++++++++++++------- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/server/marketserver/api/v1/activity/contribution.go b/server/marketserver/api/v1/activity/contribution.go index 2c81fc4c..8c7c7c37 100644 --- a/server/marketserver/api/v1/activity/contribution.go +++ b/server/marketserver/api/v1/activity/contribution.go @@ -37,7 +37,7 @@ func (cta *ContriApi) HistoryQuery(c *gin.Context) { Rows []*info `json:"rows"` }{} - mycp, _ := service.Contribution.GetAddressContribution(account) + mycp, _ := service.Contribution.GetAddressContribution(account, false) rspObj.CP = fmt.Sprintf("%.2f", mycp) q5.NewSlice(&rspObj.Rows, 0, 10) @@ -141,7 +141,7 @@ func (cta *ContriApi) CECQuery(c *gin.Context) { }{} totalgcp, _ := service.Contribution.GetGlobalContribution(false) - mycp, _ := service.Contribution.GetAddressContribution(account) + mycp, _ := service.Contribution.GetAddressContribution(account, false) rspObj.CP = fmt.Sprintf("%.2f", mycp) rspObj.Info.MyCP = rspObj.CP rspObj.Info.GCP = fmt.Sprintf("%.2f", totalgcp) diff --git a/server/marketserver/api/v1/recharge/recharge.go b/server/marketserver/api/v1/recharge/recharge.go index 9eaad0e7..064ba9c5 100644 --- a/server/marketserver/api/v1/recharge/recharge.go +++ b/server/marketserver/api/v1/recharge/recharge.go @@ -35,7 +35,7 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) { return } - if contribution, err := service.Contribution.GetAddressContribution(accountAddress); err != nil { + if contribution, err := service.Contribution.GetAddressContribution(accountAddress, true); err != nil { f5.RspErr(c, 2, "server internal error") return } else { @@ -50,8 +50,8 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) { tmpmap["price"] = tb.GetPrice() tmpmap["max_buy_times"] = tb.GetMaxBuyTimes() tmpmap["can_email_buy"] = tb.GetCanEmailBuy() - currencyList := []struct{ - Name string `json:"name"` + currencyList := []struct { + Name string `json:"name"` Address string `json:"address"` }{} currencysMeta.Range( diff --git a/server/marketserver/api/v1/user/user.go b/server/marketserver/api/v1/user/user.go index 360c30e2..c73085ae 100644 --- a/server/marketserver/api/v1/user/user.go +++ b/server/marketserver/api/v1/user/user.go @@ -26,7 +26,7 @@ func (this *UserApi) Info(c *gin.Context) { Diamond string `json:"diamond"` }{} rspObj.Email = c.MustGet("email").(string) - contributionPoint, _ := service.Contribution.GetAddressContribution(accountAddress) + contributionPoint, _ := service.Contribution.GetAddressContribution(accountAddress, false) var gold float64 var diamond float64 { diff --git a/server/marketserver/service/contribution.go b/server/marketserver/service/contribution.go index 40e41558..10b0a783 100644 --- a/server/marketserver/service/contribution.go +++ b/server/marketserver/service/contribution.go @@ -7,12 +7,13 @@ import ( ) type accountContricution struct { - history float64 - loadhistory bool - contribution float64 - gcTime int64 - loweremail string - accountid string + history float64 + loadhistory bool + contribution float64 + rechargeContri float64 + gcTime int64 + loweremail string + accountid string } type contribution struct { @@ -40,7 +41,7 @@ func (this *contribution) GetEmailAccountId(accountAddress string) (string, stri return "", "" } -func (this *contribution) GetAddressContribution(accountAddress string) (float64, error) { +func (this *contribution) GetAddressContribution(accountAddress string, onlyrecharge bool) (float64, error) { accinfo, exist := this.accountContricutionlist.Load(accountAddress) var beforcontribution float64 = 0 if nowseconds := f5.GetApp().GetRealSeconds(); !exist || (*accinfo).gcTime+60 < nowseconds { @@ -158,6 +159,7 @@ func (this *contribution) GetAddressContribution(accountAddress string) (float64 if ds.Next() { tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0)) (*accinfo).contribution += tmp + (*accinfo).rechargeContri = tmp } }) } @@ -170,6 +172,10 @@ func (this *contribution) GetAddressContribution(accountAddress string) (float64 this.GetGlobalContribution(true) } + if onlyrecharge { + return (*accinfo).rechargeContri, nil + } + return (*accinfo).contribution, nil }