平台查询状态
This commit is contained in:
parent
31794d1f1e
commit
84005dd69c
|
@ -357,12 +357,14 @@ func init() {
|
|||
|
||||
// 平台玩家注册账号
|
||||
admin.MyAdminApp.Route("/api/platform/createUser", PlatformSrvApi)
|
||||
|
||||
// 平台玩家注册账号
|
||||
// 平台玩家上分
|
||||
admin.MyAdminApp.Route("/api/platform/upscore", PlatformSrvApi)
|
||||
|
||||
// 平台玩家注册账号
|
||||
// 平台玩家下分
|
||||
admin.MyAdminApp.Route("/api/platform/downscore", PlatformSrvApi)
|
||||
// 平台查询游戏状态
|
||||
admin.MyAdminApp.Route("/api/platform/getstatus", PlatformSrvApi)
|
||||
// 平台查询下注信息
|
||||
admin.MyAdminApp.Route("/api/platform/getgamedetailed", PlatformSrvApi)
|
||||
}
|
||||
|
||||
func Stats() map[string]ApiStats {
|
||||
|
|
|
@ -286,7 +286,25 @@ type PlatfromDownScoreReq struct {
|
|||
type PlatfromDownScoreRsp struct {
|
||||
Code int `json:"code"`
|
||||
Data struct {
|
||||
Count int64 `json:"count"`
|
||||
Money int64 `json:"money"`
|
||||
} `json:"data"`
|
||||
Message string `json:"message"`
|
||||
Success bool `json:"success"`
|
||||
}
|
||||
|
||||
// 查询玩家游戏状态请求
|
||||
type PlatfromPlayerStatusReq struct {
|
||||
Username string `json:"username"`
|
||||
Channel string `json:"channel"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
}
|
||||
|
||||
// 查询游戏状态返回
|
||||
type PlatfromPlayerStatusRsp struct {
|
||||
Code int `json:"code"`
|
||||
Data struct {
|
||||
Money int64 `json:"money"`
|
||||
IsOnline bool `json:"isOnline"`
|
||||
} `json:"data"`
|
||||
Message string `json:"message"`
|
||||
Success bool `json:"success"`
|
||||
|
|
|
@ -3220,7 +3220,7 @@ func init() {
|
|||
player.SendDiffData()
|
||||
}
|
||||
|
||||
pack.Data.Count = 0
|
||||
pack.Data.Money = 0
|
||||
|
||||
jsonDataRsp, err = json.Marshal(pack)
|
||||
if err != nil {
|
||||
|
@ -3232,16 +3232,18 @@ func init() {
|
|||
}), "/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)
|
||||
var acc *model.Account
|
||||
acc, err = model.GetAccountByName("1", msg.Username)
|
||||
if acc == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
findPlayer, _ := model.GetPlayerDataBySnId(acc.Platform, int32(acc.SnId), false, true)
|
||||
if findPlayer != nil {
|
||||
|
||||
addcoin = -findPlayer.Coin
|
||||
|
||||
//增加帐变记录
|
||||
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
Platform: findPlayer.Platform,
|
||||
|
@ -3257,7 +3259,6 @@ func init() {
|
|||
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 {
|
||||
|
@ -3288,7 +3289,7 @@ func init() {
|
|||
pack.Message = data.(error).Error()
|
||||
}
|
||||
|
||||
pack.Data.Count = remainNum
|
||||
pack.Data.Money = -addcoin
|
||||
|
||||
jsonDataRsp, err = json.Marshal(pack)
|
||||
if err != nil {
|
||||
|
@ -3305,13 +3306,13 @@ func init() {
|
|||
WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/platform/getstatus", WebAPIHandlerWrapper(
|
||||
func(tNode *transact.TransNode, params []byte) (int, interface{}) {
|
||||
|
||||
var AccountInfo *webapi.PlatfromCreateAccountReq
|
||||
err := json.Unmarshal(params, &AccountInfo)
|
||||
var msg *webapi.PlatfromPlayerStatusReq
|
||||
err := json.Unmarshal(params, &msg)
|
||||
if err != nil {
|
||||
logger.Logger.Error("Unmarshal webapi.PlatfromCreateAccountReq error:", err)
|
||||
logger.Logger.Error("Unmarshal webapi.PlatfromGetStatusReq error:", err)
|
||||
}
|
||||
|
||||
pack := &webapi.PlatfromGameLoginRsp{
|
||||
pack := &webapi.PlatfromPlayerStatusRsp{
|
||||
Success: false,
|
||||
Code: 200,
|
||||
Message: "未知错误",
|
||||
|
@ -3320,12 +3321,19 @@ func init() {
|
|||
logger.Logger.Tracef("/api/platform/getstatus %v", pack)
|
||||
|
||||
var jsonDataRsp []byte
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
pack.Success = true
|
||||
pack.Message = "返回成功"
|
||||
player := PlayerMgrSington.GetPlayerByAccount(msg.Username)
|
||||
|
||||
return nil
|
||||
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
|
||||
//玩家在线
|
||||
if player != nil {
|
||||
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
||||
pack.Message = "返回成功"
|
||||
pack.Success = true
|
||||
|
||||
if player.scene != nil {
|
||||
pack.Data.IsOnline = true
|
||||
}
|
||||
|
||||
pack.Data.Money = player.Coin
|
||||
|
||||
jsonDataRsp, err = json.Marshal(pack)
|
||||
if err != nil {
|
||||
|
@ -3334,7 +3342,37 @@ func init() {
|
|||
|
||||
tNode.TransRep.RetFiels = jsonDataRsp
|
||||
tNode.Resume()
|
||||
}), "/api/platform/getstatus").Start()
|
||||
} else {
|
||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||
|
||||
var acc *model.Account
|
||||
acc, err = model.GetAccountByName("1", msg.Username)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
pack.Data.IsOnline = false
|
||||
|
||||
findPlayer, _ := model.GetPlayerDataBySnId(acc.Platform, int32(acc.SnId), false, true)
|
||||
if findPlayer != nil {
|
||||
pack.Data.Money = findPlayer.Coin
|
||||
}
|
||||
|
||||
return nil
|
||||
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
|
||||
|
||||
pack.Code = int(webapiproto.TagCode_SUCCESS)
|
||||
pack.Success = true
|
||||
pack.Message = "返回成功"
|
||||
|
||||
jsonDataRsp, err = json.Marshal(pack)
|
||||
if err != nil {
|
||||
logger.Logger.Errorf("/api/platform/getstatus err: %v", err)
|
||||
}
|
||||
|
||||
tNode.TransRep.RetFiels = jsonDataRsp
|
||||
tNode.Resume()
|
||||
}), "/api/platform/getstatus").Start()
|
||||
}
|
||||
return common.ResponseTag_TransactYield, jsonDataRsp
|
||||
}))
|
||||
|
||||
|
|
Loading…
Reference in New Issue