From 0b8f8f396171b28232bdc356c9c6d9c34317535a Mon Sep 17 00:00:00 2001 From: yangduo Date: Sun, 18 Aug 2024 15:52:01 +0800 Subject: [PATCH 01/10] 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 } From f1bb52822132a49b36b8a165f6b02213bbf48585 Mon Sep 17 00:00:00 2001 From: yangduo Date: Sun, 18 Aug 2024 16:23:33 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/marketserver/service/contribution.go | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/server/marketserver/service/contribution.go b/server/marketserver/service/contribution.go index 10b0a783..29eeacd4 100644 --- a/server/marketserver/service/contribution.go +++ b/server/marketserver/service/contribution.go @@ -2,8 +2,10 @@ package service import ( "f5" + "fmt" "main/constant" "q5" + "time" ) type accountContricution struct { @@ -26,6 +28,7 @@ type contribution struct { func (this *contribution) init() { this.accountContricutionlist = q5.ConcurrentMap[string, *accountContricution]{} + go this.checkContributionList() } func (this *contribution) unInit() { @@ -250,3 +253,24 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) { return this.globalContribution, nil } + +func (this *contribution) checkContributionList() { + fmt.Println("checkContributionList start") + for { + if time.Now().UTC().Hour() == 0 { + nowseconds := f5.GetApp().GetRealSeconds() + deletelist := []string{} + this.accountContricutionlist.Range(func(key string, value *accountContricution) bool { + if value.gcTime+86400 < nowseconds { + deletelist = append(deletelist, key) + } + return true + }) + + for _, account := range deletelist { + this.accountContricutionlist.Delete(account) + } + } + time.Sleep((time.Second * 1800)) + } +} From 335139bf5b94db07d907b4ea94cfae90701f4211 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 18 Aug 2024 16:25:53 +0800 Subject: [PATCH 03/10] 1 --- server/marketserver/middleware/jwtauth.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/marketserver/middleware/jwtauth.go b/server/marketserver/middleware/jwtauth.go index 9d5de398..2ead55e5 100644 --- a/server/marketserver/middleware/jwtauth.go +++ b/server/marketserver/middleware/jwtauth.go @@ -158,13 +158,14 @@ func internalMetaMaskJwtAuth(c *gin.Context, jwtToken string) { c.Abort() return } + /* if jsonRspObj.Decoded.Plat != jccommon.BC_POLY_POLY_METAKASK { rspObj.ErrCode = 501 rspObj.ErrMsg = "not summport platform" c.JSON(200, rspObj) c.Abort() return - } + }*/ openId := fmt.Sprintf("%d_2006_%s", jccommon.BC_CHANNEL, strings.ToLower(jsonRspObj.Decoded.OpenId)) From 4dbba418b3d9d56ff220a597ae4c9b9ad0928abd Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sun, 18 Aug 2024 19:28:20 +0800 Subject: [PATCH 04/10] 1 --- server/marketserver/api/v1/activity/bitget.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/marketserver/api/v1/activity/bitget.go b/server/marketserver/api/v1/activity/bitget.go index c06363c7..b2b24ea4 100644 --- a/server/marketserver/api/v1/activity/bitget.go +++ b/server/marketserver/api/v1/activity/bitget.go @@ -19,5 +19,6 @@ func (this *BitGetApi) NewUserMission(c *gin.Context) { q5.NewSlice(&rspObj.Missions, 0, 10) p := q5.NewSliceElement(&rspObj.Missions) p.MissionId = 1 + p.Target = 5 c.JSON(200, rspObj) } From 5f0b715c39c37041a5f1231ef90eac605aa946ce Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Aug 2024 10:37:09 +0800 Subject: [PATCH 05/10] 1 --- server/marketserver/middleware/jwtauth.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/server/marketserver/middleware/jwtauth.go b/server/marketserver/middleware/jwtauth.go index 2ead55e5..297d99ee 100644 --- a/server/marketserver/middleware/jwtauth.go +++ b/server/marketserver/middleware/jwtauth.go @@ -158,14 +158,13 @@ func internalMetaMaskJwtAuth(c *gin.Context, jwtToken string) { c.Abort() return } - /* if jsonRspObj.Decoded.Plat != jccommon.BC_POLY_POLY_METAKASK { rspObj.ErrCode = 501 - rspObj.ErrMsg = "not summport platform" + rspObj.ErrMsg = "not support this platform" c.JSON(200, rspObj) c.Abort() return - }*/ + } openId := fmt.Sprintf("%d_2006_%s", jccommon.BC_CHANNEL, strings.ToLower(jsonRspObj.Decoded.OpenId)) From 46b8fd2eacfe9d4d6db21b3da8ebe0ba39e5ca78 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Aug 2024 10:38:25 +0800 Subject: [PATCH 06/10] 1 --- server/marketserver/middleware/jwtauth.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/marketserver/middleware/jwtauth.go b/server/marketserver/middleware/jwtauth.go index 297d99ee..1a739f25 100644 --- a/server/marketserver/middleware/jwtauth.go +++ b/server/marketserver/middleware/jwtauth.go @@ -163,6 +163,7 @@ func internalMetaMaskJwtAuth(c *gin.Context, jwtToken string) { rspObj.ErrMsg = "not support this platform" c.JSON(200, rspObj) c.Abort() + f5.GetSysLog().Info("not support this platform:%s", rsp.GetRawData()) return } openId := fmt.Sprintf("%d_2006_%s", From a83b4093631a57c67031b8e770febc41562b554a Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Aug 2024 13:08:08 +0800 Subject: [PATCH 07/10] 1 --- bin/backtask/config/nets.json | 2 +- bin/backtask/config/nets/{42161 => 421614}/contract.json | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename bin/backtask/config/nets/{42161 => 421614}/contract.json (100%) diff --git a/bin/backtask/config/nets.json b/bin/backtask/config/nets.json index a7adca83..b24a077c 100644 --- a/bin/backtask/config/nets.json +++ b/bin/backtask/config/nets.json @@ -1,6 +1,6 @@ [ 97, - 42161, + 421614, 13473, 11155111 ] diff --git a/bin/backtask/config/nets/42161/contract.json b/bin/backtask/config/nets/421614/contract.json similarity index 100% rename from bin/backtask/config/nets/42161/contract.json rename to bin/backtask/config/nets/421614/contract.json From 34f11f9ebd5b1a3299d53d3807463f4628a6f13e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Aug 2024 13:11:18 +0800 Subject: [PATCH 08/10] 1 --- bin/marketserver/config/currencys/{42161 => 421614}/currency.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename bin/marketserver/config/currencys/{42161 => 421614}/currency.json (100%) diff --git a/bin/marketserver/config/currencys/42161/currency.json b/bin/marketserver/config/currencys/421614/currency.json similarity index 100% rename from bin/marketserver/config/currencys/42161/currency.json rename to bin/marketserver/config/currencys/421614/currency.json From 1aed7bee516512f09d7e755594871384e46ab219 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Aug 2024 16:15:51 +0800 Subject: [PATCH 09/10] 1 --- server/marketserver/api/v1/recharge/recharge.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/marketserver/api/v1/recharge/recharge.go b/server/marketserver/api/v1/recharge/recharge.go index 9eaad0e7..af5c8be2 100644 --- a/server/marketserver/api/v1/recharge/recharge.go +++ b/server/marketserver/api/v1/recharge/recharge.go @@ -114,6 +114,8 @@ func (this *RechargeApi) BuyWithEmail(c *gin.Context) { func (this *RechargeApi) internalBuy(c *gin.Context, netId int32, goodsId int32, goodsNum int32, accountAddress string, passportAddress string, email string, currencyAddress string) { + accountAddress = strings.ToLower(accountAddress) + passportAddress = strings.ToLower(passportAddress) currencyMeta := mt.Table.Currency.GetByNetIdAddress(netId, currencyAddress) if currencyMeta == nil { f5.RspErr(c, 2, "server internal error") From b704cdfaa0739160ef0f98d5507d3d1e8a1950b7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 19 Aug 2024 17:50:39 +0800 Subject: [PATCH 10/10] 1 --- server/marketserver/service/recharge.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/marketserver/service/recharge.go b/server/marketserver/service/recharge.go index 0c6d4c2e..65043737 100644 --- a/server/marketserver/service/recharge.go +++ b/server/marketserver/service/recharge.go @@ -3,6 +3,7 @@ package service import ( "q5" "f5" + "strings" "main/constant" ) @@ -31,6 +32,7 @@ func AddRechargeOrder(orderId string, shortOrderId string, } if email != "" { q5.AppendSlice(&fields, []string{"email", email}) + q5.AppendSlice(&fields, []string{"lower_case_email", strings.ToLower(email)}) } f5.GetGoStyleDb().UpsertEx( constant.BCNFT_DB,