liuxiaolong
2020-08-11 13a31b1caab8ffa0049dc8299cab8b8c4a31b6ed
service/userService.go
@@ -20,26 +20,26 @@
   if verifyCode(phoneNum, code) {
      carSv := NewCarService()
      //先判断此手机号是否在海康平台中
      hikPersons := carSv.GetHikPersonList()
      found := false
      hikPersonId := ""
      if hikPersons != nil {
         for _,hikP := range hikPersons {
            if hikP.PhoneNo == phoneNum {
               found = true
               hikPersonId = hikP.PersonId
            }
         }
      }
      if !found {
         return false, nil, errors.New("请联系停车场管理员")
      }
      var tmpUser models.User
      err := tmpUser.SelectByPhoneNum(phoneNum)
      fmt.Println("login err:", err)
      if err != nil { //用户不存在,则新增
         //先判断此手机号是否在海康平台中
         hikPersons := carSv.GetHikPersonList()
         found := false
         hikPersonId := ""
         if hikPersons != nil {
            for _,hikP := range hikPersons {
               if hikP.PhoneNo == phoneNum {
                  found = true
                  hikPersonId = hikP.PersonId
               }
            }
         }
         if !found {
            return false, nil, errors.New("请联系停车场管理员")
         }
         u := models.User{
            Id: hikPersonId,
            PhoneNum: phoneNum,
@@ -56,7 +56,10 @@
            }
            //客户端cid绑定别名
            if cid != "" {
               go BindAlias(cid, phoneNum)
               go func() {
                  bindR, bindE := BindAlias(cid, phoneNum)
                  fmt.Println("bind cid:",cid, "phoneNum:",phoneNum,"result:", bindR, "err:", bindE)
               }()
            }
            return true, &vo.UserInfo{
               UserId: u.Id,
@@ -68,6 +71,10 @@
            return false, nil, errors.New("注册失败")
         }
      } else { //用户已存在
         if hikPersonId != tmpUser.Id {
            tmpUser.Id = hikPersonId
            tmpUser.SyncHikPersonId(tmpUser.PhoneNum, hikPersonId)
         }
         var plateNos = make([]string, 0)
         hikVehicles := carSv.GetVehicleListByPerson(tmpUser.Id)
@@ -78,7 +85,10 @@
         }
         //客户端cid绑定别名
         if cid != "" {
            go BindAlias(cid, phoneNum)
            go func() {
               bindR, bindE := BindAlias(cid, phoneNum)
               fmt.Println("bind cid:",cid, "phoneNum:",phoneNum,"result:", bindR, "err:", bindE)
            }()
         }
         return true, &vo.UserInfo{
            UserId: tmpUser.Id,