From 31794d1f1e8e68df18ee107027b222994e6a1605 Mon Sep 17 00:00:00 2001 From: "DESKTOP-45ANQ2C\\unis" <121212121@qq.com> Date: Mon, 16 Dec 2024 14:22:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E5=88=86=E4=B8=8B=E5=88=86=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapi/deprecated.go | 2 +- worldsrv/trascate_webapi.go | 104 ++++++++++++++++++++++++++++++------ 2 files changed, 90 insertions(+), 16 deletions(-) diff --git a/webapi/deprecated.go b/webapi/deprecated.go index 657187a..5fc32de 100644 --- a/webapi/deprecated.go +++ b/webapi/deprecated.go @@ -262,7 +262,7 @@ type PlatfromUpScoreReq struct { Username string `json:"username"` Channel string `json:"channel"` Timestamp int64 `json:"timestamp"` - Count int64 `json:"count"` + Count string `json:"count"` } // 上分返回 diff --git a/worldsrv/trascate_webapi.go b/worldsrv/trascate_webapi.go index 0855742..d108330 100644 --- a/worldsrv/trascate_webapi.go +++ b/worldsrv/trascate_webapi.go @@ -2984,8 +2984,12 @@ func init() { player := PlayerMgrSington.GetPlayerByAccount(msg.Username) var remainNum int64 - var addcoin int64 = msg.Count + var addcoin int64 var logtype = int32(common.GainWayPlatformUpScore) + addcoin, err = strconv.ParseInt(msg.Count, 10, 64) + if err != nil { + logger.Logger.Error("Unmarshal webapi.PlatfromUpScoreReq strconv.ParseInt error:", err) + } //玩家在线 if player != nil { @@ -3016,8 +3020,8 @@ func init() { SnID: player.SnId, Channel: player.Channel, ChangeType: common.LoginTypePlatformToken, - ChangeNum: msg.Count, - RemainNum: remainNum + msg.Count, + ChangeNum: addcoin, + RemainNum: remainNum + addcoin, Add: 0, LogType: logtype, GameID: 0, @@ -3038,9 +3042,10 @@ func init() { pack.Code = int(webapiproto.TagCode_SUCCESS) pack.Message = "返回成功" + pack.Success = true if data != nil { - pack.Success = true + pack.Success = false pack.Code = int(webapiproto.TagCode_SUCCESS) pack.Message = data.(error).Error() } else { @@ -3048,7 +3053,6 @@ func init() { player.SendDiffData() } - pack.Success = true pack.Data.Count = player.Coin jsonDataRsp, err = json.Marshal(pack) @@ -3076,8 +3080,8 @@ func init() { SnID: findPlayer.SnId, Channel: findPlayer.Channel, ChangeType: common.LoginTypePlatformToken, - ChangeNum: msg.Count, - RemainNum: remainNum + msg.Count, + ChangeNum: addcoin, + RemainNum: remainNum + addcoin, Add: 0, LogType: logtype, GameID: 0, @@ -3107,14 +3111,14 @@ func init() { }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { pack.Code = int(webapiproto.TagCode_SUCCESS) pack.Message = "返回成功" + pack.Success = true if data != nil { - pack.Success = true + pack.Success = false pack.Code = int(webapiproto.TagCode_FAILED) pack.Message = data.(error).Error() } - pack.Success = true pack.Data.Count = remainNum jsonDataRsp, err = json.Marshal(pack) @@ -3149,12 +3153,14 @@ func init() { var jsonDataRsp []byte player := PlayerMgrSington.GetPlayerByAccount(msg.Username) + var remainNum int64 + var addcoin int64 + var logtype = int32(common.GainWayPlatformDownScore) + //玩家在线 if player != nil { - var remainNum int64 - var addcoin int64 = -player.Coin - var logtype = int32(common.GainWayPlatformDownScore) + addcoin = -player.Coin remainNum = player.Coin platform := player.Platform //玩家在游戏内 @@ -3203,17 +3209,17 @@ func init() { pack.Code = int(webapiproto.TagCode_SUCCESS) pack.Message = "返回成功" + pack.Success = true if data != nil { - pack.Success = true - pack.Code = int(webapiproto.TagCode_SUCCESS) + pack.Success = false + pack.Code = int(webapiproto.TagCode_FAILED) pack.Message = data.(error).Error() } else { player.Coin += addcoin player.SendDiffData() } - pack.Success = true pack.Data.Count = 0 jsonDataRsp, err = json.Marshal(pack) @@ -3221,6 +3227,74 @@ func init() { logger.Logger.Errorf("/api/platform/downscore err: %v", err) } + tNode.TransRep.RetFiels = jsonDataRsp + tNode.Resume() + }), "/api/platform/downscore").Start() + } else { + //玩家不在线 + var acc *model.Account + + acc, err = model.GetAccountByName("1", msg.Username) + if acc == nil { + return common.ResponseTag_ParamError, pack + } + task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + findPlayer, _ := model.GetPlayerDataBySnId("1", int32(acc.SnId), false, true) + if findPlayer != nil { + + //增加帐变记录 + coinlogex := model.NewCoinLogEx(&model.CoinLogParam{ + Platform: findPlayer.Platform, + SnID: findPlayer.SnId, + Channel: findPlayer.Channel, + ChangeType: common.LoginTypePlatformToken, + ChangeNum: addcoin, + RemainNum: remainNum + addcoin, + Add: 0, + LogType: logtype, + GameID: 0, + GameFreeID: 0, + BaseCoin: 0, + }) + + addcoin = -findPlayer.Coin + err := model.UpdatePlayerCoin(findPlayer.Platform, findPlayer.SnId, findPlayer.Coin+addcoin, + findPlayer.Diamond, findPlayer.SafeBoxCoin, findPlayer.CoinPayTs, findPlayer.SafeBoxCoinTs, findPlayer.MoneyPayTotal, findPlayer.ShopID) + if err != nil { + logger.Logger.Errorf("model.UpdatePlayerCoin err:%v.", err) + return nil + } + + //账变记录 + err = model.InsertCoinLog(coinlogex) + if err != nil { + //回滚到对账日志 + model.RemoveCoinLogOne("1", coinlogex.LogId) + logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex) + return err + } + } + + remainNum = findPlayer.Coin + addcoin + return nil + }), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) { + pack.Code = int(webapiproto.TagCode_SUCCESS) + pack.Message = "返回成功" + pack.Success = true + + if data != nil { + pack.Success = false + pack.Code = int(webapiproto.TagCode_FAILED) + pack.Message = data.(error).Error() + } + + pack.Data.Count = remainNum + + jsonDataRsp, err = json.Marshal(pack) + if err != nil { + logger.Logger.Errorf("/api/platform/downscore err: %v", err) + } + tNode.TransRep.RetFiels = jsonDataRsp tNode.Resume() }), "/api/platform/downscore").Start()