diff --git a/dbproxy/svc/u_account.go b/dbproxy/svc/u_account.go index ae8cdab..6529d4c 100644 --- a/dbproxy/svc/u_account.go +++ b/dbproxy/svc/u_account.go @@ -59,6 +59,11 @@ func (svc *AccountSvc) AccountIsExist(args *model.AccIsExistArg, ret *model.AccR } acc := &model.Account{} + defer func() { + // 修改旧数据 + // 补充渠道信息 + svc.setParam(acc) + }() switch args.LoginType { case common.LoginTypeGuest: @@ -229,6 +234,35 @@ func (svc *AccountSvc) AccountIsExist(args *model.AccIsExistArg, ret *model.AccR return nil } +func (svc *AccountSvc) setParam(acc *model.Account) { + if acc == nil || (acc.Channel != "" && acc.Channel != "0") { + return + } + + c := PlayerDataCollection(acc.Platform) + if c == nil { + return + } + p := new(model.PlayerData) + err := c.Find(bson.M{"snid": acc.SnId}).One(p) + if err != nil { + logger.Logger.Errorf("setChannel error:%v", err) + return + } + + c = AccountCollection(acc.Platform) + if c == nil { + return + } + acc.Channel = p.Channel + if acc.Channel != "" { + err = c.Update(bson.M{"_id": acc.AccountId}, bson.D{{"$set", bson.D{{"channel", acc.Channel}}}}) + if err != nil { + logger.Logger.Errorf("setChannel error:%v", err) + } + } +} + func (svc *AccountSvc) AccountTelIsRegiste(args *model.AccIsExistArg, exist *bool) error { caccounts := AccountCollection(args.Platform) if caccounts != nil {