...
|
...
|
@@ -356,6 +356,7 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
|
imInfo *domain.ImInfo
|
|
|
loginSvr = domain_service.NewPgLoginService(transactionContext)
|
|
|
isSenior bool
|
|
|
//isPartner bool
|
|
|
)
|
|
|
|
|
|
phoneId, e := strconv.Atoi(request.Phone)
|
...
|
...
|
@@ -384,10 +385,44 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
|
}
|
|
|
|
|
|
// loginSvr 初始化
|
|
|
loginSvr.Init(request.Phone)
|
|
|
if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 {
|
|
|
_ = loginSvr.Init(request.Phone)
|
|
|
if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 { // 用户且合伙人不存在
|
|
|
err = protocol.NewErrWithMessage(10001)
|
|
|
return
|
|
|
} else if len(loginSvr.Users) > 0 && len(loginSvr.PartnerInfo) == 0 { // 用户存在,合伙人不存在
|
|
|
// 注册合伙人到非高管公司
|
|
|
userLoginErr := loginSvr.RegistryPartner(request.Phone, loginSvr.Users)
|
|
|
if userLoginErr != nil {
|
|
|
log.Error(userLoginErr)
|
|
|
}
|
|
|
|
|
|
cnt := 0
|
|
|
|
|
|
for _, user := range loginSvr.Users {
|
|
|
if user.IsSenior == 2 {
|
|
|
cnt++
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if cnt == len(loginSvr.Users) {
|
|
|
isSenior = false
|
|
|
} else {
|
|
|
isSenior = true
|
|
|
}
|
|
|
} else if len(loginSvr.Users) > 0 && len(loginSvr.PartnerInfo) > 0 {
|
|
|
cnt := 0
|
|
|
|
|
|
for _, user := range loginSvr.Users {
|
|
|
if user.IsSenior == 2 {
|
|
|
cnt++
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if cnt == len(loginSvr.Users) {
|
|
|
isSenior = false
|
|
|
} else {
|
|
|
isSenior = true
|
|
|
}
|
|
|
}
|
|
|
|
|
|
switch request.GrantType {
|
...
|
...
|
@@ -397,31 +432,10 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
|
return
|
|
|
}
|
|
|
|
|
|
// 判断是否高管
|
|
|
ok, loginErr := loginSvr.CheckIsSenior(request.Phone, 0)
|
|
|
if loginErr != nil {
|
|
|
err = protocol.NewErrWithMessage(10001)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
isSenior = ok
|
|
|
|
|
|
if ok { // 高管
|
|
|
if loginSvr.ManagerLogin(request.Phone, request.Password) != nil && loginSvr.PartnerLogin(request.Phone, request.Password) != nil {
|
|
|
err = protocol.NewCustomMessage(1, "密码输入有误!")
|
|
|
return
|
|
|
}
|
|
|
} else { // 普通用户登录
|
|
|
//guestErr := loginSvr.RegistryGuest(request.Phone)
|
|
|
//if guestErr != nil {
|
|
|
// err = protocol.NewCustomMessage(1, "普通用户登录错误")
|
|
|
// return
|
|
|
//}
|
|
|
if loginSvr.ManagerLogin(request.Phone, request.Password) != nil {
|
|
|
err = protocol.NewCustomMessage(1, "密码输入有误!")
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
case protocol.LoginBySmsCode:
|
|
|
if _, err = CheckSmsCode(request.Phone, request.Captcha); err != nil {
|
...
|
...
|
@@ -449,6 +463,7 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
|
// 获取统计信息(合伙人/高管)
|
|
|
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
|
|
|
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
|
|
|
|
|
|
if !loginSvr.HasAvailableCompany {
|
|
|
err = protocol.NewErrWithMessage(10008) //账号禁用
|
|
|
return
|
...
|
...
|
@@ -476,21 +491,23 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
|
userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials)
|
|
|
|
|
|
// 判断是否高管
|
|
|
if isSenior {
|
|
|
v = map[string]interface{}{"center": rsp}
|
|
|
} else {
|
|
|
if !isSenior { // 用户非高管非合伙人
|
|
|
rsp.Partner.(map[string]interface{})["companys"] = rsp.Manager.(map[string]interface{})["companys"]
|
|
|
rsp.Manager.(map[string]interface{})["companys"] = []struct{}{}
|
|
|
v = map[string]interface{}{"center": rsp}
|
|
|
} else {
|
|
|
v = map[string]interface{}{"center": rsp}
|
|
|
}
|
|
|
|
|
|
//v = map[string]interface{}{"center": rsp}
|
|
|
|
|
|
err = transactionContext.CommitTransaction()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @Author SteveChan
|
|
|
* @Description //TODO 企业平台-多公司登录 - 通过凭证,判断是否高管
|
|
|
* @Description // 企业平台-多公司登录 - 通过凭证,判断是否高管
|
|
|
* @Date 15:00 2021/1/12
|
|
|
* @Param
|
|
|
* @return
|
...
|
...
|
|