From 13a31b1caab8ffa0049dc8299cab8b8c4a31b6ed Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期二, 11 八月 2020 15:32:06 +0800
Subject: [PATCH] test

---
 service/userService.go |   52 +++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/service/userService.go b/service/userService.go
index 731ee51..b6eccdd 100644
--- a/service/userService.go
+++ b/service/userService.go
@@ -16,30 +16,30 @@
 
 }
 
-func (sv *UserService) Login(phoneNum, code string) (bool,*vo.UserInfo,error) {
+func (sv *UserService) Login(phoneNum, code, cid string) (bool,*vo.UserInfo,error) {
 	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,
@@ -54,6 +54,13 @@
 						plateNos = append(plateNos, up.PlateNo)
 					}
 				}
+				//瀹㈡埛绔痗id缁戝畾鍒悕
+				if cid != "" {
+					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,
 					PhoneNum: phoneNum,
@@ -64,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)
 
@@ -72,6 +83,13 @@
 					plateNos = append(plateNos, up.PlateNo)
 				}
 			}
+			//瀹㈡埛绔痗id缁戝畾鍒悕
+			if cid != "" {
+				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,
 				PhoneNum: phoneNum,

--
Gitblit v1.8.0