作者 陈志颖

fix:过滤非高管公司i

@@ -381,14 +381,6 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -381,14 +381,6 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
381 transactionContext.RollbackTransaction() 381 transactionContext.RollbackTransaction()
382 }() 382 }()
383 383
384 - // 通过短信验证码登录的游客,注册一个账号到配置的公司去(ios审核使用)  
385 - //if request.GrantType == protocol.LoginBySmsCode {  
386 - // guestErr := loginSvr.RegistryGuest(request.Phone)  
387 - // if guestErr != nil {  
388 - // log.Error(guestErr)  
389 - // }  
390 - //}  
391 -  
392 // 通过密码或校验码登录的普通用户或通过校验码登录的游客,注册一个账号到配置的公司去 384 // 通过密码或校验码登录的普通用户或通过校验码登录的游客,注册一个账号到配置的公司去
393 if request.GrantType == protocol.LoginBySmsCode || request.GrantType == protocol.LoginByPassword { 385 if request.GrantType == protocol.LoginBySmsCode || request.GrantType == protocol.LoginByPassword {
394 userErr := loginSvr.RegistryUser(request.Phone) 386 userErr := loginSvr.RegistryUser(request.Phone)
@@ -434,19 +426,6 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -434,19 +426,6 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
434 err = protocol.NewCustomMessage(1, "密码输入有误!") 426 err = protocol.NewCustomMessage(1, "密码输入有误!")
435 return 427 return
436 } 428 }
437 -  
438 - //if isPartner { // 合伙人登录  
439 - // if loginSvr.ManagerLogin(request.Phone, request.Password) != nil && loginSvr.PartnerLogin(request.Phone, request.Password) != nil {  
440 - // err = protocol.NewCustomMessage(1, "密码输入有误!")  
441 - // return  
442 - // }  
443 - //} else { // 非合伙人高管或者非合伙人非高管  
444 - // if loginSvr.ManagerLogin(request.Phone, request.Password) != nil {  
445 - // err = protocol.NewCustomMessage(1, "密码输入有错误!")  
446 - // return  
447 - // }  
448 - //}  
449 -  
450 break 429 break
451 case protocol.LoginBySmsCode: 430 case protocol.LoginBySmsCode:
452 if _, err = CheckSmsCode(request.Phone, request.Captcha); err != nil { 431 if _, err = CheckSmsCode(request.Phone, request.Captcha); err != nil {
@@ -602,9 +581,7 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco @@ -602,9 +581,7 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco
602 581
603 if !isSenior { // 非高管普通用户, 显示游客公司 582 if !isSenior { // 非高管普通用户, 显示游客公司
604 var companies []interface{} 583 var companies []interface{}
605 - //for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]protocol.CompanyBase) {  
606 - // companies = append(companies, company)  
607 - //} 584 +
608 if rsp.Partner.(map[string]interface{})["companys"] != nil { 585 if rsp.Partner.(map[string]interface{})["companys"] != nil {
609 for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) { 586 for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {
610 companies = append(companies, company) 587 companies = append(companies, company)
@@ -213,7 +213,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { @@ -213,7 +213,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
213 return response, e 213 return response, e
214 } 214 }
215 var mapCompanyAdminUsers map[int64]*domain.Users = make(map[int64]*domain.Users) //key:company_id value:domain.users 215 var mapCompanyAdminUsers map[int64]*domain.Users = make(map[int64]*domain.Users) //key:company_id value:domain.users
216 - if _, adminUsers, e := UsersRepository.Find(map[string]interface{}{"inCompanyIds": doGetCompanyIds(), "adminType": 2, "deleteAtIsNull": true}); e == nil { 216 + if _, adminUsers, e := UsersRepository.Find(map[string]interface{}{"inCompanyIds": doGetCompanyIds(), "adminType": 2, "deleteAtIsNull": true, "isSenior": 1}); e == nil {
217 for i := range adminUsers { 217 for i := range adminUsers {
218 mapCompanyAdminUsers[adminUsers[i].CompanyId] = adminUsers[i] 218 mapCompanyAdminUsers[adminUsers[i].CompanyId] = adminUsers[i]
219 } 219 }
@@ -278,8 +278,8 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { @@ -278,8 +278,8 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
278 ) 278 )
279 doGetCompanyIds := func() []int64 { 279 doGetCompanyIds := func() []int64 {
280 var companies []int64 280 var companies []int64
281 - for i := range svr.Users {  
282 - companies = append(companies, svr.Users[i].CompanyId) 281 + for i := range svr.IsSenior {
  282 + companies = append(companies, svr.IsSenior[i].CompanyId)
283 } 283 }
284 return companies 284 return companies
285 } 285 }
@@ -291,9 +291,9 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) { @@ -291,9 +291,9 @@ func (svr *PgLoginService) ManagerStaticInfo() (interface{}, error) {
291 if constant.POSTGRESQL_DB_NAME != "partner_dev" { 291 if constant.POSTGRESQL_DB_NAME != "partner_dev" {
292 //通过企业平台 校验模块权限 292 //通过企业平台 校验模块权限
293 var user *domain.Users 293 var user *domain.Users
294 - for j := range svr.Users {  
295 - if svr.Users[j].CompanyId == c.Id {  
296 - user = svr.Users[j] 294 + for j := range svr.IsSenior {
  295 + if svr.IsSenior[j].CompanyId == c.Id {
  296 + user = svr.IsSenior[j]
297 break 297 break
298 } 298 }
299 } 299 }
@@ -390,6 +390,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error { @@ -390,6 +390,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
390 ) 390 )
391 391
392 partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "isNot": constant.DEFAULT_GUEST_COMPANY}) // 合伙人是否存在 392 partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "isNot": constant.DEFAULT_GUEST_COMPANY}) // 合伙人是否存在
  393 + guestInfo, _ := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "companyId": constant.DEFAULT_GUEST_COMPANY}) // 合伙人是否存在
393 user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在 394 user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在
394 senior, errSenior := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "isSenior": 2, "deleteAtIsNull": true}) // 用户是否是高管 395 senior, errSenior := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "isSenior": 2, "deleteAtIsNull": true}) // 用户是否是高管
395 396
@@ -400,7 +401,8 @@ func (svr *PgLoginService) RegistryUser(phone string) error { @@ -400,7 +401,8 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
400 // 合伙人存在、用户存在、是高管(高管合伙人) 401 // 合伙人存在、用户存在、是高管(高管合伙人)
401 // 合伙人不存在、用户存在、是高管(高管)|| partnerInfo == nil && user != nil && senior != nil 402 // 合伙人不存在、用户存在、是高管(高管)|| partnerInfo == nil && user != nil && senior != nil
402 // 合伙人存在、用户存在、非高管(合伙人) 403 // 合伙人存在、用户存在、非高管(合伙人)
403 - if partnerInfo != nil && user != nil && senior != nil || partnerInfo != nil && user != nil && senior == nil { 404 + // 游客公司合伙人存在
  405 + if partnerInfo != nil && user != nil && senior != nil || partnerInfo != nil && user != nil && senior == nil || guestInfo != nil {
404 return nil 406 return nil
405 } 407 }
406 408