diff --git a/mgrsrv/api/webapi_worldsrv.go b/mgrsrv/api/webapi_worldsrv.go index 121270b..1745f1e 100644 --- a/mgrsrv/api/webapi_worldsrv.go +++ b/mgrsrv/api/webapi_worldsrv.go @@ -243,7 +243,7 @@ func init() { admin.MyAdminApp.Route("/api/player/update_tel", WorldSrvApi) // 删除账号 admin.MyAdminApp.Route("/api/player/delete", WorldSrvApi) - //添加道具 + // 添加道具 admin.MyAdminApp.Route("/api/player/AddItem", WorldSrvApi) } diff --git a/worldsrv/trascate_webapi.go b/worldsrv/trascate_webapi.go index a882271..1620b44 100644 --- a/worldsrv/trascate_webapi.go +++ b/worldsrv/trascate_webapi.go @@ -1964,6 +1964,65 @@ func init() { pack.Msg = "no any data" return common.ResponseTag_Ok, pack } + + f := func(plt string, snid int32) { + var alipayAcc, alipayAccName, bankAccount, bankAccName, channelId string + if val, ok := playerMap["AlipayAccount"]; ok { + if str, ok := val.(string); ok { + alipayAcc = str + } + } + if val, ok := playerMap["AlipayAccName"]; ok { + if str, ok := val.(string); ok { + alipayAccName = str + } + } + if val, ok := playerMap["BankAccount"]; ok { + if str, ok := val.(string); ok { + bankAccount = str + } + } + if val, ok := playerMap["BankAccName"]; ok { + if str, ok := val.(string); ok { + bankAccName = str + } + } + if val, ok := playerMap["ChannelId"]; ok { + if str, ok := val.(string); ok { + channelId = str + } + } + + if alipayAcc != "" || alipayAccName != "" { + task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + model.NewBankBindLog(msg.SnId, msg.Platform, model.BankBindLogType_Ali, + alipayAccName, alipayAcc, 2) + return nil + }), nil, "NewBankBindLog").Start() + } + if bankAccount != "" || bankAccName != "" { + task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + model.NewBankBindLog(msg.SnId, msg.Platform, model.BankBindLogType_Bank, + bankAccName, bankAccount, 2) + return nil + }), nil, "NewBankBindLog").Start() + } + if channelId != "" { + task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { + a, err := model.GetAccountBySnid(plt, snid) + if err != nil { + logger.Logger.Errorf("GetAccountBySnid error: %v", err) + return nil + } + a.ChannelId = channelId + if err = model.UpdateAccount(a); err != nil { + logger.Logger.Errorf("UpdateAccount error: %v", err) + } + return nil + }), nil).StartByExecutor("UpdateChannelId") + } + } + pack.Tag = webapiproto.TagCode_SUCCESS player := PlayerMgrSington.GetPlayerBySnId(msg.SnId) if player != nil { @@ -1985,7 +2044,7 @@ func init() { if v.FieldByName(k).CanInterface() { switch f.Type.Kind() { case reflect.Int64, reflect.Int32: - a, _ := strconv.ParseInt((fmt.Sprintf("%v", n)), 10, 64) + a, _ := strconv.ParseInt(fmt.Sprintf("%v", n), 10, 64) s.FieldByName(k).SetInt(a) case reflect.Bool: s.FieldByName(k).SetBool(n.(bool)) @@ -2002,42 +2061,8 @@ func init() { pd = SetInfo(pd, *pd, playerMap) player.dirty = true player.SendDiffData() - var alipayAcc, alipayAccName, bankAccount, bankAccName string - if val, ok := playerMap["AlipayAccount"]; ok { - if str, ok := val.(string); ok { - alipayAcc = str - } - } - if val, ok := playerMap["AlipayAccName"]; ok { - if str, ok := val.(string); ok { - alipayAccName = str - } - } - if val, ok := playerMap["BankAccount"]; ok { - if str, ok := val.(string); ok { - bankAccount = str - } - } - if val, ok := playerMap["BankAccName"]; ok { - if str, ok := val.(string); ok { - bankAccName = str - } - } - if alipayAcc != "" || alipayAccName != "" { - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - model.NewBankBindLog(msg.SnId, msg.Platform, model.BankBindLogType_Ali, - alipayAccName, alipayAcc, 2) - return nil - }), nil, "NewBankBindLog").Start() - } - if bankAccount != "" || bankAccName != "" { - task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} { - model.NewBankBindLog(msg.SnId, msg.Platform, model.BankBindLogType_Bank, - bankAccName, bankAccount, 2) - return nil - }), nil, "NewBankBindLog").Start() - } pack.Msg = "success" + f(pd.Platform, pd.SnId) return common.ResponseTag_Ok, pack } } else { @@ -2053,35 +2078,7 @@ func init() { //直接操作数据库 err := model.UpdatePlayerElement(msg.Platform, msg.SnId, playerMap) if err == nil { - var alipayAcc, alipayAccName, bankAccount, bankAccName string - if val, ok := playerMap["AlipayAccount"]; ok { - if str, ok := val.(string); ok { - alipayAcc = str - } - } - if val, ok := playerMap["AlipayAccName"]; ok { - if str, ok := val.(string); ok { - alipayAccName = str - } - } - if val, ok := playerMap["BankAccount"]; ok { - if str, ok := val.(string); ok { - bankAccount = str - } - } - if val, ok := playerMap["BankAccName"]; ok { - if str, ok := val.(string); ok { - bankAccName = str - } - } - if alipayAcc != "" || alipayAccName != "" { - model.NewBankBindLog(msg.SnId, msg.Platform, model.BankBindLogType_Ali, - alipayAccName, alipayAcc, 2) - } - if bankAccount != "" || bankAccName != "" { - model.NewBankBindLog(msg.SnId, msg.Platform, model.BankBindLogType_Bank, - bankAccName, bankAccount, 2) - } + f(msg.Platform, msg.SnId) } else if err != nil { logger.Logger.Error("UpdatePlayerElement task marshal data error:", err) } @@ -3730,6 +3727,7 @@ func init() { })).StartByExecutor(fmt.Sprint(msg.GetSnid())) return common.ResponseTag_TransactYield, pack })) + WebAPIHandlerMgrSingleton.RegisteWebAPIHandler("/api/player/AddItem", WebAPIHandlerWrapper( func(tNode *transact.TransNode, params []byte) (int, proto.Message) { pack := &webapiproto.SAAddItemById{}