上分下分修改
This commit is contained in:
parent
90d76a17c8
commit
31794d1f1e
|
@ -262,7 +262,7 @@ type PlatfromUpScoreReq struct {
|
||||||
Username string `json:"username"`
|
Username string `json:"username"`
|
||||||
Channel string `json:"channel"`
|
Channel string `json:"channel"`
|
||||||
Timestamp int64 `json:"timestamp"`
|
Timestamp int64 `json:"timestamp"`
|
||||||
Count int64 `json:"count"`
|
Count string `json:"count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 上分返回
|
// 上分返回
|
||||||
|
|
|
@ -2984,8 +2984,12 @@ func init() {
|
||||||
player := PlayerMgrSington.GetPlayerByAccount(msg.Username)
|
player := PlayerMgrSington.GetPlayerByAccount(msg.Username)
|
||||||
|
|
||||||
var remainNum int64
|
var remainNum int64
|
||||||
var addcoin int64 = msg.Count
|
var addcoin int64
|
||||||
var logtype = int32(common.GainWayPlatformUpScore)
|
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 {
|
if player != nil {
|
||||||
|
@ -3016,8 +3020,8 @@ func init() {
|
||||||
SnID: player.SnId,
|
SnID: player.SnId,
|
||||||
Channel: player.Channel,
|
Channel: player.Channel,
|
||||||
ChangeType: common.LoginTypePlatformToken,
|
ChangeType: common.LoginTypePlatformToken,
|
||||||
ChangeNum: msg.Count,
|
ChangeNum: addcoin,
|
||||||
RemainNum: remainNum + msg.Count,
|
RemainNum: remainNum + addcoin,
|
||||||
Add: 0,
|
Add: 0,
|
||||||
LogType: logtype,
|
LogType: logtype,
|
||||||
GameID: 0,
|
GameID: 0,
|
||||||
|
@ -3038,9 +3042,10 @@ func init() {
|
||||||
|
|
||||||
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
||||||
pack.Message = "返回成功"
|
pack.Message = "返回成功"
|
||||||
|
pack.Success = true
|
||||||
|
|
||||||
if data != nil {
|
if data != nil {
|
||||||
pack.Success = true
|
pack.Success = false
|
||||||
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
||||||
pack.Message = data.(error).Error()
|
pack.Message = data.(error).Error()
|
||||||
} else {
|
} else {
|
||||||
|
@ -3048,7 +3053,6 @@ func init() {
|
||||||
player.SendDiffData()
|
player.SendDiffData()
|
||||||
}
|
}
|
||||||
|
|
||||||
pack.Success = true
|
|
||||||
pack.Data.Count = player.Coin
|
pack.Data.Count = player.Coin
|
||||||
|
|
||||||
jsonDataRsp, err = json.Marshal(pack)
|
jsonDataRsp, err = json.Marshal(pack)
|
||||||
|
@ -3076,8 +3080,8 @@ func init() {
|
||||||
SnID: findPlayer.SnId,
|
SnID: findPlayer.SnId,
|
||||||
Channel: findPlayer.Channel,
|
Channel: findPlayer.Channel,
|
||||||
ChangeType: common.LoginTypePlatformToken,
|
ChangeType: common.LoginTypePlatformToken,
|
||||||
ChangeNum: msg.Count,
|
ChangeNum: addcoin,
|
||||||
RemainNum: remainNum + msg.Count,
|
RemainNum: remainNum + addcoin,
|
||||||
Add: 0,
|
Add: 0,
|
||||||
LogType: logtype,
|
LogType: logtype,
|
||||||
GameID: 0,
|
GameID: 0,
|
||||||
|
@ -3107,14 +3111,14 @@ func init() {
|
||||||
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
}), task.CompleteNotifyWrapper(func(data interface{}, t task.Task) {
|
||||||
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
||||||
pack.Message = "返回成功"
|
pack.Message = "返回成功"
|
||||||
|
pack.Success = true
|
||||||
|
|
||||||
if data != nil {
|
if data != nil {
|
||||||
pack.Success = true
|
pack.Success = false
|
||||||
pack.Code = int(webapiproto.TagCode_FAILED)
|
pack.Code = int(webapiproto.TagCode_FAILED)
|
||||||
pack.Message = data.(error).Error()
|
pack.Message = data.(error).Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
pack.Success = true
|
|
||||||
pack.Data.Count = remainNum
|
pack.Data.Count = remainNum
|
||||||
|
|
||||||
jsonDataRsp, err = json.Marshal(pack)
|
jsonDataRsp, err = json.Marshal(pack)
|
||||||
|
@ -3149,12 +3153,14 @@ func init() {
|
||||||
var jsonDataRsp []byte
|
var jsonDataRsp []byte
|
||||||
player := PlayerMgrSington.GetPlayerByAccount(msg.Username)
|
player := PlayerMgrSington.GetPlayerByAccount(msg.Username)
|
||||||
|
|
||||||
|
var remainNum int64
|
||||||
|
var addcoin int64
|
||||||
|
var logtype = int32(common.GainWayPlatformDownScore)
|
||||||
|
|
||||||
//玩家在线
|
//玩家在线
|
||||||
if player != nil {
|
if player != nil {
|
||||||
var remainNum int64
|
|
||||||
var addcoin int64 = -player.Coin
|
|
||||||
var logtype = int32(common.GainWayPlatformDownScore)
|
|
||||||
|
|
||||||
|
addcoin = -player.Coin
|
||||||
remainNum = player.Coin
|
remainNum = player.Coin
|
||||||
platform := player.Platform
|
platform := player.Platform
|
||||||
//玩家在游戏内
|
//玩家在游戏内
|
||||||
|
@ -3203,17 +3209,17 @@ func init() {
|
||||||
|
|
||||||
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
||||||
pack.Message = "返回成功"
|
pack.Message = "返回成功"
|
||||||
|
pack.Success = true
|
||||||
|
|
||||||
if data != nil {
|
if data != nil {
|
||||||
pack.Success = true
|
pack.Success = false
|
||||||
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
pack.Code = int(webapiproto.TagCode_FAILED)
|
||||||
pack.Message = data.(error).Error()
|
pack.Message = data.(error).Error()
|
||||||
} else {
|
} else {
|
||||||
player.Coin += addcoin
|
player.Coin += addcoin
|
||||||
player.SendDiffData()
|
player.SendDiffData()
|
||||||
}
|
}
|
||||||
|
|
||||||
pack.Success = true
|
|
||||||
pack.Data.Count = 0
|
pack.Data.Count = 0
|
||||||
|
|
||||||
jsonDataRsp, err = json.Marshal(pack)
|
jsonDataRsp, err = json.Marshal(pack)
|
||||||
|
@ -3221,6 +3227,74 @@ func init() {
|
||||||
logger.Logger.Errorf("/api/platform/downscore err: %v", err)
|
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.TransRep.RetFiels = jsonDataRsp
|
||||||
tNode.Resume()
|
tNode.Resume()
|
||||||
}), "/api/platform/downscore").Start()
|
}), "/api/platform/downscore").Start()
|
||||||
|
|
Loading…
Reference in New Issue