休闲平台上分修改

This commit is contained in:
DESKTOP-45ANQ2C\unis 2024-12-13 16:02:13 +08:00
parent a1ecd801e1
commit 358da77924
1 changed files with 70 additions and 18 deletions

View File

@ -2902,6 +2902,8 @@ func init() {
"Platform": "1",
"Channel": AccountInfo.Channel,
"Timestamp": AccountInfo.Timestamp,
"Avatar": AccountInfo.Avatar,
"NickName": AccountInfo.Nickname,
"Exp": time.Now().Add(time.Hour * 24).Unix(),
})
tokenStr, err := token.SignedString([]byte(common.Config.AppId))
@ -2933,7 +2935,7 @@ func init() {
Plt: acc.Platform,
AccId: acc.AccountId.Hex(),
NickName: AccountInfo.Nickname,
HeadUrl: AccountInfo.Avater,
HeadUrl: AccountInfo.Avatar,
})
if pi == nil || tf == false {
@ -2965,37 +2967,87 @@ func init() {
WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/platform/upscore", WebAPIHandlerWrapper(
func(tNode *transact.TransNode, params []byte) (int, interface{}) {
var AccountInfo *webapi.PlatfromCreateAccountReq
err := json.Unmarshal(params, &AccountInfo)
var msg *webapi.PlatfromUpScoreReq
err := json.Unmarshal(params, &msg)
if err != nil {
logger.Logger.Error("Unmarshal webapi.PlatfromCreateAccountReq error:", err)
logger.Logger.Error("Unmarshal webapi.PlatfromUpScoreReq error:", err)
}
pack := &webapi.PlatfromGameLoginRsp{
logger.Logger.Tracef("/api/platform/upscore upScoreReqInfo%v", msg)
pack := &webapi.PlatfromUpScoreRsp{
Success: false,
Code: 200,
Message: "未知错误",
}
logger.Logger.Tracef("/api/platform/upscore %v", pack)
var jsonDataRsp []byte
player := PlayerMgrSington.GetPlayerByAccount(msg.Username)
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
pack.Success = true
pack.Message = "返回成功"
//玩家在线
if player != nil {
var remainNum int64
var addcoin int64 = msg.Count
var logtype = int32(common.GainWayPlatformUpScore)
return nil
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
remainNum = player.Coin
jsonDataRsp, err = json.Marshal(pack)
if err != nil {
logger.Logger.Errorf("/api/platform/createUser err: %v", err)
platform := player.Platform
//玩家在游戏内
if player.scene != nil {
pack.Code = int(webapiproto.TagCode_FAILED)
pack.Message = "Unsupported!!! because player in scene!"
return common.ResponseTag_ParamError, pack
}
if len(platform) > 0 {
pack.Code = int(webapiproto.TagCode_FAILED)
pack.Message = "player platform forbit!"
return common.ResponseTag_ParamError, pack
}
tNode.TransRep.RetFiels = jsonDataRsp
tNode.Resume()
}), "/api/platform/upscore").Start()
if player.Coin+addcoin < 0 {
pack.Code = int(webapiproto.TagCode_FAILED)
pack.Message = "coin not enough!"
return common.ResponseTag_ParamError, pack
}
//增加帐变记录
coinlogex := model.NewCoinLogEx(&model.CoinLogParam{
Platform: player.Platform,
SnID: player.SnId,
Channel: player.Channel,
ChangeType: common.LoginTypePlatformToken,
ChangeNum: msg.Count,
RemainNum: remainNum + msg.Count,
Add: 0,
LogType: logtype,
GameID: 0,
GameFreeID: 0,
BaseCoin: 0,
})
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
err := model.InsertCoinLog(coinlogex)
if err != nil {
//回滚到对账日志
model.RemoveCoinLogOne(platform, coinlogex.LogId)
logger.Logger.Errorf("model.InsertCoinLogs err:%v log:%v", err, coinlogex)
return err
}
pack.Success = true
pack.Message = "返回成功"
return nil
}), task.CompleteNotifyWrapper(func(i interface{}, t task.Task) {
jsonDataRsp, err = json.Marshal(pack)
if err != nil {
logger.Logger.Errorf("/api/platform/upscore err: %v", err)
}
tNode.TransRep.RetFiels = jsonDataRsp
tNode.Resume()
}), "/api/platform/upscore").Start()
}
return common.ResponseTag_TransactYield, jsonDataRsp
}))