|
@@ -6,6 +6,8 @@ import ( |
|
@@ -6,6 +6,8 @@ import ( |
6
|
"fmt"
|
6
|
"fmt"
|
7
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/uid"
|
7
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/uid"
|
8
|
"html/template"
|
8
|
"html/template"
|
|
|
9
|
+ "math/rand"
|
|
|
10
|
+ "strconv"
|
9
|
"strings"
|
11
|
"strings"
|
10
|
"time"
|
12
|
"time"
|
11
|
|
13
|
|
|
@@ -93,13 +95,15 @@ Success: |
|
@@ -93,13 +95,15 @@ Success: |
93
|
Uid:fmt.Sprintf("%v",userInfo.Id),
|
95
|
Uid:fmt.Sprintf("%v",userInfo.Id),
|
94
|
Uname:userInfo.Uname,
|
96
|
Uname:userInfo.Uname,
|
95
|
Icon:userInfo.Icon,
|
97
|
Icon:userInfo.Icon,
|
96
|
- IsCreated:userInfo.ImToken=="",
|
98
|
+ IsCreated:userInfo.ImToken!="",
|
97
|
});err!=nil{
|
99
|
});err!=nil{
|
98
|
return
|
100
|
return
|
99
|
}
|
101
|
}
|
100
|
- userInfo.ImToken = checkImResponse.ImToken
|
102
|
+ if checkImResponse!=nil && checkImResponse.ImToken!=""{
|
|
|
103
|
+ userInfo.ImToken = checkImResponse.ImToken
|
|
|
104
|
+ }
|
101
|
if userInfo.CsAccount==0{
|
105
|
if userInfo.CsAccount==0{
|
102
|
- userInfo.CsAccount = checkImResponse.CsAccount
|
106
|
+ userInfo.CsAccount = imGetRandomCSAccount()
|
103
|
}
|
107
|
}
|
104
|
userInfo.AuthExp = time.Now().Add(time.Second*protocol.TokenExpire)
|
108
|
userInfo.AuthExp = time.Now().Add(time.Second*protocol.TokenExpire)
|
105
|
if err = UserRepository.UpdateUserInfoById(userInfo); err != nil {
|
109
|
if err = UserRepository.UpdateUserInfoById(userInfo); err != nil {
|
|
@@ -414,5 +418,22 @@ func imUserRefreshToken(request *protocol.CheckImRequest,rsp *protocol.CheckImRe |
|
@@ -414,5 +418,22 @@ func imUserRefreshToken(request *protocol.CheckImRequest,rsp *protocol.CheckImRe |
414
|
rsp.ImToken = out.Info.Token
|
418
|
rsp.ImToken = out.Info.Token
|
415
|
return
|
419
|
return
|
416
|
}
|
420
|
}
|
|
|
421
|
+// 获取客服id
|
|
|
422
|
+func imGetRandomCSAccount()( acid int64){
|
|
|
423
|
+ kefus,err :=models.GetUsersKefu()
|
|
|
424
|
+ if err!=nil{
|
|
|
425
|
+ log.Error(err)
|
|
|
426
|
+ return
|
|
|
427
|
+ }
|
|
|
428
|
+ if len(kefus)<=0{
|
|
|
429
|
+ return
|
|
|
430
|
+ }
|
|
|
431
|
+ index :=rand.Intn(len(kefus))
|
|
|
432
|
+ acid,err = strconv.ParseInt(kefus[index].Accid,10,64)
|
|
|
433
|
+ if err!=nil{
|
|
|
434
|
+ log.Error(err)
|
|
|
435
|
+ }
|
|
|
436
|
+ return acid
|
|
|
437
|
+}
|
417
|
|
438
|
|
418
|
|
439
|
|