...
|
...
|
@@ -6,6 +6,8 @@ import ( |
|
|
"fmt"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/uid"
|
|
|
"html/template"
|
|
|
"math/rand"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"time"
|
|
|
|
...
|
...
|
@@ -93,13 +95,15 @@ Success: |
|
|
Uid:fmt.Sprintf("%v",userInfo.Id),
|
|
|
Uname:userInfo.Uname,
|
|
|
Icon:userInfo.Icon,
|
|
|
IsCreated:userInfo.ImToken=="",
|
|
|
IsCreated:userInfo.ImToken!="",
|
|
|
});err!=nil{
|
|
|
return
|
|
|
}
|
|
|
userInfo.ImToken = checkImResponse.ImToken
|
|
|
if checkImResponse!=nil && checkImResponse.ImToken!=""{
|
|
|
userInfo.ImToken = checkImResponse.ImToken
|
|
|
}
|
|
|
if userInfo.CsAccount==0{
|
|
|
userInfo.CsAccount = checkImResponse.CsAccount
|
|
|
userInfo.CsAccount = imGetRandomCSAccount()
|
|
|
}
|
|
|
userInfo.AuthExp = time.Now().Add(time.Second*protocol.TokenExpire)
|
|
|
if err = UserRepository.UpdateUserInfoById(userInfo); err != nil {
|
...
|
...
|
@@ -414,5 +418,22 @@ func imUserRefreshToken(request *protocol.CheckImRequest,rsp *protocol.CheckImRe |
|
|
rsp.ImToken = out.Info.Token
|
|
|
return
|
|
|
}
|
|
|
// 获取客服id
|
|
|
func imGetRandomCSAccount()( acid int64){
|
|
|
kefus,err :=models.GetUsersKefu()
|
|
|
if err!=nil{
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if len(kefus)<=0{
|
|
|
return
|
|
|
}
|
|
|
index :=rand.Intn(len(kefus))
|
|
|
acid,err = strconv.ParseInt(kefus[index].Accid,10,64)
|
|
|
if err!=nil{
|
|
|
log.Error(err)
|
|
|
}
|
|
|
return acid
|
|
|
}
|
|
|
|
|
|
|
...
|
...
|
|