From 2bc17d7a2e359f3bdeb6a81096d96c5119b0becc Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 1 Aug 2024 14:06:01 +0800 Subject: [PATCH] 1 --- server/marketserver/api/v1/recharge/recharge.go | 7 ++++++- server/marketserver/mt/Recharge.go | 2 +- server/marketserver/router/recharge/recharge.go | 3 ++- server/matchserver/common/types.go | 3 +++ server/matchserver/player/player.go | 6 ++++++ server/matchserver/proto/cs_proto.proto | 1 + server/matchserver/team/team.go | 1 + 7 files changed, 20 insertions(+), 3 deletions(-) diff --git a/server/marketserver/api/v1/recharge/recharge.go b/server/marketserver/api/v1/recharge/recharge.go index a7f35892..3f54bea6 100644 --- a/server/marketserver/api/v1/recharge/recharge.go +++ b/server/marketserver/api/v1/recharge/recharge.go @@ -45,7 +45,7 @@ func (ea *RechargeApi) RechargeList(c *gin.Context) { func (this *RechargeApi) Pay(c *gin.Context) { reqJson := struct { NetId int32 `json:"net_id"` - GoodsId string `json:"goods_id"` + GoodsId int32 `json:"goods_id"` AccountAddress string `json:"account_address"` } {} if err := c.ShouldBindJSON(&reqJson); err != nil { @@ -55,6 +55,11 @@ func (this *RechargeApi) Pay(c *gin.Context) { }) return } + goodsMeta := mt.Table.Recharge.GetById(q5.ToInt64(reqJson.GoodsId)) + if goodsMeta == nil { + f5.RspErr(c, 2, "goods id param error") + return + } orderId := q5.ToString(f5.GetApp().NewLockNodeUuid()) params := map[string]string{ "c" : "BcService", diff --git a/server/marketserver/mt/Recharge.go b/server/marketserver/mt/Recharge.go index 8e09f19b..d078a853 100644 --- a/server/marketserver/mt/Recharge.go +++ b/server/marketserver/mt/Recharge.go @@ -10,5 +10,5 @@ type Recharge struct { } type RechargeTable struct { - f5.NameMetaTable[Recharge] + f5.IdMetaTable[Recharge] } diff --git a/server/marketserver/router/recharge/recharge.go b/server/marketserver/router/recharge/recharge.go index 9f9f53ad..34d2cfaa 100644 --- a/server/marketserver/router/recharge/recharge.go +++ b/server/marketserver/router/recharge/recharge.go @@ -2,6 +2,7 @@ package recharge import ( "f5" + "main/middleware" v1 "main/api/v1" ) @@ -11,5 +12,5 @@ func (er *RechargeRouter) InitRouter() { api := v1.ApiGroupApp.RechargeApiGroup f5.GetApp().GetGinEngine().GET("/api/recharge/history/:account_address", api.RechargeApi.RechargeQuery) f5.GetApp().GetGinEngine().GET("/api/recharge/goods", api.RechargeApi.RechargeList) - f5.GetApp().GetGinEngine().GET("/api/recharge/pay", api.RechargeApi.Pay) + f5.GetApp().GetGinEngine().POST("/api/recharge/pay", middleware.JwtAuth, api.RechargeApi.Pay) } diff --git a/server/matchserver/common/types.go b/server/matchserver/common/types.go index ff7a5049..ad983b4b 100644 --- a/server/matchserver/common/types.go +++ b/server/matchserver/common/types.go @@ -34,6 +34,7 @@ type LoginRsp struct { ValidLefttime interface{} `json:"valid_lefttime"` CurrentTimes interface{} `json:"current_times"` TotalTimes interface{} `json:"total_times"` + SkinId interface{} `json:"skin_id"` } `json:"hero_info"` MapInfo *MapInfoRsp `json:"map_info"` } `json:"info"` @@ -63,6 +64,7 @@ type UserRsp struct { ValidLefttime interface{} `json:"valid_lefttime"` CurrentTimes interface{} `json:"current_times"` TotalTimes interface{} `json:"total_times"` + SkinId interface{} `json:"skin_id"` } `json:"hero_info"` } `json:"info"` } @@ -110,6 +112,7 @@ type UpdateBattleInfoRsp struct { ValidLefttime interface{} `json:"valid_lefttime"` CurrentTimes interface{} `json:"current_times"` TotalTimes interface{} `json:"total_times"` + SkinId interface{} `json:"skin_id"` } `json:"hero_info"` } `json:"info"` } diff --git a/server/matchserver/player/player.go b/server/matchserver/player/player.go index f0f16b4e..3a10cd72 100644 --- a/server/matchserver/player/player.go +++ b/server/matchserver/player/player.go @@ -21,6 +21,7 @@ type hero struct { validLeftTime int32 currentTimes int32 totalTimes int32 + skinId int32 } type player struct { @@ -70,6 +71,7 @@ func (this *player) init(req *pendingLoginRequest, rsp *common.LoginRsp){ q5.DuckToSimple(rsp.Info.HeroInfo.ValidLefttime, &this.hero.validLeftTime) q5.DuckToSimple(rsp.Info.HeroInfo.CurrentTimes, &this.hero.currentTimes) q5.DuckToSimple(rsp.Info.HeroInfo.TotalTimes, &this.hero.totalTimes) + q5.DuckToSimple(rsp.Info.HeroInfo.SkinId, &this.hero.skinId) } } @@ -93,6 +95,7 @@ func (this *player) againInit(req *pendingLoginRequest, rsp *common.LoginRsp){ q5.DuckToSimple(rsp.Info.HeroInfo.ValidLefttime, &this.hero.validLeftTime) q5.DuckToSimple(rsp.Info.HeroInfo.CurrentTimes, &this.hero.currentTimes) q5.DuckToSimple(rsp.Info.HeroInfo.TotalTimes, &this.hero.totalTimes) + q5.DuckToSimple(rsp.Info.HeroInfo.SkinId, &this.hero.skinId) } } @@ -217,6 +220,7 @@ func (this *player) FillMFTeamMember(member_pb *cs.MFTeamMember) { member_pb.Hero.Quality = proto.Int32(this.hero.quality) member_pb.Hero.CurrentTimes = proto.Int32(this.hero.currentTimes) member_pb.Hero.TotalTimes = proto.Int32(this.hero.totalTimes) + member_pb.Hero.SkinId = proto.Int32(this.hero.skinId) } member_pb.State = proto.Int32(this.state) if this.IsOnline() { @@ -434,6 +438,7 @@ func (this *player) CMRefreshUser(hdr *f5.MsgHdr, msg *cs.CMRefreshUser) { q5.DuckToSimple(rspObj.Info.HeroInfo.ValidLefttime, &this.hero.validLeftTime) q5.DuckToSimple(rspObj.Info.HeroInfo.CurrentTimes, &this.hero.currentTimes) q5.DuckToSimple(rspObj.Info.HeroInfo.TotalTimes, &this.hero.totalTimes) + q5.DuckToSimple(rspObj.Info.HeroInfo.SkinId, &this.hero.skinId) } if this.GetTeam() != nil { this.GetTeam().SendUpdateNotify() @@ -486,6 +491,7 @@ func (this *player) updateChoose(skillId int32, heroUniId string, q5.DuckToSimple(rspObj.Info.HeroInfo.ValidLefttime, &this.hero.validLeftTime) q5.DuckToSimple(rspObj.Info.HeroInfo.CurrentTimes, &this.hero.currentTimes) q5.DuckToSimple(rspObj.Info.HeroInfo.TotalTimes, &this.hero.totalTimes) + q5.DuckToSimple(rspObj.Info.HeroInfo.SkinId, &this.hero.skinId) } cb(0, "") diff --git a/server/matchserver/proto/cs_proto.proto b/server/matchserver/proto/cs_proto.proto index bc6f3f15..d1840a87 100644 --- a/server/matchserver/proto/cs_proto.proto +++ b/server/matchserver/proto/cs_proto.proto @@ -112,6 +112,7 @@ message MFHero optional int32 quality = 2; //英雄品阶 optional int32 current_times = 3; //当前打金次数 optional int32 total_times = 4; //总打金次数 + optional int32 skin_id = 5; //皮肤id } //加入房间消息 diff --git a/server/matchserver/team/team.go b/server/matchserver/team/team.go index 2755a80b..573d8aec 100644 --- a/server/matchserver/team/team.go +++ b/server/matchserver/team/team.go @@ -56,6 +56,7 @@ func (this* robot) FillMFTeamMember(member_pb *cs.MFTeamMember) { member_pb.Hero.Quality = proto.Int32(0) member_pb.Hero.CurrentTimes = proto.Int32(0) member_pb.Hero.TotalTimes = proto.Int32(0) + member_pb.Hero.SkinId = proto.Int32(0) } member_pb.State = proto.Int32(0) member_pb.Online = proto.Int32(1)