作者 陈志颖

合并分支 'dev' 到 'test'

fix:过滤非高管公司i



查看合并请求 !33
... ... @@ -381,14 +381,6 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
transactionContext.RollbackTransaction()
}()
// 通过短信验证码登录的游客,注册一个账号到配置的公司去(ios审核使用)
//if request.GrantType == protocol.LoginBySmsCode {
// guestErr := loginSvr.RegistryGuest(request.Phone)
// if guestErr != nil {
// log.Error(guestErr)
// }
//}
// 通过密码或校验码登录的普通用户或通过校验码登录的游客,注册一个账号到配置的公司去
if request.GrantType == protocol.LoginBySmsCode || request.GrantType == protocol.LoginByPassword {
userErr := loginSvr.RegistryUser(request.Phone)
... ... @@ -434,19 +426,6 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
err = protocol.NewCustomMessage(1, "密码输入有误!")
return
}
//if isPartner { // 合伙人登录
// if loginSvr.ManagerLogin(request.Phone, request.Password) != nil && loginSvr.PartnerLogin(request.Phone, request.Password) != nil {
// err = protocol.NewCustomMessage(1, "密码输入有误!")
// return
// }
//} else { // 非合伙人高管或者非合伙人非高管
// 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 {
... ... @@ -602,9 +581,7 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco
if !isSenior { // 非高管普通用户, 显示游客公司
var companies []interface{}
//for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]protocol.CompanyBase) {
// companies = append(companies, company)
//}
if rsp.Partner.(map[string]interface{})["companys"] != nil {
for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {
companies = append(companies, company)
... ...
... ... @@ -213,7 +213,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
return response, e
}
var mapCompanyAdminUsers map[int64]*domain.Users = make(map[int64]*domain.Users) //key:company_id value:domain.users
if _, adminUsers, e := UsersRepository.Find(map[string]interface{}{"inCompanyIds": doGetCompanyIds(), "adminType": 2, "deleteAtIsNull": true}); e == nil {
if _, adminUsers, e := UsersRepository.Find(map[string]interface{}{"inCompanyIds": doGetCompanyIds(), "adminType": 2, "deleteAtIsNull": true, "isSenior": 1}); e == nil {
for i := range adminUsers {
mapCompanyAdminUsers[adminUsers[i].CompanyId] = adminUsers[i]
}
... ... @@ -278,8 +278,8 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
)
doGetCompanyIds := func() []int64 {
var companies []int64
for i := range svr.Users {
companies = append(companies, svr.Users[i].CompanyId)
for i := range svr.IsSenior {
companies = append(companies, svr.IsSenior[i].CompanyId)
}
return companies
}
... ... @@ -291,9 +291,9 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
if constant.POSTGRESQL_DB_NAME != "partner_dev" {
//通过企业平台 校验模块权限
var user *domain.Users
for j := range svr.Users {
if svr.Users[j].CompanyId == c.Id {
user = svr.Users[j]
for j := range svr.IsSenior {
if svr.IsSenior[j].CompanyId == c.Id {
user = svr.IsSenior[j]
break
}
}
... ... @@ -390,6 +390,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
)
partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "isNot": constant.DEFAULT_GUEST_COMPANY}) // 合伙人是否存在
guestInfo, _ := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "companyId": constant.DEFAULT_GUEST_COMPANY}) // 合伙人是否存在
user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在
senior, errSenior := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "isSenior": 2, "deleteAtIsNull": true}) // 用户是否是高管
... ... @@ -400,7 +401,8 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
// 合伙人存在、用户存在、是高管(高管合伙人)
// 合伙人不存在、用户存在、是高管(高管)|| partnerInfo == nil && user != nil && senior != nil
// 合伙人存在、用户存在、非高管(合伙人)
if partnerInfo != nil && user != nil && senior != nil || partnerInfo != nil && user != nil && senior == nil {
// 游客公司合伙人存在
if partnerInfo != nil && user != nil && senior != nil || partnerInfo != nil && user != nil && senior == nil || guestInfo != nil {
return nil
}
... ...