上分下分修改
This commit is contained in:
parent
90d76a17c8
commit
31794d1f1e
|
@ -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"`
|
||||
}
|
||||
|
||||
// 上分返回
|
||||
|
|
|
@ -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)
|
||||
|
||||
//玩家在线
|
||||
if player != nil {
|
||||
var remainNum int64
|
||||
var addcoin int64 = -player.Coin
|
||||
var addcoin int64
|
||||
var logtype = int32(common.GainWayPlatformDownScore)
|
||||
|
||||
//玩家在线
|
||||
if player != nil {
|
||||
|
||||
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()
|
||||
|
|
Loading…
Reference in New Issue