From 27219fdf34dcee51be6ca39a36d35a71e48fe9b2 Mon Sep 17 00:00:00 2001 From: yangduo Date: Tue, 20 Aug 2024 16:18:19 +0800 Subject: [PATCH 01/28] fix --- server/marketserver/service/contribution.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/server/marketserver/service/contribution.go b/server/marketserver/service/contribution.go index ea604040..7224fefa 100644 --- a/server/marketserver/service/contribution.go +++ b/server/marketserver/service/contribution.go @@ -86,6 +86,10 @@ func (this *contribution) GetEmailAccountId(accountAddress string) (string, stri func (this *contribution) GetAddressContribution(accountAddress string, onlyrecharge bool) (float64, error) { accinfo, exist := this.accountContributionlist.Load(accountAddress) var beforcontribution float64 = 0 + if exist { + beforcontribution = (*accinfo).contribution + } + if nowseconds := f5.GetApp().GetRealSeconds(); !exist || (*accinfo).gcTime+60 < nowseconds { if !exist { info := new(accountContribution) @@ -163,6 +167,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech (*accinfo).loadhistory = true } + (*accinfo).contribution = 0 if (*accinfo).accountid != "" { sql := `SELECT contribution FROM t_contribution WHERE idx > 0 AND account_id = ?` f5.GetGoStyleDb().RawQuery( @@ -200,12 +205,12 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech if ds.Next() { tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0)) - (*accinfo).contribution += tmp (*accinfo).rechargeContri = tmp } }) } + (*accinfo).contribution += (*accinfo).rechargeContri (*accinfo).contribution += (*accinfo).history (*accinfo).gcTime = nowseconds if (*accinfo).loweremail != "" { @@ -213,7 +218,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech } } - if beforcontribution != (*accinfo).contribution { + if beforcontribution > 0.000001 && (*accinfo).contribution > beforcontribution+0.000001 { this.GetGlobalContribution(true) } From 13586dd0d5a8c12338e661a3148f54423b64a251 Mon Sep 17 00:00:00 2001 From: yangduo Date: Tue, 20 Aug 2024 16:36:13 +0800 Subject: [PATCH 02/28] fix --- server/marketserver/service/contribution.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/marketserver/service/contribution.go b/server/marketserver/service/contribution.go index 7224fefa..382045f4 100644 --- a/server/marketserver/service/contribution.go +++ b/server/marketserver/service/contribution.go @@ -264,6 +264,7 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) { } if nowseconds := f5.GetApp().GetRealSeconds(); nowseconds > this.gcTime+60 || instant { + this.globalContribution = 0 sql := `SELECT SUM(contribution) FROM t_contribution WHERE idx > 0` f5.GetGoStyleDb().RawQuery( constant.GAME_DB, From 8ad879c3eede9a911e5c6577c5f79d0d40b28765 Mon Sep 17 00:00:00 2001 From: yangduo Date: Tue, 20 Aug 2024 17:32:50 +0800 Subject: [PATCH 03/28] log --- server/marketserver/service/contribution.go | 24 ++++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/server/marketserver/service/contribution.go b/server/marketserver/service/contribution.go index 382045f4..0dbcf3b0 100644 --- a/server/marketserver/service/contribution.go +++ b/server/marketserver/service/contribution.go @@ -19,9 +19,10 @@ type accountContribution struct { } type contribution struct { - historyContribution float64 - globalContribution float64 - gcTime int64 + historyContribution float64 + rechargeContribution float64 + globalContribution float64 + gcTime int64 accountContributionlist q5.ConcurrentMap[string, *accountContribution] emailContributionlist q5.ConcurrentMap[string, *accountContribution] @@ -204,8 +205,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech } if ds.Next() { - tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0)) - (*accinfo).rechargeContri = tmp + (*accinfo).rechargeContri, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) } }) } @@ -290,11 +290,11 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) { } if ds.Next() { - tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0)) - this.globalContribution += tmp + this.rechargeContribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) } }) + this.globalContribution += this.rechargeContribution this.globalContribution += this.historyContribution this.gcTime = nowseconds } @@ -322,7 +322,15 @@ func (this *contribution) checkContributionList() { } this.accountContributionlist.Delete(account) } + f5.GetSysLog().Info("delete contribution address cache count:%d", len(deletelist)) } - time.Sleep((time.Second * 1800)) + + f5.GetSysLog().Info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") + f5.GetSysLog().Info("contribution cache total:%.2f, recharge:%.2f, history:%.2f", + this.globalContribution, + this.rechargeContribution, + this.historyContribution) + f5.GetSysLog().Info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") + time.Sleep((time.Second * 60)) } } From 40000afc7ba2cb6204afa6bc61bb1389036e2f8c Mon Sep 17 00:00:00 2001 From: yangduo Date: Tue, 20 Aug 2024 17:48:57 +0800 Subject: [PATCH 04/28] =?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/api/v1/activity/stacking.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/server/marketserver/api/v1/activity/stacking.go b/server/marketserver/api/v1/activity/stacking.go index a78a3376..24d28888 100644 --- a/server/marketserver/api/v1/activity/stacking.go +++ b/server/marketserver/api/v1/activity/stacking.go @@ -132,6 +132,7 @@ func (sa *StackingApi) DiamondRecordQuery(c *gin.Context) { Date int32 `json:"date"` Amount string `json:"amount"` Type int32 `json:"type"` + From string `json:"from"` } rspObj := struct { ErrCode int32 `json:"errcode"` @@ -140,7 +141,7 @@ func (sa *StackingApi) DiamondRecordQuery(c *gin.Context) { }{} { - sql := `SELECT * FROM t_diamond_consume_product WHERE account_id = ? OR passport_address = ? ORDER BY createtime DESC` + sql := `SELECT * FROM t_diamond_consume_product WHERE idx > 0 AND (account_id = ? OR passport_address = ?)` params := []string{ accountAddress, accountAddress, @@ -161,13 +162,14 @@ func (sa *StackingApi) DiamondRecordQuery(c *gin.Context) { obj.Date = q5.SafeToInt32(ds.GetByName("createtime")) obj.Amount = ds.GetByName("amount") obj.Type = 1 + obj.From = accountAddress rspObj.Rows = append(rspObj.Rows, obj) } }) } { - sql := `SELECT pay_time, diamond + present_diamond FROM t_recharge_order WHERE passport_address = ? AND pay_status = 1 ORDER BY createtime DESC` + sql := `SELECT pay_time, diamond + present_diamond, account_address FROM t_recharge_order WHERE idx > 0 AND passport_address = ? AND pay_status = 1` params := []string{ accountAddress, } @@ -186,6 +188,7 @@ func (sa *StackingApi) DiamondRecordQuery(c *gin.Context) { obj.Date = q5.SafeToInt32(ds.GetByName("pay_time")) obj.Amount = ds.GetByIndex(1) + obj.From = ds.GetByIndex(2) obj.Type = 0 rspObj.Rows = append(rspObj.Rows, obj) } From 4e934ad8998fdc0ab072ff558c9b749dbbefaa7e Mon Sep 17 00:00:00 2001 From: yangduo Date: Tue, 20 Aug 2024 18:28:07 +0800 Subject: [PATCH 05/28] =?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 | 58 +++++++++++---------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/server/marketserver/service/contribution.go b/server/marketserver/service/contribution.go index 0dbcf3b0..9e222631 100644 --- a/server/marketserver/service/contribution.go +++ b/server/marketserver/service/contribution.go @@ -9,19 +9,23 @@ import ( ) type accountContribution struct { - history float64 - loadhistory bool - contribution float64 - rechargeContri float64 - gcTime int64 - loweremail string - accountid string + history float64 + loadhistory bool + gamecontribution float64 + rechargeContri float64 + gcTime int64 + loweremail string + accountid string +} + +func (ac *accountContribution) sum() float64 { + return ac.history + ac.gamecontribution + ac.rechargeContri } type contribution struct { historyContribution float64 rechargeContribution float64 - globalContribution float64 + gameContribution float64 gcTime int64 accountContributionlist q5.ConcurrentMap[string, *accountContribution] @@ -38,10 +42,14 @@ func (this *contribution) unInit() { } +func (c *contribution) sum() float64 { + return c.historyContribution + c.rechargeContribution + c.gameContribution +} + func (this *contribution) GetEmailContributionAccountid(email string) (float64, string, error) { info, exist := this.emailContributionlist.Load(email) if exist { - return (*info).contribution, (*info).accountid, nil + return (*info).sum(), (*info).accountid, nil } accountid := "" @@ -88,7 +96,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech accinfo, exist := this.accountContributionlist.Load(accountAddress) var beforcontribution float64 = 0 if exist { - beforcontribution = (*accinfo).contribution + beforcontribution = (*accinfo).sum() } if nowseconds := f5.GetApp().GetRealSeconds(); !exist || (*accinfo).gcTime+60 < nowseconds { @@ -97,7 +105,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech this.accountContributionlist.Store(accountAddress, info) accinfo = &info } - beforcontribution = (*accinfo).contribution + beforcontribution = (*accinfo).sum() if (*accinfo).loweremail == "" { sql := `SELECT account_id FROM t_user WHERE idx > 0 AND address = ?` @@ -131,6 +139,10 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech } }) } + + if (*accinfo).loweremail != "" { + this.emailContributionlist.Store((*accinfo).loweremail, *accinfo) + } } if !(*accinfo).loadhistory { @@ -168,7 +180,6 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech (*accinfo).loadhistory = true } - (*accinfo).contribution = 0 if (*accinfo).accountid != "" { sql := `SELECT contribution FROM t_contribution WHERE idx > 0 AND account_id = ?` f5.GetGoStyleDb().RawQuery( @@ -181,7 +192,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech } if ds.Next() { - (*accinfo).contribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) + (*accinfo).gamecontribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) } }) } @@ -210,15 +221,10 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech }) } - (*accinfo).contribution += (*accinfo).rechargeContri - (*accinfo).contribution += (*accinfo).history (*accinfo).gcTime = nowseconds - if (*accinfo).loweremail != "" { - this.emailContributionlist.Store((*accinfo).loweremail, *accinfo) - } } - if beforcontribution > 0.000001 && (*accinfo).contribution > beforcontribution+0.000001 { + if beforcontribution > 0.000001 && (*accinfo).sum() > beforcontribution+0.000001 { this.GetGlobalContribution(true) } @@ -226,7 +232,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech return (*accinfo).rechargeContri, nil } - return (*accinfo).contribution, nil + return (*accinfo).sum(), nil } func (this *contribution) GetGlobalContribution(instant bool) (float64, error) { @@ -264,7 +270,6 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) { } if nowseconds := f5.GetApp().GetRealSeconds(); nowseconds > this.gcTime+60 || instant { - this.globalContribution = 0 sql := `SELECT SUM(contribution) FROM t_contribution WHERE idx > 0` f5.GetGoStyleDb().RawQuery( constant.GAME_DB, @@ -276,7 +281,7 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) { } if ds.Next() { - this.globalContribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) + this.gameContribution, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) } }) sql = `SELECT SUM(return_contribution) FROM t_recharge_return_contribution WHERE idx > 0` @@ -294,12 +299,10 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) { } }) - this.globalContribution += this.rechargeContribution - this.globalContribution += this.historyContribution this.gcTime = nowseconds } - return this.globalContribution, nil + return this.sum(), nil } func (this *contribution) checkContributionList() { @@ -326,9 +329,10 @@ func (this *contribution) checkContributionList() { } f5.GetSysLog().Info("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<") - f5.GetSysLog().Info("contribution cache total:%.2f, recharge:%.2f, history:%.2f", - this.globalContribution, + f5.GetSysLog().Info("contribution cache total:%.2f, recharge:%.2f, ingame:%.2f, history:%.2f", + this.sum(), this.rechargeContribution, + this.gameContribution, this.historyContribution) f5.GetSysLog().Info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>") time.Sleep((time.Second * 60)) From e3a6607b7f3e9f318367e748395966f8957ad129 Mon Sep 17 00:00:00 2001 From: yangduo Date: Tue, 20 Aug 2024 18:36:09 +0800 Subject: [PATCH 06/28] =?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 | 1 + 1 file changed, 1 insertion(+) diff --git a/server/marketserver/service/contribution.go b/server/marketserver/service/contribution.go index 9e222631..60be0509 100644 --- a/server/marketserver/service/contribution.go +++ b/server/marketserver/service/contribution.go @@ -35,6 +35,7 @@ type contribution struct { func (this *contribution) init() { this.accountContributionlist = q5.ConcurrentMap[string, *accountContribution]{} this.emailContributionlist = q5.ConcurrentMap[string, *accountContribution]{} + this.GetGlobalContribution(true) go this.checkContributionList() } From 1f1a09170e588f33960985987c826671c665acb7 Mon Sep 17 00:00:00 2001 From: yangduo Date: Tue, 20 Aug 2024 19:16:54 +0800 Subject: [PATCH 07/28] fix --- server/marketserver/api/v1/activity/contribution.go | 10 ++-------- server/marketserver/api/v1/recharge/recharge.go | 2 +- server/marketserver/api/v1/user/user.go | 6 +++++- server/marketserver/service/contribution.go | 3 +++ 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/server/marketserver/api/v1/activity/contribution.go b/server/marketserver/api/v1/activity/contribution.go index 8c7c7c37..05e242db 100644 --- a/server/marketserver/api/v1/activity/contribution.go +++ b/server/marketserver/api/v1/activity/contribution.go @@ -17,10 +17,7 @@ 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": "", - }) + f5.RspErr(c, 2, "empty account") return } @@ -121,10 +118,7 @@ func (cta *ContriApi) HistoryQuery(c *gin.Context) { func (cta *ContriApi) CECQuery(c *gin.Context) { account := strings.ToLower(c.Param("account_address")) if account == "" { - c.JSON(200, gin.H{ - "errcode": 1, - "errmsg": "", - }) + f5.RspErr(c, 2, "empty account") return } diff --git a/server/marketserver/api/v1/recharge/recharge.go b/server/marketserver/api/v1/recharge/recharge.go index 43da1fd6..f779aa62 100644 --- a/server/marketserver/api/v1/recharge/recharge.go +++ b/server/marketserver/api/v1/recharge/recharge.go @@ -36,7 +36,7 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) { } if contribution, err := service.Contribution.GetAddressContribution(accountAddress, true); err != nil { - f5.RspErr(c, 2, "server internal error") + f5.RspErr(c, 2, err.Error()) return } else { rspObj.Contribution = q5.ToString(contribution) diff --git a/server/marketserver/api/v1/user/user.go b/server/marketserver/api/v1/user/user.go index c73085ae..7c6667a0 100644 --- a/server/marketserver/api/v1/user/user.go +++ b/server/marketserver/api/v1/user/user.go @@ -26,7 +26,11 @@ func (this *UserApi) Info(c *gin.Context) { Diamond string `json:"diamond"` }{} rspObj.Email = c.MustGet("email").(string) - contributionPoint, _ := service.Contribution.GetAddressContribution(accountAddress, false) + contributionPoint, err := service.Contribution.GetAddressContribution(accountAddress, false) + if err != nil { + f5.RspErr(c, 2, err.Error()) + return + } var gold float64 var diamond float64 { diff --git a/server/marketserver/service/contribution.go b/server/marketserver/service/contribution.go index 60be0509..68be4687 100644 --- a/server/marketserver/service/contribution.go +++ b/server/marketserver/service/contribution.go @@ -94,6 +94,9 @@ func (this *contribution) GetEmailAccountId(accountAddress string) (string, stri } func (this *contribution) GetAddressContribution(accountAddress string, onlyrecharge bool) (float64, error) { + if accountAddress == "" { + return 0, fmt.Errorf("empty account") + } accinfo, exist := this.accountContributionlist.Load(accountAddress) var beforcontribution float64 = 0 if exist { From 86b5a499532943b06ec38f9ebdea89e79c790dab Mon Sep 17 00:00:00 2001 From: yangduo Date: Wed, 21 Aug 2024 10:30:46 +0800 Subject: [PATCH 08/28] =?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/api/v1/activity/contribution.go | 2 +- server/marketserver/service/contribution.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/marketserver/api/v1/activity/contribution.go b/server/marketserver/api/v1/activity/contribution.go index 05e242db..ddd47f04 100644 --- a/server/marketserver/api/v1/activity/contribution.go +++ b/server/marketserver/api/v1/activity/contribution.go @@ -134,8 +134,8 @@ func (cta *ContriApi) CECQuery(c *gin.Context) { } `json:"info"` }{} - totalgcp, _ := service.Contribution.GetGlobalContribution(false) mycp, _ := service.Contribution.GetAddressContribution(account, false) + totalgcp, _ := service.Contribution.GetGlobalContribution(false) rspObj.CP = fmt.Sprintf("%.2f", mycp) rspObj.Info.MyCP = rspObj.CP rspObj.Info.GCP = fmt.Sprintf("%.2f", totalgcp) diff --git a/server/marketserver/service/contribution.go b/server/marketserver/service/contribution.go index 68be4687..202920ca 100644 --- a/server/marketserver/service/contribution.go +++ b/server/marketserver/service/contribution.go @@ -312,7 +312,7 @@ func (this *contribution) GetGlobalContribution(instant bool) (float64, error) { func (this *contribution) checkContributionList() { fmt.Println("checkContributionList start") for { - if time.Now().UTC().Hour() == 0 { + if time.Now().UTC().Hour() == 0 && time.Now().UTC().Minute() == 0 { nowseconds := f5.GetApp().GetRealSeconds() deletelist := []string{} this.accountContributionlist.Range(func(key string, value *accountContribution) bool { From b4780301b9edf9475e24e70a94e4a25db3b357e2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 21 Aug 2024 14:00:03 +0800 Subject: [PATCH 09/28] 1 --- bin/marketserver/config/confdb.mysql.json | 9 +++ server/marketserver/mt/ConfDb.go | 15 +++++ server/marketserver/mt/export.go | 6 ++ server/marketserver/mtb/mtb.auto_gen.go | 79 +++++++++++++++++++++++ server/marketserver/proto/mt.proto | 11 ++++ 5 files changed, 120 insertions(+) create mode 100644 bin/marketserver/config/confdb.mysql.json create mode 100644 server/marketserver/mt/ConfDb.go diff --git a/bin/marketserver/config/confdb.mysql.json b/bin/marketserver/config/confdb.mysql.json new file mode 100644 index 00000000..c3477c54 --- /dev/null +++ b/bin/marketserver/config/confdb.mysql.json @@ -0,0 +1,9 @@ +{ + "host": "mysql-test.kingsome.cn", + "port": 3306, + "user": "root", + "passwd": "keji178", + "database": "confdb_dev_1", + "max_open_conns": 1, + "max_idle_conns": 1 +} diff --git a/server/marketserver/mt/ConfDb.go b/server/marketserver/mt/ConfDb.go new file mode 100644 index 00000000..ab948bf7 --- /dev/null +++ b/server/marketserver/mt/ConfDb.go @@ -0,0 +1,15 @@ +package mt + +import ( + "f5" + "main/mtb" +) + +type ConfDb struct { + mtb.ConfDb +} + +type ConfDbTable struct { + f5.IdMetaTable[ConfDb] + selfConf *ConfDb +} diff --git a/server/marketserver/mt/export.go b/server/marketserver/mt/export.go index 1fc05347..dc7673b3 100644 --- a/server/marketserver/mt/export.go +++ b/server/marketserver/mt/export.go @@ -18,6 +18,7 @@ type table struct { Recharge *RechargeTable Currency *CurrencyTable AccountDb *AccountDbTable + ConfDb *ConfDbTable } var Table = f5.New(func(this *table) { @@ -46,6 +47,11 @@ var Table = f5.New(func(this *table) { this.PrimKey = "" }) + this.ConfDb = f5.New(func(this *ConfDbTable) { + this.FileName = "../config/confdb.mysql.json" + this.PrimKey = "" + }) + this.Config = f5.New(func(this *ConfigTable) { this.FileName = "../config/config.json" this.PrimKey = "" diff --git a/server/marketserver/mtb/mtb.auto_gen.go b/server/marketserver/mtb/mtb.auto_gen.go index 34282aa4..15c16c16 100644 --- a/server/marketserver/mtb/mtb.auto_gen.go +++ b/server/marketserver/mtb/mtb.auto_gen.go @@ -65,6 +65,19 @@ type GameDb struct { _flags2_ uint64 } +type ConfDb struct { + host string + port int32 + user string + passwd string + database string + max_open_conns int32 + max_idle_conns int32 + + _flags1_ uint64 + _flags2_ uint64 +} + type Config struct { gameapi_url string jwks_uri string @@ -374,6 +387,62 @@ func (this *GameDb) HasMaxIdleConns() bool { return (this._flags1_ & (uint64(1) << 7)) > 0 } +func (this *ConfDb) GetHost() string { + return this.host +} + +func (this *ConfDb) HasHost() bool { + return (this._flags1_ & (uint64(1) << 1)) > 0 +} + +func (this *ConfDb) GetPort() int32 { + return this.port +} + +func (this *ConfDb) HasPort() bool { + return (this._flags1_ & (uint64(1) << 2)) > 0 +} + +func (this *ConfDb) GetUser() string { + return this.user +} + +func (this *ConfDb) HasUser() bool { + return (this._flags1_ & (uint64(1) << 3)) > 0 +} + +func (this *ConfDb) GetPasswd() string { + return this.passwd +} + +func (this *ConfDb) HasPasswd() bool { + return (this._flags1_ & (uint64(1) << 4)) > 0 +} + +func (this *ConfDb) GetDatabase() string { + return this.database +} + +func (this *ConfDb) HasDatabase() bool { + return (this._flags1_ & (uint64(1) << 5)) > 0 +} + +func (this *ConfDb) GetMaxOpenConns() int32 { + return this.max_open_conns +} + +func (this *ConfDb) HasMaxOpenConns() bool { + return (this._flags1_ & (uint64(1) << 6)) > 0 +} + +func (this *ConfDb) GetMaxIdleConns() int32 { + return this.max_idle_conns +} + +func (this *ConfDb) HasMaxIdleConns() bool { + return (this._flags1_ & (uint64(1) << 7)) > 0 +} + func (this *Config) GetGameapiUrl() string { return this.gameapi_url } @@ -573,6 +642,16 @@ func (this *GameDb) LoadFromKv(kv map[string]interface{}) { f5.ReadMetaTableField(&this.max_idle_conns, "max_idle_conns", &this._flags1_, 7, kv) } +func (this *ConfDb) LoadFromKv(kv map[string]interface{}) { + f5.ReadMetaTableField(&this.host, "host", &this._flags1_, 1, kv) + f5.ReadMetaTableField(&this.port, "port", &this._flags1_, 2, kv) + f5.ReadMetaTableField(&this.user, "user", &this._flags1_, 3, kv) + f5.ReadMetaTableField(&this.passwd, "passwd", &this._flags1_, 4, kv) + f5.ReadMetaTableField(&this.database, "database", &this._flags1_, 5, kv) + f5.ReadMetaTableField(&this.max_open_conns, "max_open_conns", &this._flags1_, 6, kv) + f5.ReadMetaTableField(&this.max_idle_conns, "max_idle_conns", &this._flags1_, 7, kv) +} + func (this *Config) LoadFromKv(kv map[string]interface{}) { f5.ReadMetaTableField(&this.gameapi_url, "gameapi_url", &this._flags1_, 1, kv) f5.ReadMetaTableField(&this.jwks_uri, "jwks_uri", &this._flags1_, 2, kv) diff --git a/server/marketserver/proto/mt.proto b/server/marketserver/proto/mt.proto index 03428950..565ac8cd 100644 --- a/server/marketserver/proto/mt.proto +++ b/server/marketserver/proto/mt.proto @@ -53,6 +53,17 @@ message GameDb optional int32 max_idle_conns = 7; } +message ConfDb +{ + optional string host = 1; + optional int32 port = 2; + optional string user = 3; + optional string passwd = 4; + optional string database = 5; + optional int32 max_open_conns = 6; + optional int32 max_idle_conns = 7; +} + message Config { optional string gameapi_url = 1; From cb0847c3f571313a4d76da98fc10b0340bcf49ad Mon Sep 17 00:00:00 2001 From: yangduo Date: Wed, 21 Aug 2024 14:36:01 +0800 Subject: [PATCH 10/28] gameswitch list --- server/marketserver/api/v1/enter.go | 2 + .../marketserver/api/v1/game_switch/enter.go | 5 +++ .../api/v1/game_switch/gswitch.go | 41 +++++++++++++++++++ server/marketserver/app/app.go | 11 +++++ server/marketserver/constant/constant.go | 1 + .../marketserver/router/game_switch/enter.go | 5 +++ .../router/game_switch/game_switch.go | 13 ++++++ server/marketserver/router/routermgr.go | 3 ++ 8 files changed, 81 insertions(+) create mode 100644 server/marketserver/api/v1/game_switch/enter.go create mode 100644 server/marketserver/api/v1/game_switch/gswitch.go create mode 100644 server/marketserver/router/game_switch/enter.go create mode 100644 server/marketserver/router/game_switch/game_switch.go diff --git a/server/marketserver/api/v1/enter.go b/server/marketserver/api/v1/enter.go index 47db03d5..272c7207 100644 --- a/server/marketserver/api/v1/enter.go +++ b/server/marketserver/api/v1/enter.go @@ -4,6 +4,7 @@ import ( "main/api/v1/activity" "main/api/v1/asset" "main/api/v1/event" + "main/api/v1/game_switch" "main/api/v1/gold_bullion" "main/api/v1/hero" "main/api/v1/ingame" @@ -26,6 +27,7 @@ type ApiGroup struct { ActivityApiGroup activity.ApiGroup EventApiGroup event.ApiGroup RechargeApiGroup recharge.ApiGroup + SwitchApiGroup game_switch.ApiGroup } var ApiGroupApp = new(ApiGroup) diff --git a/server/marketserver/api/v1/game_switch/enter.go b/server/marketserver/api/v1/game_switch/enter.go new file mode 100644 index 00000000..0cac7f13 --- /dev/null +++ b/server/marketserver/api/v1/game_switch/enter.go @@ -0,0 +1,5 @@ +package game_switch + +type ApiGroup struct { + GameSwitchApi +} diff --git a/server/marketserver/api/v1/game_switch/gswitch.go b/server/marketserver/api/v1/game_switch/gswitch.go new file mode 100644 index 00000000..6f75be2e --- /dev/null +++ b/server/marketserver/api/v1/game_switch/gswitch.go @@ -0,0 +1,41 @@ +package game_switch + +import ( + "f5" + "main/constant" + "net/http" + "q5" + + "github.com/gin-gonic/gin" +) + +type GameSwitchApi struct { +} + +func (this *GameSwitchApi) List(c *gin.Context) { + f5.GetGoStyleDb().RawQuery( + constant.CONF_DB, + "SELECT * FROM t_game_switch WHERE 1=1", + []string{}, + func(err error, ds *f5.DataSet) { + if err != nil { + c.JSON(http.StatusOK, gin.H{ + "code": 1, + "message": err.Error(), + }) + return + } + + data := map[string]int32{} + for ds.Next() { + data[ds.GetByName("switch_name")] = q5.SafeToInt32(ds.GetByName("is_open")) + } + + c.JSON(http.StatusOK, gin.H{ + "code": 0, + "message": "获取成功", + "contributionPoint": "", + "data": data, + }) + }) +} diff --git a/server/marketserver/app/app.go b/server/marketserver/app/app.go index 575be92d..70152d4d 100644 --- a/server/marketserver/app/app.go +++ b/server/marketserver/app/app.go @@ -97,6 +97,17 @@ func (this *app) registerDataSources() { 1, mt.Table.AccountDb.GetById(0).GetMaxOpenConns(), mt.Table.AccountDb.GetById(0).GetMaxIdleConns()) + + f5.GetGoStyleDb().RegisterDataSource( + constant.CONF_DB, + mt.Table.ConfDb.GetById(0).GetHost(), + mt.Table.ConfDb.GetById(0).GetPort(), + mt.Table.ConfDb.GetById(0).GetUser(), + mt.Table.ConfDb.GetById(0).GetPasswd(), + mt.Table.ConfDb.GetById(0).GetDatabase(), + 1, + mt.Table.ConfDb.GetById(0).GetMaxOpenConns(), + mt.Table.ConfDb.GetById(0).GetMaxIdleConns()) } func (this *app) HasTask() bool { diff --git a/server/marketserver/constant/constant.go b/server/marketserver/constant/constant.go index 13006a48..ba291c13 100644 --- a/server/marketserver/constant/constant.go +++ b/server/marketserver/constant/constant.go @@ -5,6 +5,7 @@ const ( BCNFT_DB = "bcnftdb" BCEVENT_DB = "bceventdb" GAME_DB = "gamedb" + CONF_DB = "confdb" ) const ( diff --git a/server/marketserver/router/game_switch/enter.go b/server/marketserver/router/game_switch/enter.go new file mode 100644 index 00000000..1871e5c2 --- /dev/null +++ b/server/marketserver/router/game_switch/enter.go @@ -0,0 +1,5 @@ +package game_switch + +type RouterGroup struct { + GameSwitchRouter +} diff --git a/server/marketserver/router/game_switch/game_switch.go b/server/marketserver/router/game_switch/game_switch.go new file mode 100644 index 00000000..9811f62c --- /dev/null +++ b/server/marketserver/router/game_switch/game_switch.go @@ -0,0 +1,13 @@ +package game_switch + +import ( + "f5" + v1 "main/api/v1" +) + +type GameSwitchRouter struct{} + +func (this *GameSwitchRouter) InitRouter() { + api := v1.ApiGroupApp.SwitchApiGroup + f5.GetApp().GetGinEngine().GET("/api/server_switch", api.GameSwitchApi.List) +} diff --git a/server/marketserver/router/routermgr.go b/server/marketserver/router/routermgr.go index f5a45371..61ee28cb 100644 --- a/server/marketserver/router/routermgr.go +++ b/server/marketserver/router/routermgr.go @@ -6,6 +6,7 @@ import ( "main/router/activity" "main/router/asset" "main/router/event" + "main/router/game_switch" "main/router/gold_bullion" "main/router/hero" "main/router/ingame" @@ -28,6 +29,7 @@ type routerMgr struct { activity activity.RouterGroup event event.RouterGroup recharge recharge.RouterGroup + gameswitch game_switch.RouterGroup } func (this *routerMgr) Init() { @@ -45,6 +47,7 @@ func (this *routerMgr) Init() { this.activity.ContributionRouter.InitRouter() this.event.EventRouter.InitRouter() this.recharge.RechargeRouter.InitRouter() + this.gameswitch.GameSwitchRouter.InitRouter() f5.GetSysLog().Info("routerMgr.init") From 993061616c9bad61fbdd00fbc578a3be2e9900c5 Mon Sep 17 00:00:00 2001 From: yangduo Date: Wed, 21 Aug 2024 14:44:34 +0800 Subject: [PATCH 11/28] cache gameswitch --- .../api/v1/game_switch/gswitch.go | 52 +++++++++++-------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/server/marketserver/api/v1/game_switch/gswitch.go b/server/marketserver/api/v1/game_switch/gswitch.go index 6f75be2e..2287d90d 100644 --- a/server/marketserver/api/v1/game_switch/gswitch.go +++ b/server/marketserver/api/v1/game_switch/gswitch.go @@ -10,32 +10,40 @@ import ( ) type GameSwitchApi struct { + data map[string]int32 + time int64 } func (this *GameSwitchApi) List(c *gin.Context) { - f5.GetGoStyleDb().RawQuery( - constant.CONF_DB, - "SELECT * FROM t_game_switch WHERE 1=1", - []string{}, - func(err error, ds *f5.DataSet) { - if err != nil { - c.JSON(http.StatusOK, gin.H{ - "code": 1, - "message": err.Error(), - }) - return - } - data := map[string]int32{} - for ds.Next() { - data[ds.GetByName("switch_name")] = q5.SafeToInt32(ds.GetByName("is_open")) - } + now := f5.GetApp().GetRealSeconds() + if now > this.time+30 { + this.data = map[string]int32{} + this.time = now - c.JSON(http.StatusOK, gin.H{ - "code": 0, - "message": "获取成功", - "contributionPoint": "", - "data": data, + f5.GetGoStyleDb().RawQuery( + constant.CONF_DB, + "SELECT * FROM t_game_switch WHERE 1=1", + []string{}, + func(err error, ds *f5.DataSet) { + if err != nil { + c.JSON(http.StatusOK, gin.H{ + "code": 1, + "message": err.Error(), + }) + return + } + + for ds.Next() { + this.data[ds.GetByName("switch_name")] = q5.SafeToInt32(ds.GetByName("is_open")) + } }) - }) + } + + c.JSON(http.StatusOK, gin.H{ + "code": 0, + "message": "获取成功", + "contributionPoint": "", + "data": this.data, + }) } From ded5802429070f44a9f04fd188cbfaaa0fdcf167 Mon Sep 17 00:00:00 2001 From: yangduo Date: Wed, 21 Aug 2024 20:17:48 +0800 Subject: [PATCH 12/28] check heromint --- .../api/v1/game_switch/gswitch.go | 30 +----- server/marketserver/api/v1/ingame/ingame.go | 101 ++++++++++-------- server/marketserver/constant/constant.go | 4 + server/marketserver/service/export.go | 1 + server/marketserver/service/gameswitch.go | 45 ++++++++ 5 files changed, 107 insertions(+), 74 deletions(-) create mode 100644 server/marketserver/service/gameswitch.go diff --git a/server/marketserver/api/v1/game_switch/gswitch.go b/server/marketserver/api/v1/game_switch/gswitch.go index 2287d90d..31c6a0ee 100644 --- a/server/marketserver/api/v1/game_switch/gswitch.go +++ b/server/marketserver/api/v1/game_switch/gswitch.go @@ -1,10 +1,8 @@ package game_switch import ( - "f5" - "main/constant" + "main/service" "net/http" - "q5" "github.com/gin-gonic/gin" ) @@ -16,34 +14,10 @@ type GameSwitchApi struct { func (this *GameSwitchApi) List(c *gin.Context) { - now := f5.GetApp().GetRealSeconds() - if now > this.time+30 { - this.data = map[string]int32{} - this.time = now - - f5.GetGoStyleDb().RawQuery( - constant.CONF_DB, - "SELECT * FROM t_game_switch WHERE 1=1", - []string{}, - func(err error, ds *f5.DataSet) { - if err != nil { - c.JSON(http.StatusOK, gin.H{ - "code": 1, - "message": err.Error(), - }) - return - } - - for ds.Next() { - this.data[ds.GetByName("switch_name")] = q5.SafeToInt32(ds.GetByName("is_open")) - } - }) - } - c.JSON(http.StatusOK, gin.H{ "code": 0, "message": "获取成功", "contributionPoint": "", - "data": this.data, + "data": service.GameSwitches.GetSwitchList(), }) } diff --git a/server/marketserver/api/v1/ingame/ingame.go b/server/marketserver/api/v1/ingame/ingame.go index 90ffd446..0c2cf05b 100644 --- a/server/marketserver/api/v1/ingame/ingame.go +++ b/server/marketserver/api/v1/ingame/ingame.go @@ -1,33 +1,34 @@ package ingame import ( - "q5" "f5" - "main/mt" "main/common" "main/constant" . "main/global" + "main/mt" + "marketserver/service" + "q5" + "github.com/gin-gonic/gin" ) type InGameApi struct { - } func (this *InGameApi) HeroList(c *gin.Context) { reqJson := struct { PageSize interface{} `json:"page_size"` - Cursor interface{} `json:"cursor"` - Search struct { + Cursor interface{} `json:"cursor"` + Search struct { Name string `json:"name"` } `json:"search"` Filter struct { - ItemIds []interface{} `json:"item_ids"` + ItemIds []interface{} `json:"item_ids"` HeroRanks []interface{} `json:"hero_ranks"` } `json:"filter"` Sort struct { - Fields [] struct { - Name string `json:"name"` + Fields []struct { + Name string `json:"name"` Type interface{} `json:"type"` } `json:"fields"` } `json:"sort"` @@ -45,10 +46,10 @@ func (this *InGameApi) HeroList(c *gin.Context) { } rspObj := struct { - ErrCode int32 `json:"errcode"` - ErrMsg string `json:"errmsg"` - Page common.StreamPagination `json:"page"` - Rows [] interface{} `json:"rows"` + ErrCode int32 `json:"errcode"` + ErrMsg string `json:"errmsg"` + Page common.StreamPagination `json:"page"` + Rows []interface{} `json:"rows"` }{} q5.NewSlice(&rspObj.Rows, 0, 10) @@ -56,26 +57,31 @@ func (this *InGameApi) HeroList(c *gin.Context) { heroList, q5.SafeToInt32(reqJson.PageSize), q5.SafeToInt64(reqJson.Cursor), - func (kv interface{}) bool { + func(kv interface{}) bool { return true }, - func (a interface{}, b interface{}) bool { + func(a interface{}, b interface{}) bool { return true }, - func (p *f5.StreamPagination) { + func(p *f5.StreamPagination) { rspObj.Page.FillPage(p) }, - func (kv interface{}) { + func(kv interface{}) { q5.AppendSlice(&rspObj.Rows, kv) }) c.JSON(200, rspObj) } func (this *InGameApi) HeroMint(c *gin.Context) { + if service.GameSwitches.CheckSwitch(constant.GAME_SWITCH_HERO_MINT) == 0 { + f5.RspErr(c, 404, "unavailable request") + return + } + reqJson := struct { - NetId interface{} `json:"net_id"` - To string `json:"to"` - HeroUniIds []string `json:"hero_uniids"` + NetId interface{} `json:"net_id"` + To string `json:"to"` + HeroUniIds []string `json:"hero_uniids"` }{} if err := c.ShouldBindJSON(&reqJson); err != nil { f5.RspErr(c, 401, "params parse error") @@ -99,29 +105,28 @@ func (this *InGameApi) HeroMint(c *gin.Context) { {"account_id", accountId}, {"idx", uniid}, }, - func (err error, ds *f5.DataSet) { + func(err error, ds *f5.DataSet) { if err != nil { f5.RspErr(c, 500, "server internal error") return } if ds.Next() { params := map[string]string{ - "c": "OutAppMint", - "a": "mintHero", - "account_id": accountId, + "c": "OutAppMint", + "a": "mintHero", + "account_id": accountId, "account_address": accountAddress, - "to_address": reqJson.To, - "uniid": uniid, + "to_address": reqJson.To, + "uniid": uniid, } rspObj := &struct { - ErrCode interface{} `json:"errcode"` - ErrMsg string `json:"errmsg"` - TransId string `json:"trans_id"` + ErrCode interface{} `json:"errcode"` + ErrMsg string `json:"errmsg"` + TransId string `json:"trans_id"` TransReq interface{} `json:"trans_req"` - }{ - } + }{} f5.GetHttpCliMgr().SendGoStyleRequest( - mt.Table.Config.GetGameApiUrl() + "/webapp/index.php", + mt.Table.Config.GetGameApiUrl()+"/webapp/index.php", params, func(rsp f5.HttpCliResponse) { if rsp.GetErr() != nil { @@ -146,10 +151,15 @@ func (this *InGameApi) HeroMint(c *gin.Context) { } func (this *InGameApi) newHeroMint(c *gin.Context) { + if service.GameSwitches.CheckSwitch(constant.GAME_SWITCH_HERO_MINT) == 0 { + f5.RspErr(c, 404, "unavailable request") + return + } + reqJson := struct { - NetId interface{} `json:"net_id"` - To string `json:"to"` - HeroUniIds []string `json:"hero_uniids"` + NetId interface{} `json:"net_id"` + To string `json:"to"` + HeroUniIds []string `json:"hero_uniids"` }{} if err := c.ShouldBindJSON(&reqJson); err != nil { f5.RspErr(c, 401, "params parse error") @@ -173,29 +183,28 @@ func (this *InGameApi) newHeroMint(c *gin.Context) { {"account_id", accountId}, {"idx", uniid}, }, - func (err error, ds *f5.DataSet) { + func(err error, ds *f5.DataSet) { if err != nil { f5.RspErr(c, 500, "server internal error") return } if ds.Next() { params := map[string]string{ - "c": "OutAppMint", - "a": "mintHero", - "account_id": accountId, + "c": "OutAppMint", + "a": "mintHero", + "account_id": accountId, "account_address": accountAddress, - "to_address": reqJson.To, - "uniid": uniid, + "to_address": reqJson.To, + "uniid": uniid, } rspObj := &struct { - ErrCode interface{} `json:"errcode"` - ErrMsg string `json:"errmsg"` - TransId string `json:"trans_id"` + ErrCode interface{} `json:"errcode"` + ErrMsg string `json:"errmsg"` + TransId string `json:"trans_id"` TransReq interface{} `json:"trans_req"` - }{ - } + }{} f5.GetHttpCliMgr().SendGoStyleRequest( - mt.Table.Config.GetGameApiUrl() + "/webapp/index.php", + mt.Table.Config.GetGameApiUrl()+"/webapp/index.php", params, func(rsp f5.HttpCliResponse) { if rsp.GetErr() != nil { diff --git a/server/marketserver/constant/constant.go b/server/marketserver/constant/constant.go index ba291c13..dae7e836 100644 --- a/server/marketserver/constant/constant.go +++ b/server/marketserver/constant/constant.go @@ -26,3 +26,7 @@ const ( RECHARGE_CURRENCY_MAX_DECIMAL = 6 RECHARGE_CURRENCY_MAX_BUY_NUM = 9999 ) + +const ( + GAME_SWITCH_HERO_MINT = "heroMint" +) diff --git a/server/marketserver/service/export.go b/server/marketserver/service/export.go index 517ec780..f41910a9 100644 --- a/server/marketserver/service/export.go +++ b/server/marketserver/service/export.go @@ -7,6 +7,7 @@ import ( var Contribution = new(contribution) var _serviceMgr = new(serviceMgr) +var GameSwitches = new(gameSwitch) func init() { global.RegModule(constant.SERVICE_MGR_MODULE_IDX, _serviceMgr) diff --git a/server/marketserver/service/gameswitch.go b/server/marketserver/service/gameswitch.go new file mode 100644 index 00000000..0281ba4c --- /dev/null +++ b/server/marketserver/service/gameswitch.go @@ -0,0 +1,45 @@ +package service + +import ( + "f5" + "marketserver/constant" + "q5" +) + +type gameSwitch struct { + data map[string]int32 + time int64 +} + +func (this *gameSwitch) GetSwitchList() map[string]int32 { + now := f5.GetApp().GetRealSeconds() + if now > this.time+30 { + this.data = map[string]int32{} + this.time = now + + f5.GetGoStyleDb().RawQuery( + constant.CONF_DB, + "SELECT * FROM t_game_switch WHERE 1=1", + []string{}, + func(err error, ds *f5.DataSet) { + if err != nil { + return + } + + for ds.Next() { + this.data[ds.GetByName("switch_name")] = q5.SafeToInt32(ds.GetByName("is_open")) + } + }) + } + + return this.data +} + +func (this *gameSwitch) CheckSwitch(gs string) int32 { + v, exist := this.data[gs] + if exist { + return v + } + + return 0 +} From e0c06c8b01e5125933069adf7c21ed1643b5dc7b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 22 Aug 2024 19:14:54 +0800 Subject: [PATCH 13/28] 1 --- server/mailserver/mail/mailmgr.go | 1 + server/mailserver/player/player.go | 1 + 2 files changed, 2 insertions(+) diff --git a/server/mailserver/mail/mailmgr.go b/server/mailserver/mail/mailmgr.go index 45d3ad5f..492c6e64 100644 --- a/server/mailserver/mail/mailmgr.go +++ b/server/mailserver/mail/mailmgr.go @@ -134,6 +134,7 @@ func (this *mailMgr) CaGetMailList(c *gin.Context) { this.traversePlayerMail( hum, func (m *mail) bool { + f5.GetSysLog().Info("getMailList mail_id:%s", m.mailId) if m.IsValid(hum) { if hum.IsReadable(m) { mailDto := new(common.MailDto) diff --git a/server/mailserver/player/player.go b/server/mailserver/player/player.go index 92862d22..ec390a52 100644 --- a/server/mailserver/player/player.go +++ b/server/mailserver/player/player.go @@ -237,6 +237,7 @@ func (this *player) load() { p.state = q5.ToInt32(ds.GetByName("state")) p.expireTime = q5.ToInt32(ds.GetByName("expiretime")) this.inboxHash[p.mailId] = p + f5.GetSysLog().Info("load mail mail_id:%s", p.mailId) } this.loaded = true }) From c8187f971e00a500e55c92dc739fbb02b0410382 Mon Sep 17 00:00:00 2001 From: yangduo Date: Fri, 23 Aug 2024 14:33:42 +0800 Subject: [PATCH 14/28] =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=8C=E8=B4=A8?= =?UTF-8?q?=E6=8A=BC=E7=BB=A7=E7=BB=AD=E6=9C=89=E6=94=B6=E7=9B=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/v1/activity/contribution.go | 36 ++++++++++--------- server/marketserver/service/contribution.go | 8 +++-- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/server/marketserver/api/v1/activity/contribution.go b/server/marketserver/api/v1/activity/contribution.go index ddd47f04..d78f8560 100644 --- a/server/marketserver/api/v1/activity/contribution.go +++ b/server/marketserver/api/v1/activity/contribution.go @@ -60,24 +60,26 @@ func (cta *ContriApi) HistoryQuery(c *gin.Context) { { 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 - } + if accountid != "" { + 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) - } - }) + 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 (?` diff --git a/server/marketserver/service/contribution.go b/server/marketserver/service/contribution.go index 202920ca..8f6bd1a3 100644 --- a/server/marketserver/service/contribution.go +++ b/server/marketserver/service/contribution.go @@ -10,7 +10,7 @@ import ( type accountContribution struct { history float64 - loadhistory bool + // loadhistory bool gamecontribution float64 rechargeContri float64 gcTime int64 @@ -149,7 +149,9 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech } } - if !(*accinfo).loadhistory { + // if !(*accinfo).loadhistory + { + (*accinfo).history = 0 sql := `SELECT contribution FROM t_contribution WHERE idx > 0 and account_address = ?` f5.GetGoStyleDb().RawQuery( constant.BCNFT_DB, @@ -181,7 +183,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech } }) - (*accinfo).loadhistory = true + // (*accinfo).loadhistory = true } if (*accinfo).accountid != "" { From 4d2fc95ed08a1797d9fec6d439d39c25f028844c Mon Sep 17 00:00:00 2001 From: yangduo Date: Fri, 23 Aug 2024 15:01:17 +0800 Subject: [PATCH 15/28] =?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 | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/server/marketserver/service/contribution.go b/server/marketserver/service/contribution.go index 8f6bd1a3..7c2b6913 100644 --- a/server/marketserver/service/contribution.go +++ b/server/marketserver/service/contribution.go @@ -10,7 +10,7 @@ import ( type accountContribution struct { history float64 - // loadhistory bool + stakingContri float64 gamecontribution float64 rechargeContri float64 gcTime int64 @@ -19,7 +19,7 @@ type accountContribution struct { } func (ac *accountContribution) sum() float64 { - return ac.history + ac.gamecontribution + ac.rechargeContri + return ac.history + ac.stakingContri + ac.gamecontribution + ac.rechargeContri } type contribution struct { @@ -149,9 +149,7 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech } } - // if !(*accinfo).loadhistory { - (*accinfo).history = 0 sql := `SELECT contribution FROM t_contribution WHERE idx > 0 and account_address = ?` f5.GetGoStyleDb().RawQuery( constant.BCNFT_DB, @@ -178,12 +176,9 @@ func (this *contribution) GetAddressContribution(accountAddress string, onlyrech } if ds.Next() { - tmp, _ := q5.ToFloat64Ex(ds.GetByIndex(0)) - (*accinfo).history += tmp + (*accinfo).stakingContri, _ = q5.ToFloat64Ex(ds.GetByIndex(0)) } }) - - // (*accinfo).loadhistory = true } if (*accinfo).accountid != "" { From 13f17e49e0b1798d1a4943e73276a6ce18febee6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 16:22:28 +0800 Subject: [PATCH 16/28] 1 --- server/marketserver/service/export.go | 1 + server/marketserver/service/servicemgr.go | 2 ++ server/marketserver/service/user.go | 21 +++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 server/marketserver/service/user.go diff --git a/server/marketserver/service/export.go b/server/marketserver/service/export.go index f41910a9..ff5606f2 100644 --- a/server/marketserver/service/export.go +++ b/server/marketserver/service/export.go @@ -8,6 +8,7 @@ import ( var Contribution = new(contribution) var _serviceMgr = new(serviceMgr) var GameSwitches = new(gameSwitch) +var User = new(user) func init() { global.RegModule(constant.SERVICE_MGR_MODULE_IDX, _serviceMgr) diff --git a/server/marketserver/service/servicemgr.go b/server/marketserver/service/servicemgr.go index 14997cfe..4e9d8baa 100644 --- a/server/marketserver/service/servicemgr.go +++ b/server/marketserver/service/servicemgr.go @@ -5,8 +5,10 @@ type serviceMgr struct { func (this *serviceMgr) Init() { Contribution.init() + User.init() } func (this *serviceMgr) UnInit() { Contribution.unInit() + User.unInit() } diff --git a/server/marketserver/service/user.go b/server/marketserver/service/user.go new file mode 100644 index 00000000..68913856 --- /dev/null +++ b/server/marketserver/service/user.go @@ -0,0 +1,21 @@ +package service + +import ( + "strings" +) + +type user struct { +} + +func (this *user) init(){ +} + +func (this *user) unInit(){ +} + +func (this *user) InBlackList(userIdentity string) (bool, error) { + if strings.ToLower(userIdentity) == strings.ToLower("0x52f01e8791cb558c93ee0c59ea5ff5d79fc82044") { + return true, nil + } + return false, nil +} From f7395cc45c522a412af4da1869e6e15aa0ae6d47 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 16:30:40 +0800 Subject: [PATCH 17/28] 1 --- server/marketserver/api/v1/nft/nft.go | 8 ++++++++ server/marketserver/api/v1/recharge/recharge.go | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/server/marketserver/api/v1/nft/nft.go b/server/marketserver/api/v1/nft/nft.go index dfc3aea6..c8b6a435 100644 --- a/server/marketserver/api/v1/nft/nft.go +++ b/server/marketserver/api/v1/nft/nft.go @@ -6,6 +6,7 @@ import ( "main/mt" "jccommon" "main/constant" + "main/service" "strings" "github.com/gin-gonic/gin" ) @@ -67,6 +68,13 @@ func (this *NftApi) Unlock(c *gin.Context) { f5.RspErr(c, 500, "nft not found") return } + if ok, err := service.User.InBlackList(accountAddress); err != nil { + f5.RspErr(c, 500, "server internal error") + return + } else if ok { + f5.RspErr(c, 501, "illegal user") + return + } params := map[string]string{ "c": "BcService", "a": "nftUnlock", diff --git a/server/marketserver/api/v1/recharge/recharge.go b/server/marketserver/api/v1/recharge/recharge.go index f779aa62..f5cdc9f2 100644 --- a/server/marketserver/api/v1/recharge/recharge.go +++ b/server/marketserver/api/v1/recharge/recharge.go @@ -170,6 +170,13 @@ func (this *RechargeApi) internalBuy(c *gin.Context, f5.RspErr(c, 3, "server internal error") return } + if ok, err := service.User.InBlackList(accountAddress); err != nil { + f5.RspErr(c, 500, "server internal error") + return + } else if ok { + f5.RspErr(c, 501, "illegal user") + return + } params := map[string]string{ "c": "BcService", "a": "recharge", From 993bc9bbe729435e633dca048453c78159dc4bc8 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 16:58:14 +0800 Subject: [PATCH 18/28] 1 --- .../config/currencys/97/currency.json | 4 ++-- server/marketserver/constant/constant.go | 1 + server/marketserver/mt/Currency.go | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bin/marketserver/config/currencys/97/currency.json b/bin/marketserver/config/currencys/97/currency.json index 00ec2ea5..2cdb2bb2 100644 --- a/bin/marketserver/config/currencys/97/currency.json +++ b/bin/marketserver/config/currencys/97/currency.json @@ -2,11 +2,11 @@ { "currency_name": "USDC", "contract_name": "BEUSDC", - "currency_decimal": 6 + "currency_decimal": 18 }, { "currency_name": "USDT", "contract_name": "BEUSDT", - "currency_decimal": 6 + "currency_decimal": 18 } ] diff --git a/server/marketserver/constant/constant.go b/server/marketserver/constant/constant.go index dae7e836..1c2704ed 100644 --- a/server/marketserver/constant/constant.go +++ b/server/marketserver/constant/constant.go @@ -25,6 +25,7 @@ const ( RECHARGE_CURRENCY_MAX_EXCHANGE_RAET = 100 RECHARGE_CURRENCY_MAX_DECIMAL = 6 RECHARGE_CURRENCY_MAX_BUY_NUM = 9999 + BNB_RECHARGE_CURRENCY_MAX_DECIMAL = 18 ) const ( diff --git a/server/marketserver/mt/Currency.go b/server/marketserver/mt/Currency.go index 650dd1ec..bb2647e7 100644 --- a/server/marketserver/mt/Currency.go +++ b/server/marketserver/mt/Currency.go @@ -43,14 +43,21 @@ func (this *Currency) GetContract() *Contract { return this.contract } -func (this *Currency) check() { +func (this *Currency) check(netId int32) { if this.GetCurrencyDecimal() <= 0 { panic("Currency currency_decimal <= 0") return } - if this.GetCurrencyDecimal() != constant.RECHARGE_CURRENCY_MAX_DECIMAL { - panic("Currency exchange_rate > uplimit") - return + if netId == 56 || netId == 97 { + if this.GetCurrencyDecimal() != constant.BNB_RECHARGE_CURRENCY_MAX_DECIMAL { + panic("Currency exchange_rate > uplimit") + return + } + } else { + if this.GetCurrencyDecimal() != constant.RECHARGE_CURRENCY_MAX_DECIMAL { + panic("Currency exchange_rate > uplimit") + return + } } } @@ -109,7 +116,7 @@ func (this *CurrencyTable) Load() { for _, currencyCfg := range currencysCfg { p := new(Currency) p.init(currencyCfg.CurrencyName, currencyCfg.ContractName, currencyCfg.CurrencyDecimal) - p.check() + p.check(netId) currencysMeta := this.GetByNetId(netId) if currencysMeta == nil { currencysMeta = new(q5.ConcurrentMap[string, *Currency]) From be3ec0ef5ca680b43b31f81cef6d7d475da1cc3d Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 17:19:55 +0800 Subject: [PATCH 19/28] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=B4=A7=E5=B8=81?= =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/marketserver/api/v1/recharge/recharge.go | 14 ++++++++++---- server/marketserver/service/recharge.go | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/server/marketserver/api/v1/recharge/recharge.go b/server/marketserver/api/v1/recharge/recharge.go index f5cdc9f2..c9e513bd 100644 --- a/server/marketserver/api/v1/recharge/recharge.go +++ b/server/marketserver/api/v1/recharge/recharge.go @@ -13,6 +13,7 @@ import ( "q5" "strings" + "math/big" "github.com/gin-gonic/gin" ) @@ -165,8 +166,13 @@ func (this *RechargeApi) internalBuy(c *gin.Context, } } srcPrice := q5.ToInt64(goodsMeta.GetPrice()) * q5.ToInt64(goodsNum) - price := q5.PowInt64(10, currencyMeta.GetCurrencyDecimal()) * srcPrice - if price <= 0 || price < q5.ToInt64(goodsMeta.GetPrice()) { + bnPrice := big.NewInt(0) + { + var i, e = big.NewInt(10), big.NewInt(currencyMeta.GetCurrencyDecimal()) + i.Exp(i, e, nil) + bnPrice = i.Mul(i, big.NewInt(srcPrice)) + } + if bnPrice.Cmp(big.NewInt(0)) < 0 || bnPrice.Cmp(big.NewInt(q5.ToInt64(goodsMeta.GetPrice()))) < 0 { f5.RspErr(c, 3, "server internal error") return } @@ -184,7 +190,7 @@ func (this *RechargeApi) internalBuy(c *gin.Context, "order_id": orderId, "account_address": accountAddress, "passport_address": passportAddress, - "amount": q5.ToString(price), + "amount": bnPrice.String(), "currency_name": currencyContractMeta.GetName(), "currency_address": currencyContractMeta.GetAddress(), } @@ -223,7 +229,7 @@ func (this *RechargeApi) internalBuy(c *gin.Context, currencyContractMeta.GetAddress(), goodsMeta.GetId(), itemNum, - price, + bnPrice.String(), srcPrice, diamond, presentDiamond, diff --git a/server/marketserver/service/recharge.go b/server/marketserver/service/recharge.go index 65043737..428f7dae 100644 --- a/server/marketserver/service/recharge.go +++ b/server/marketserver/service/recharge.go @@ -10,7 +10,7 @@ import ( func AddRechargeOrder(orderId string, shortOrderId string, netId int32, accountAddress string, passportAddress string, currencyAddress string, currencyName string, itemId int32, itemNum int32, - price int64, srcPrice int64, diamond int64, presentDiamond int64, email string) bool { + price string, srcPrice int64, diamond int64, presentDiamond int64, email string) bool { ok := false nowTime := f5.GetApp().GetRealSeconds() fields := [][]string{ @@ -23,7 +23,7 @@ func AddRechargeOrder(orderId string, shortOrderId string, {"currency_address", currencyAddress}, {"item_id", q5.ToString(itemId)}, {"item_num", q5.ToString(itemNum)}, - {"price", q5.ToString(price)}, + {"price", price}, {"diamond", q5.ToString(diamond)}, {"present_diamond", q5.ToString(presentDiamond)}, {"return_contribution", q5.ToString(srcPrice * 1)}, From 17f5cfaf89bd1e779d0531c5f684e6a744a00b23 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 17:38:31 +0800 Subject: [PATCH 20/28] 1 --- server/jccommon/constant.go | 3 +++ server/marketserver/api/v1/recharge/recharge.go | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/server/jccommon/constant.go b/server/jccommon/constant.go index 4f762121..f11725e9 100644 --- a/server/jccommon/constant.go +++ b/server/jccommon/constant.go @@ -40,6 +40,7 @@ const ( MAIL_TAG1_CUSTOM = 10 MAIL_TAG1_HERO = 100 MAIL_TAG1_GOLD_BULLION = 101 + MAIL_TAG1_OLD_USER = 102 ) const ( @@ -53,6 +54,8 @@ const ( MAIL_TAG2_GOLD_BULLION_LOCK = 2 MAIL_TAG2_GOLD_BULLION_UNLOCK = 3 MAIL_TAG2_GOLD_BULLION_RETURN = 4 + + MAIL_TAG2_OLD_USER = 1 ) const ( diff --git a/server/marketserver/api/v1/recharge/recharge.go b/server/marketserver/api/v1/recharge/recharge.go index c9e513bd..17ec91ff 100644 --- a/server/marketserver/api/v1/recharge/recharge.go +++ b/server/marketserver/api/v1/recharge/recharge.go @@ -172,7 +172,9 @@ func (this *RechargeApi) internalBuy(c *gin.Context, i.Exp(i, e, nil) bnPrice = i.Mul(i, big.NewInt(srcPrice)) } - if bnPrice.Cmp(big.NewInt(0)) < 0 || bnPrice.Cmp(big.NewInt(q5.ToInt64(goodsMeta.GetPrice()))) < 0 { + f5.GetSysLog().Info("recharge net_id:%d currency_name:%s decimal:%d srcPrice:%d bnPrice:%s", + netId, currencyMeta.GetCurrencyName(), currencyMeta.GetCurrencyDecimal(), srcPrice, bnPrice.String()); + if bnPrice.Cmp(big.NewInt(0)) < 0 || bnPrice.Cmp(big.NewInt(srcPrice)) < 0 { f5.RspErr(c, 3, "server internal error") return } From 0775bfd7a74b96876f29c5632cba763e95ef7405 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 18:30:40 +0800 Subject: [PATCH 21/28] 1 --- server/light_backtask/task/olduser.go | 16 ++++++++++++++++ server/light_backtask/task/taskmgr.go | 3 +++ 2 files changed, 19 insertions(+) create mode 100644 server/light_backtask/task/olduser.go diff --git a/server/light_backtask/task/olduser.go b/server/light_backtask/task/olduser.go new file mode 100644 index 00000000..1800fc67 --- /dev/null +++ b/server/light_backtask/task/olduser.go @@ -0,0 +1,16 @@ +package task + +import ( +) + +type oldUser struct { + +} + +func (this *oldUser) init() { + +} + +func (this *oldUser) unInit() { + +} diff --git a/server/light_backtask/task/taskmgr.go b/server/light_backtask/task/taskmgr.go index 42cb72d1..81e4a54f 100644 --- a/server/light_backtask/task/taskmgr.go +++ b/server/light_backtask/task/taskmgr.go @@ -12,6 +12,7 @@ type taskMgr struct { contribution chainActivity recharge + oldUser } func (this *taskMgr) Init() { @@ -23,9 +24,11 @@ func (this *taskMgr) Init() { this.contribution.init() this.chainActivity.init() this.recharge.init() + this.oldUser.init() } func (this *taskMgr) UnInit() { + this.oldUser.unInit() this.recharge.unInit() this.chainActivity.unInit() this.contribution.unInit() From 040e52770452ce265736475fe52134f005e6c6f6 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 19:17:19 +0800 Subject: [PATCH 22/28] 1 --- server/light_backtask/task/olduser.go | 81 ++++++++++++++++++++++++++- 1 file changed, 80 insertions(+), 1 deletion(-) diff --git a/server/light_backtask/task/olduser.go b/server/light_backtask/task/olduser.go index 1800fc67..056ae223 100644 --- a/server/light_backtask/task/olduser.go +++ b/server/light_backtask/task/olduser.go @@ -1,6 +1,12 @@ package task import ( + "q5" + "f5" + "main/constant" + "encoding/json" + "fmt" + "jccommon" ) type oldUser struct { @@ -8,7 +14,80 @@ type oldUser struct { } func (this *oldUser) init() { - + oldUsers := []struct { + Idx int32 `json:"idx"` + AccountId string `json:"account_id"` + Diamond int32 `json:"diamond"` + }{} + { + if jsonStr, err := f5.ReadJsonFile("/home/kingsome/pub/game2006web3/server/web3tools/1.json"); err == nil { + if err := json.Unmarshal([]byte(jsonStr), &oldUsers); err != nil { + panic(fmt.Sprintf("load oldUser json decode error %s %s", "nets.json", err)) + } + } else { + panic(fmt.Sprintf("load oldUser error %s %s", "nets.json", err)) + } + } + type AttachmentDto struct { + ItemId int32 `json:"itemid"` + ItemNum int32 `json:"itemnum"` + } + //fmt.Println("%s", oldUsers) + for _, user := range oldUsers { + if user.Idx <= 0 { + panic("") + } + if user.AccountId == "" { + panic("") + } + if user.Diamond <= 0 { + panic("") + } + mailId := q5.ToString(f5.GetApp().NewLockNodeUuid()) + unikey := "oldUser.return.20240823:" + user.AccountId + subject := "Claim Your Diamonds" + content := "Thanks for participating in P2E S1! The gold you earned in Gold Mode has been converted to diamonds at a 1:1 ratio. Click “Claim” to receive your rewards now." + nowTime := f5.GetApp().GetRealSeconds() + sendTime := f5.GetApp().GetRealSeconds() + expireTime := nowTime + 3600 * 24 * 15 + userRegEndTime := nowTime + 3600 * 24 * 365 + f5.GetGoStyleDb().Upsert( + constant.BCNFT_DB, + "t_mail", + [][]string{ + {"unikey", unikey}, + }, + [][]string{ + }, + [][]string{ + {"mail_id", mailId}, + {"mail_type", q5.ToString(jccommon.MAIL_TYPE_GROUP)}, + {"unikey", unikey}, + {"subject", subject}, + {"content", content}, + {"recipients", q5.EncodeJson([]string{ + user.AccountId, + })}, + {"attachments", q5.EncodeJson([]AttachmentDto{ + AttachmentDto{ + ItemId : 10014, + ItemNum : user.Diamond}, + })}, + {"sendtime", q5.ToString(sendTime)}, + {"user_reg_start_time", q5.ToString(0)}, + {"user_reg_end_time", q5.ToString(userRegEndTime)}, + {"tag1", q5.ToString(jccommon.MAIL_TAG1_OLD_USER)}, + {"tag2", q5.ToString(jccommon.MAIL_TAG2_OLD_USER)}, + {"expiretime", q5.ToString(expireTime)}, + {"createtime", q5.ToString(nowTime)}, + {"modifytime", q5.ToString(nowTime)}, + }, + func (err error, lastInsertId int64, rowsAffected int64) { + if err != nil { + panic("") + } + }) + } } func (this *oldUser) unInit() { From de09b6f6c925945a6e03276521d667841447875e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 19:19:55 +0800 Subject: [PATCH 23/28] 1 --- server/light_backtask/task/taskmgr.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/server/light_backtask/task/taskmgr.go b/server/light_backtask/task/taskmgr.go index 81e4a54f..42cb72d1 100644 --- a/server/light_backtask/task/taskmgr.go +++ b/server/light_backtask/task/taskmgr.go @@ -12,7 +12,6 @@ type taskMgr struct { contribution chainActivity recharge - oldUser } func (this *taskMgr) Init() { @@ -24,11 +23,9 @@ func (this *taskMgr) Init() { this.contribution.init() this.chainActivity.init() this.recharge.init() - this.oldUser.init() } func (this *taskMgr) UnInit() { - this.oldUser.unInit() this.recharge.unInit() this.chainActivity.unInit() this.contribution.unInit() From 206b067a0c99a1f6668bdb7122f2b80fca62385e Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 23 Aug 2024 23:32:20 +0800 Subject: [PATCH 24/28] 1 --- server/marketserver/service/user.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/marketserver/service/user.go b/server/marketserver/service/user.go index 68913856..619d7497 100644 --- a/server/marketserver/service/user.go +++ b/server/marketserver/service/user.go @@ -14,8 +14,9 @@ func (this *user) unInit(){ } func (this *user) InBlackList(userIdentity string) (bool, error) { + /* if strings.ToLower(userIdentity) == strings.ToLower("0x52f01e8791cb558c93ee0c59ea5ff5d79fc82044") { return true, nil - } + }*/ return false, nil } From 6b3134779a23b88c6118963bd6d5566856c8ddc2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 24 Aug 2024 07:41:14 +0800 Subject: [PATCH 25/28] 1 --- server/marketserver/service/user.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/marketserver/service/user.go b/server/marketserver/service/user.go index 619d7497..117b1277 100644 --- a/server/marketserver/service/user.go +++ b/server/marketserver/service/user.go @@ -1,7 +1,7 @@ package service import ( - "strings" + //"strings" ) type user struct { From dcdcd6f4301a7614bfba6e6c5ab7060c06106cf3 Mon Sep 17 00:00:00 2001 From: yangduo Date: Mon, 26 Aug 2024 14:18:31 +0800 Subject: [PATCH 26/28] block player --- .../adminserver/api/v1/system/block_player.go | 4 +-- server/adminserver/api/v1/system/whitelist.go | 4 +-- server/marketserver/api/v1/user/user.go | 2 +- server/marketserver/service/user.go | 32 +++++++++++++++---- 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/server/adminserver/api/v1/system/block_player.go b/server/adminserver/api/v1/system/block_player.go index 789a8879..f1b1d9cd 100644 --- a/server/adminserver/api/v1/system/block_player.go +++ b/server/adminserver/api/v1/system/block_player.go @@ -132,7 +132,7 @@ func (bpa *BlockPlayerApi) Edit(c *gin.Context) { blockplayer := new(system.BlockPlayer) db := f5.GetApp().GetOrmDb(constant.CONF_DB) - if err := db.Take(blockplayer, "account_id =?", req.Account).Error; err != nil { + if err := db.Take(blockplayer, "account_id = ? AND deleted = 0", req.Account).Error; err != nil { if !f5.IsOrmErrRecordNotFound(err) { c.JSON(http.StatusOK, gin.H{ "code": 500, @@ -178,7 +178,7 @@ func (bpa *BlockPlayerApi) Del(c *gin.Context) { blockplayer := new(system.BlockPlayer) db := f5.GetApp().GetOrmDb(constant.CONF_DB) - if err := db.Take(blockplayer, "account_id =?", req.Account).Error; err != nil { + if err := db.Take(blockplayer, "account_id = ? AND deleted = 0", req.Account).Error; err != nil { if !f5.IsOrmErrRecordNotFound(err) { c.JSON(http.StatusOK, gin.H{ "code": 500, diff --git a/server/adminserver/api/v1/system/whitelist.go b/server/adminserver/api/v1/system/whitelist.go index 890a08ee..b45fa2f1 100644 --- a/server/adminserver/api/v1/system/whitelist.go +++ b/server/adminserver/api/v1/system/whitelist.go @@ -207,8 +207,8 @@ func (bpa *WhiteListApi) Del(c *gin.Context) { } else { if whiteListItem.Deleted == 1 { c.JSON(http.StatusOK, gin.H{ - "code": 0, - "message": "", + "code": 2, + "message": "无法查到记录", }) return diff --git a/server/marketserver/api/v1/user/user.go b/server/marketserver/api/v1/user/user.go index 7c6667a0..524b2997 100644 --- a/server/marketserver/api/v1/user/user.go +++ b/server/marketserver/api/v1/user/user.go @@ -118,7 +118,7 @@ func (this *UserApi) Info(c *gin.Context) { if err != nil { return } - for ds.Next() { + if ds.Next() { diamond += q5.ToFloat64(ds.GetByIndex(0)) } }) diff --git a/server/marketserver/service/user.go b/server/marketserver/service/user.go index 117b1277..4992acb7 100644 --- a/server/marketserver/service/user.go +++ b/server/marketserver/service/user.go @@ -1,22 +1,40 @@ package service import ( - //"strings" + "f5" + "main/constant" + "q5" ) +//"strings" + type user struct { } -func (this *user) init(){ +func (this *user) init() { } -func (this *user) unInit(){ +func (this *user) unInit() { } func (this *user) InBlackList(userIdentity string) (bool, error) { - /* - if strings.ToLower(userIdentity) == strings.ToLower("0x52f01e8791cb558c93ee0c59ea5ff5d79fc82044") { + if userIdentity == "" { return true, nil - }*/ - return false, nil + } + + var queryerr error + blocked := false + f5.GetGoStyleDb().RawQuery( + constant.CONF_DB, + "SELECT * FROM t_blockplayer WHERE 1=1 AND account_id = ?", + []string{userIdentity}, + func(err error, ds *f5.DataSet) { + if err != nil { + queryerr = err + return + } + + blocked = ds.Next() && q5.SafeToInt32(ds.GetByName("blocked")) != 0 && q5.SafeToInt32(ds.GetByName("deleted")) == 0 + }) + return blocked, queryerr } From b0d6db0f8ae0197c2e3141a7371692993993e9fc Mon Sep 17 00:00:00 2001 From: yangduo Date: Tue, 27 Aug 2024 11:08:51 +0800 Subject: [PATCH 27/28] recharge query --- server/adminserver/api/v1/system/player.go | 49 +++++++++++++++++++ .../adminserver/model/system/rechargeorder.go | 31 ++++++++++++ .../adminserver/router/system/sys_player.go | 1 + 3 files changed, 81 insertions(+) create mode 100644 server/adminserver/model/system/rechargeorder.go diff --git a/server/adminserver/api/v1/system/player.go b/server/adminserver/api/v1/system/player.go index 70004ebe..67e954c9 100644 --- a/server/adminserver/api/v1/system/player.go +++ b/server/adminserver/api/v1/system/player.go @@ -136,6 +136,14 @@ func (pai *PlayerApi) BagQuery(c *gin.Context) { return } + if len(reqJson.Account_id) > 0xFF { + c.JSON(http.StatusOK, gin.H{ + "code": 1, + "message": "输入过长", + }) + return + } + cursor := q5.ToInt64(c.DefaultQuery("cursor", "")) filterstr := " account_id = '" + reqJson.Account_id + "' " sql := fmt.Sprintf(`SELECT * FROM t_bag WHERE idx > %d AND %s `, cursor, filterstr) @@ -157,6 +165,14 @@ func (pai *PlayerApi) HeroesQuery(c *gin.Context) { return } + if len(reqJson.Account_id) > 0xFF { + c.JSON(http.StatusOK, gin.H{ + "code": 1, + "message": "输入过长", + }) + return + } + cursor := q5.ToInt64(c.DefaultQuery("cursor", "")) filterstr := " account_id = '" + reqJson.Account_id + "' " sql := fmt.Sprintf(`SELECT * FROM t_hero WHERE idx > %d AND %s `, cursor, filterstr) @@ -264,3 +280,36 @@ func (pai *PlayerApi) GameMallQuery(c *gin.Context) { return p }) } + +func (pai *PlayerApi) RechargeQuery(c *gin.Context) { + type RechargeQueryForm struct { + Identity string `binding:"required" json:"identity"` + } + + reqJson := RechargeQueryForm{} + if !checkparam(&reqJson, c) { + return + } + + if len(reqJson.Identity) > 0xFF { + c.JSON(http.StatusOK, gin.H{ + "code": 1, + "message": "输入过长", + }) + return + } + + cursor := q5.ToInt64(c.DefaultQuery("cursor", "")) + filterstr := + " (receiver_account_id = '" + reqJson.Identity + + "' OR account_address = '" + reqJson.Identity + + "' OR passport_address = '" + reqJson.Identity + + "' OR lower_case_email = '" + reqJson.Identity + "')" + sql := fmt.Sprintf(`SELECT * FROM t_recharge_order WHERE idx > %d AND %s `, cursor, filterstr) + + query(constant.BCNFT_DB, cursor, sql, c, func(ds *f5.DataSet) interface{} { + p := new(system.RechargeOrder) + f5.UnmarshalModel(ds, p) + return p + }) +} diff --git a/server/adminserver/model/system/rechargeorder.go b/server/adminserver/model/system/rechargeorder.go new file mode 100644 index 00000000..adcb6267 --- /dev/null +++ b/server/adminserver/model/system/rechargeorder.go @@ -0,0 +1,31 @@ +package system + +type RechargeOrder struct { + Idx int64 `gorm:"column:idx" json:"idx"` + Order_id string `gorm:"column:order_id;comment:订单id" json:"order_id"` + Short_Order_id string `gorm:"column:short_order_id;comment:短订单id" json:"short_order_id"` + Account_address string `gorm:"column:account_address;comment:钱包地址" json:"account_address"` + Passport_address string `gorm:"column:passport_address;comment:passport地址" json:"passport_address"` + Currency_address string `gorm:"column:currency_address;comment:货币地址" json:"currency_address"` + Currency_name string `gorm:"column:currency_name;comment:货币名称" json:"currency_name"` + Item_id int `gorm:"column:item_id;comment:item_id" json:"item_id"` + Item_num int64 `gorm:"column:item_num;comment:item_num" json:"item_num"` + Price string `gorm:"column:price;comment:price" json:"price"` + Createtime int `gorm:"column:createtime;comment:创建时间" json:"createtime"` + Modifytime int `gorm:"column:modifytime;comment:修改时间" json:"modifytime"` + Diamond float64 `gorm:"column:diamond;comment:diamond" json:"diamond"` + Pay_status int `gorm:"column:pay_status;comment:0:支付中 1:支付成功" json:"pay_status"` + Pay_time int `gorm:"column:pay_time;comment:支付成功时间" json:"pay_time"` + Delivery_status int `gorm:"column:delivery_status;comment:0:未发货 1:发货成功" json:"delivery_status"` + Delivery_time int `gorm:"column:delivery_time;comment:发货成功时间" json:"delivery_time"` + Receiver_account_id string `gorm:"column:receiver_account_id;comment:收货人account_id" json:"receiver_account_id"` + Net_id int64 `gorm:"column:net_id;comment:net_id" json:"net_id"` + Txhash string `gorm:"column:txhash;comment:txhash" json:"txhash"` + Lower_case_email string `gorm:"column:lower_case_email;comment:lower_case_email" json:"lower_case_email"` + Present_diamond float64 `gorm:"column:present_diamond;comment:充值赠送钻石" json:"present_diamond"` + Return_contribution float64 `gorm:"column:return_contribution;comment:return_contribution" json:"return_contribution"` +} + +func (this *RechargeOrder) TableName() string { + return "t_recharge_rder" +} diff --git a/server/adminserver/router/system/sys_player.go b/server/adminserver/router/system/sys_player.go index aa5f74bc..8ec419ef 100644 --- a/server/adminserver/router/system/sys_player.go +++ b/server/adminserver/router/system/sys_player.go @@ -19,5 +19,6 @@ func (pr *PlayerRouter) InitPlayerRouter(priRouter *gin.RouterGroup) { group.POST("goldbullionquery", middleware.Permission("api/v1/player/goldbullionquery", api.GoldBullionQuery)) group.POST("ticketconsumequery", middleware.Permission("api/v1/player/ticketconsumequery", api.TicketConsumeQuery)) group.POST("gamemallquery", middleware.Permission("api/v1/player/gamemallquery", api.GameMallQuery)) + group.POST("rechargequery", middleware.Permission("api/v1/player/rechargequery", api.RechargeQuery)) } } From a1cd0acd2538494bc5cffa2bcfc36af2cbb7e078 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 27 Aug 2024 14:05:54 +0800 Subject: [PATCH 28/28] 1 --- server/light_backtask/task/taskmgr.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/light_backtask/task/taskmgr.go b/server/light_backtask/task/taskmgr.go index 42cb72d1..aa00ce33 100644 --- a/server/light_backtask/task/taskmgr.go +++ b/server/light_backtask/task/taskmgr.go @@ -9,7 +9,7 @@ type taskMgr struct { sysMail repairOrder refreshMeta - contribution + //contribution chainActivity recharge } @@ -20,7 +20,7 @@ func (this *taskMgr) Init() { this.sysMail.init() this.repairOrder.init() //this.refreshMeta.init() - this.contribution.init() + //this.contribution.init() this.chainActivity.init() this.recharge.init() } @@ -28,7 +28,7 @@ func (this *taskMgr) Init() { func (this *taskMgr) UnInit() { this.recharge.unInit() this.chainActivity.unInit() - this.contribution.unInit() + //this.contribution.unInit() //this.refreshMeta.unInit() this.repairOrder.unInit() this.sysMail.unInit()