From 4ffdb2807586a0a7be3edf3e3119ef6c375cdcf8 Mon Sep 17 00:00:00 2001 From: "DESKTOP-45ANQ2C\\unis" <121212121@qq.com> Date: Tue, 31 Dec 2024 16:09:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=91=E9=97=B2=E5=B9=B3=E5=8F=B0=E6=AF=8F?= =?UTF-8?q?=E5=B1=80=E8=AF=A6=E6=83=85=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbproxy/svc/l_coinlog.go | 15 ++++++++++++ gamesrv/base/player.go | 2 ++ model/coinlog.go | 31 +++++++++++++++++++++++ webapi/deprecated.go | 19 +++++++++++--- worldsrv/action_player.go | 1 + worldsrv/player.go | 3 +++ worldsrv/task_login.go | 3 +++ worldsrv/trascate_webapi.go | 49 ++++++++++++++++++++++++++++++++++--- 8 files changed, 117 insertions(+), 6 deletions(-) diff --git a/dbproxy/svc/l_coinlog.go b/dbproxy/svc/l_coinlog.go index 25e7811..dfa253f 100644 --- a/dbproxy/svc/l_coinlog.go +++ b/dbproxy/svc/l_coinlog.go @@ -2,6 +2,7 @@ package svc import ( "errors" + "mongo.games.com/game/common" "net/rpc" "time" @@ -173,6 +174,20 @@ func (svc *CoinLogSvc) UpdateCoinLogRemark(args *model.UpdateCoinLogRemarkArg, r return } +func (svc *CoinLogSvc) GetCoinLogAllInTime(args *model.GetCoinLogGameReq, ret *model.GetCoinLogGameRet) (err error) { + + plt := args.Plt + startts := args.StartTs + endts := args.EndTs + billType := args.BillType // 0金币 1钻石 + + logtypeConds := [...]int32{common.GainWayPlatformUpScore, common.GainWayPlatformUpScore} + ret.Count, _ = CoinLogsCollection(plt).Find(bson.M{"cointype": billType, "ts": bson.M{"$gte": startts, "$lte": endts}}).Count() + err = CoinLogsCollection(plt).Find(bson.M{"cointype": billType, "logtype": bson.M{"$nin": logtypeConds}, "ts": bson.M{"$gte": startts, "$lte": endts}}).Sort("-time").All(&ret.Logs) + + return +} + func init() { rpc.Register(new(CoinLogSvc)) } diff --git a/gamesrv/base/player.go b/gamesrv/base/player.go index 0bf54af..04918fd 100644 --- a/gamesrv/base/player.go +++ b/gamesrv/base/player.go @@ -461,6 +461,7 @@ func (this *Player) AddCoin(num int64, gainWay int32, syncFlag int, oper, remark log := model.NewCoinLogEx(&model.CoinLogParam{ Platform: this.Platform, SnID: this.SnId, + UserName: this.Username, Channel: this.Channel, ChangeType: common.BillTypeCoin, ChangeNum: num, @@ -544,6 +545,7 @@ func (this *Player) AddCoinAsync(num int64, gainWay int32, notifyC, broadcast bo log := model.NewCoinLogEx(&model.CoinLogParam{ Platform: this.Platform, SnID: this.SnId, + UserName: this.Username, Channel: this.Channel, ChangeType: common.BillTypeCoin, ChangeNum: num, diff --git a/model/coinlog.go b/model/coinlog.go index fcba59a..bdc91f3 100644 --- a/model/coinlog.go +++ b/model/coinlog.go @@ -21,6 +21,7 @@ var COINEX_GLOBAL_SEQ = int64(0) type CoinLog struct { LogId bson.ObjectId `bson:"_id"` SnId int32 //玩家id + UserName string // 账号 Platform string //平台名称 Channel string //渠道名称 Promoter string //推广员 @@ -48,6 +49,7 @@ type CoinLog struct { type CoinLogV1 struct { LogId bson.ObjectId `bson:"_id"` SnId int32 //玩家id + UserName string // 账号 Platform string //平台名称 Channel string //渠道名称 Promoter string //推广员 @@ -76,6 +78,7 @@ func NewCoinLog() *CoinLog { type CoinLogParam struct { Platform string // 平台id SnID int32 // 玩家id + UserName string // 账号 Channel string // 渠道 ChangeType int32 // 变化类型 common.BillTypeCoin 金币 common.BillTypeDiamond 钻石 ChangeNum int64 // 变化数量 @@ -94,6 +97,7 @@ func NewCoinLogEx(param *CoinLogParam) *CoinLog { cl := NewCoinLog() cl.Platform = param.Platform cl.SnId = param.SnID + cl.UserName = param.UserName cl.Channel = param.Channel cl.Count = param.ChangeNum cl.Oper = param.Operator @@ -126,6 +130,7 @@ func NewCoinLogExV1(param *CoinLogParam) *CoinLogV1 { cl := CoinLogV1{ LogId: bson.NewObjectId(), SnId: param.SnID, + UserName: param.UserName, Platform: param.Platform, Channel: "", Promoter: "", @@ -332,3 +337,29 @@ func UpdateCoinLogRemark(plt string, id bson.ObjectId, remark string) error { } return err } + +func GetCoinAllLogInTime(plt string, billType int, startts, endts int64, fromIndex, toIndex int) (logs []CoinLog, count int, err error) { + if rpcCli == nil { + logger.Logger.Error("model.GetCoinLogGame rpcCli == nil") + return + } + + args := &GetCoinLogGameReq{ + Plt: plt, + BillType: billType, + FromIdx: fromIndex, + ToIdx: toIndex, + StartTs: startts, + EndTs: endts, + } + var ret GetCoinLogGameRet + err = rpcCli.CallWithTimeout("CoinLogSvc.GetCoinLogAllInTime", args, &ret, time.Second*30) + if err != nil { + logger.Logger.Warn("GetCoinLogGame error:", err) + return + } + + logs = ret.Logs + count = ret.Count + return +} diff --git a/webapi/deprecated.go b/webapi/deprecated.go index 041c461..c2b2149 100644 --- a/webapi/deprecated.go +++ b/webapi/deprecated.go @@ -312,17 +312,30 @@ type PlatfromPlayerStatusRsp struct { // 查询玩家游戏状态请求 type PlatfromGamedetailReq struct { - Username string `json:"username"` Channel string `json:"channel"` Timestamp string `json:"timestamp"` + Start string `json:"start"` + End string `json:"end"` +} + +type PlatfromPlayerScoreInfo struct { + SnId int32 `json:"snid"` //用户Id + UserName string `json:"username"` // 账号 + BeforeCount int64 `json:"beforecount"` //账号变化前数量 + Count int64 `json:"count"` //帐变数量 + RestCount int64 `json:"resetcount"` //余额 + CoinAdd int64 `json:"coinadd"` //金币加成 + BaseCoin int64 `json:"basecoin"` //底分 + LogType int32 `json:"logtype"` //账变类型 + Remark string `json:"remark"` //备注 + GameEndTime string `json:"gameendtime"` //游戏结束时间 } // 查询游戏状态返回 type PlatfromGamedetaiRsp struct { Code int `json:"code"` Data struct { - In int `json:"in"` //当局投入 - Out int `json:"out"` //当局收入 + PlayersInfo []PlatfromPlayerScoreInfo `json:"playersinfo"` } `json:"data"` Message string `json:"message"` Success bool `json:"success"` diff --git a/worldsrv/action_player.go b/worldsrv/action_player.go index 8af5823..0ddc827 100644 --- a/worldsrv/action_player.go +++ b/worldsrv/action_player.go @@ -1436,6 +1436,7 @@ func (this *CSPlayerRegisterHandler) Process(s *netlib.Session, packetid int, da log := model.NewCoinLogEx(&model.CoinLogParam{ Platform: pi.Platform, SnID: pi.SnId, + UserName: pi.Username, Channel: pi.Channel, ChangeType: common.BillTypeCoin, ChangeNum: int64(model.GameParamData.NewPlayerCoin), diff --git a/worldsrv/player.go b/worldsrv/player.go index db18a4a..724edf0 100644 --- a/worldsrv/player.go +++ b/worldsrv/player.go @@ -1414,6 +1414,7 @@ func (this *Player) AddDiamond(num, add int64, gainWay int32, oper, remark strin log := model.NewCoinLogEx(&model.CoinLogParam{ Platform: this.Platform, SnID: this.SnId, + UserName: this.Username, Channel: this.Channel, ChangeType: common.BillTypeDiamond, ChangeNum: num, @@ -1469,6 +1470,7 @@ func (this *Player) AddCoin(num, add int64, gainWay int32, oper, remark string) log := model.NewCoinLogEx(&model.CoinLogParam{ Platform: this.Platform, SnID: this.SnId, + UserName: this.Username, Channel: this.Channel, ChangeType: common.BillTypeCoin, ChangeNum: num, @@ -1524,6 +1526,7 @@ func (this *Player) AddCoinAsync(num, add int64, gainWay int32, oper, remark str log := model.NewCoinLogEx(&model.CoinLogParam{ Platform: this.Platform, SnID: this.SnId, + UserName: this.Username, Channel: this.Channel, ChangeType: common.BillTypeCoin, ChangeNum: num, diff --git a/worldsrv/task_login.go b/worldsrv/task_login.go index facf7ed..3fcd7fe 100644 --- a/worldsrv/task_login.go +++ b/worldsrv/task_login.go @@ -227,6 +227,7 @@ func (t *TaskLogin) Call(o *basic.Object) interface{} { log := model.NewCoinLogEx(&model.CoinLogParam{ Platform: playerData.Platform, SnID: playerData.SnId, + UserName: playerData.Username, Channel: playerData.Channel, ChangeType: common.BillTypeCoin, ChangeNum: int64(model.GameParamData.NewPlayerCoin), @@ -260,6 +261,7 @@ func (t *TaskLogin) Call(o *basic.Object) interface{} { log := model.NewCoinLogEx(&model.CoinLogParam{ Platform: playerData.Platform, SnID: playerData.SnId, + UserName: playerData.Username, Channel: playerData.Channel, ChangeType: common.BillTypeCoin, ChangeNum: coin, @@ -287,6 +289,7 @@ func (t *TaskLogin) Call(o *basic.Object) interface{} { log := model.NewCoinLogEx(&model.CoinLogParam{ Platform: playerData.Platform, SnID: playerData.SnId, + UserName: playerData.Username, Channel: playerData.Channel, ChangeType: common.BillTypeDiamond, ChangeNum: diamond, diff --git a/worldsrv/trascate_webapi.go b/worldsrv/trascate_webapi.go index 1012d72..ee835ae 100644 --- a/worldsrv/trascate_webapi.go +++ b/worldsrv/trascate_webapi.go @@ -236,6 +236,7 @@ func init() { coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ Platform: player.Platform, SnID: player.SnId, + UserName: player.Username, Channel: player.Channel, ChangeType: msg.GetLogType(), ChangeNum: msg.GetGold(), @@ -322,6 +323,7 @@ func init() { coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ Platform: findPlayer.Platform, SnID: findPlayer.SnId, + UserName: findPlayer.Username, Channel: findPlayer.Channel, ChangeType: msg.GetLogType(), ChangeNum: msg.GetGold(), @@ -3022,6 +3024,7 @@ func init() { coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ Platform: player.Platform, SnID: player.SnId, + UserName: player.Username, Channel: player.Channel, ChangeType: common.BillTypeCoin, ChangeNum: addcoin, @@ -3031,6 +3034,8 @@ func init() { GameID: 0, GameFreeID: 0, BaseCoin: 0, + Operator: "休闲平台", + Remark: "在线平台上分", }) task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { @@ -3083,6 +3088,7 @@ func init() { coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ Platform: findPlayer.Platform, SnID: findPlayer.SnId, + UserName: msg.Username, Channel: findPlayer.Channel, ChangeType: common.BillTypeCoin, ChangeNum: addcoin, @@ -3092,6 +3098,8 @@ func init() { GameID: 0, GameFreeID: 0, BaseCoin: 0, + Operator: "休闲平台", + Remark: "不在线平台上分", }) err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addcoin, @@ -3187,6 +3195,7 @@ func init() { coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ Platform: player.Platform, SnID: player.SnId, + UserName: player.Username, Channel: player.Channel, ChangeType: common.BillTypeCoin, ChangeNum: -player.Coin, @@ -3196,6 +3205,8 @@ func init() { GameID: 0, GameFreeID: 0, BaseCoin: 0, + Operator: "休闲平台", + Remark: "在线平台下分", }) task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { @@ -3251,6 +3262,7 @@ func init() { coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ Platform: findPlayer.Platform, SnID: findPlayer.SnId, + UserName: msg.Username, Channel: findPlayer.Channel, ChangeType: common.BillTypeCoin, ChangeNum: addcoin, @@ -3260,6 +3272,8 @@ func init() { GameID: 0, GameFreeID: 0, BaseCoin: 0, + Operator: "休闲平台", + Remark: "不在线平台下分", }) err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addcoin, @@ -3398,12 +3412,41 @@ func init() { logger.Logger.Tracef("/api/platform/getgamedetailed %v", pack) - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - pack.Success = true - pack.Message = "返回成功" + startTs, err := strconv.ParseInt(msg.Start, 10, 64) + if err != nil { + logger.Logger.Error("strconv.ParseInt error:", err) + return common.ResponseTag_ParamError, jsonDataRsp + } + endTs, err := strconv.ParseInt(msg.End, 10, 64) + if err != nil { + logger.Logger.Error("strconv.ParseInt error:", err) + return common.ResponseTag_ParamError, jsonDataRsp + } + + var logs []model.CoinLog + task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + logs, _, err = model.GetCoinAllLogInTime("1", common.BillTypeCoin, startTs, endTs, 0, 0) return nil }), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) { + for _, v := range logs { + pack.Data.PlayersInfo = append(pack.Data.PlayersInfo, webapi.PlatfromPlayerScoreInfo{ + SnId: v.SnId, + UserName: v.UserName, + Count: v.Count, + RestCount: v.RestCount, + CoinAdd: v.CoinAdd, + BaseCoin: v.BaseCoin, + LogType: v.LogType, + Remark: v.Remark, + BeforeCount: v.RestCount + v.Count, + GameEndTime: v.Time.Format(time.DateTime), + }) + } + + pack.Code = int(webapiproto.TagCode_SUCCESS) + pack.Success = true + pack.Message = "返回成功" jsonDataRsp, err = json.Marshal(pack) if err != nil {