liuxiaolong
2020-08-17 bae4af47f77a195a12a0437584d667465e826e12
service/userService.go
@@ -37,7 +37,7 @@
      }
      var tmpUser models.User
      err := tmpUser.SelectByPhoneNum(phoneNum)
      err := tmpUser.SelectById(hikPersonId)
      fmt.Println("login err:", err)
      if err != nil { //用户不存在,则新增
         u := models.User{
@@ -58,6 +58,13 @@
            if cid != "" {
               go func() {
                  var uc models.UserClient
                  ucList := uc.GetByCid(cid)
                  if ucList != nil && len(ucList) >0 {
                     if len(ucList) >1 || ucList[0].PhoneNum != phoneNum {
                        unbindB, unE := UnbindAlias(cid)
                        fmt.Println("unbindB:", unbindB, "err:", unE)
                     }
                  }
                  if !uc.ExistByCid(phoneNum, cid) {
                     new := models.UserClient{
                        Id:uuid.NewV4().String(),
@@ -66,9 +73,9 @@
                        BindTime: time.Now().Format("2006-01-02 15:04:05"),
                     }
                     new.Insert()
                     bindR, bindE := BindAlias(cid, phoneNum)
                     fmt.Println("bind cid:",cid, "phoneNum:",phoneNum,"result:", bindR, "err:", bindE)
                  }
                  bindR, bindE := BindAlias(cid, phoneNum)
                  fmt.Println("bind cid:",cid, "phoneNum:",phoneNum,"result:", bindR, "err:", bindE)
               }()
            }
            return true, &vo.UserInfo{
@@ -81,12 +88,11 @@
            return false, nil, errors.New("注册失败")
         }
      } else { //用户已存在
         if hikPersonId != tmpUser.Id {
            tmpUser.Id = hikPersonId
            tmpUser.SyncHikPersonId(tmpUser.PhoneNum, hikPersonId)
         if phoneNum != tmpUser.PhoneNum {
            tmpUser.UpdatePhoneNum(phoneNum, hikPersonId)
         }
         var plateNos = make([]string, 0)
         hikVehicles := carSv.GetVehicleListByPerson(tmpUser.Id)
         hikVehicles := carSv.GetVehicleListByPerson(hikPersonId)
         if hikVehicles != nil {
            for _,up := range hikVehicles {
@@ -97,6 +103,13 @@
         if cid != "" {
            go func() {
               var uc models.UserClient
               ucList := uc.GetByCid(cid)
               if ucList != nil && len(ucList) >0 {
                  if len(ucList) >1 || ucList[0].PhoneNum != phoneNum {
                     unbindB, unE := UnbindAlias(cid)
                     fmt.Println("unbindB:", unbindB, "err:", unE)
                  }
               }
               if !uc.ExistByCid(phoneNum, cid) {
                  new := models.UserClient{
                     Id:uuid.NewV4().String(),
@@ -105,9 +118,9 @@
                     BindTime: time.Now().Format("2006-01-02 15:04:05"),
                  }
                  new.Insert()
                  bindR, bindE := BindAlias(cid, phoneNum)
                  fmt.Println("bind cid:",cid, "phoneNum:",phoneNum,"result:", bindR, "err:", bindE)
               }
               bindR, bindE := BindAlias(cid, phoneNum)
               fmt.Println("bind cid:",cid, "phoneNum:",phoneNum,"result:", bindR, "err:", bindE)
            }()
         }
         return true, &vo.UserInfo{