...
|
...
|
@@ -350,20 +350,24 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
|
imInfo *domain.ImInfo
|
|
|
loginSvr = domain_service.NewPgLoginService(transactionContext)
|
|
|
)
|
|
|
|
|
|
phoneId, e := strconv.Atoi(request.Phone)
|
|
|
if e != nil {
|
|
|
log.Error(e)
|
|
|
e = protocol.NewErrWithMessage(2)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
rsp := &protocolx.CenterCompanysResponse{}
|
|
|
if err = transactionContext.StartTransaction(); err != nil {
|
|
|
log.Error(err)
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
// 通过短信验证码登录的游客,注册一个账号到配置的公司去(ios审核使用)
|
|
|
if request.GrantType == protocol.LoginBySmsCode {
|
|
|
e := loginSvr.RegistryGuest(request.Phone)
|
...
|
...
|
@@ -371,22 +375,38 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
|
log.Error(e)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// loginSvr 初始化
|
|
|
loginSvr.Init(request.Phone)
|
|
|
if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 {
|
|
|
err = protocol.NewErrWithMessage(10001)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
switch request.GrantType {
|
|
|
case protocol.LoginByPassword:
|
|
|
if len(request.Password) == 0 {
|
|
|
err = protocol.NewCustomMessage(1, "密码不能为空!")
|
|
|
return
|
|
|
}
|
|
|
// 判断是否高管
|
|
|
ok, loginErr := loginSvr.CheckIsSenior(request.Phone, 0)
|
|
|
if loginErr != nil {
|
|
|
err = protocol.NewErrWithMessage(10001)
|
|
|
return
|
|
|
}
|
|
|
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
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
case protocol.LoginBySmsCode:
|
|
|
if _, err = CheckSmsCode(request.Phone, request.Captcha); err != nil {
|
...
|
...
|
|