作者 陈志颖

合并分支 'dev' 到 'test'

fix:登录提示



查看合并请求 !39
@@ -357,8 +357,6 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -357,8 +357,6 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
357 transactionContext, _ = factory.CreateTransactionContext(nil) 357 transactionContext, _ = factory.CreateTransactionContext(nil)
358 imInfo *domain.ImInfo 358 imInfo *domain.ImInfo
359 loginSvr = domain_service.NewPgLoginService(transactionContext) 359 loginSvr = domain_service.NewPgLoginService(transactionContext)
360 - //isSenior bool  
361 - //isPartner bool  
362 ) 360 )
363 361
364 // 转换手机号码 362 // 转换手机号码
@@ -391,29 +389,25 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -391,29 +389,25 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
391 389
392 // loginSvr 初始化 390 // loginSvr 初始化
393 _ = loginSvr.Init(request.Phone) 391 _ = loginSvr.Init(request.Phone)
394 - if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 {  
395 - err = protocol.NewErrWithMessage(10001)  
396 - return  
397 - }  
398 392
399 // 高管标志位初始化 393 // 高管标志位初始化
400 _ = loginSvr.InitSenior(request.Phone) 394 _ = loginSvr.InitSenior(request.Phone)
401 - //if len(loginSvr.IsSenior) == 0 {  
402 - // isSenior = false  
403 - //} else {  
404 - // isSenior = true  
405 - //}  
406 395
407 // 合伙人标志位初始化 396 // 合伙人标志位初始化
408 _ = loginSvr.InitPartner(request.Phone) 397 _ = loginSvr.InitPartner(request.Phone)
409 - //if len(loginSvr.IsPartnerInfo) == 0 {  
410 - // isPartner = false  
411 - //} else {  
412 - // isPartner = true  
413 - //}  
414 398
415 - //fmt.Print(isPartner, "\n")  
416 - //fmt.Print(isSenior, "\n") 399 + // 普通合伙人标志位
  400 + _ = loginSvr.InitNormal(request.Phone)
  401 +
  402 + if len(loginSvr.Users) == 0 && len(loginSvr.PartnerInfo) == 0 && len(loginSvr.NormalPartnerInfo) == 0 {
  403 + err = protocol.NewErrWithMessage(10001)
  404 + return
  405 + }
  406 +
  407 + if len(loginSvr.PartnerInfo) == 0 {
  408 + err = protocol.NewErrWithMessage(10008)
  409 + return
  410 + }
417 411
418 switch request.GrantType { 412 switch request.GrantType {
419 case protocol.LoginByPassword: 413 case protocol.LoginByPassword:
@@ -480,39 +474,6 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -480,39 +474,6 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
480 // 添加手机对应的凭证 474 // 添加手机对应的凭证
481 userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials) 475 userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials)
482 476
483 - // 判断是否高管  
484 - //if isSenior && isPartner { // 高管且合伙人  
485 - // v = map[string]interface{}{"center": rsp}  
486 - //} else if isSenior && !isPartner { // 高管非合伙人  
487 - // var companies []interface{}  
488 - // if len(rsp.Manager.(map[string]interface{})["companys"].([]protocol.CompanyBase)) > 0 {  
489 - // for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]protocol.CompanyBase) {  
490 - // companies = append(companies, company)  
491 - // }  
492 - // } else {  
493 - // companies = []interface{}{}  
494 - // }  
495 - //  
496 - // rsp.Partner.(map[string]interface{})["companys"] = []struct{}{}  
497 - // rsp.Manager.(map[string]interface{})["companys"] = companies  
498 - //  
499 - // v = map[string]interface{}{"center": rsp}  
500 - //} else { // 非高管合伙人  
501 - // var companies []interface{}  
502 - // if len(rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company)) > 0 {  
503 - // for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {  
504 - // companies = append(companies, company)  
505 - // }  
506 - // } else {  
507 - // companies = []interface{}{}  
508 - // }  
509 - //  
510 - // rsp.Partner.(map[string]interface{})["companys"] = companies  
511 - // rsp.Manager.(map[string]interface{})["companys"] = []struct{}{}  
512 - //  
513 - // v = map[string]interface{}{"center": rsp}  
514 - //}  
515 -  
516 v = map[string]interface{}{"center": rsp} 477 v = map[string]interface{}{"center": rsp}
517 478
518 err = transactionContext.CommitTransaction() 479 err = transactionContext.CommitTransaction()
@@ -531,8 +492,6 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco @@ -531,8 +492,6 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco
531 transactionContext, _ = factory.CreateTransactionContext(nil) 492 transactionContext, _ = factory.CreateTransactionContext(nil)
532 loginSvr = domain_service.NewPgLoginService(transactionContext) 493 loginSvr = domain_service.NewPgLoginService(transactionContext)
533 claim *utils.UserTokenClaims 494 claim *utils.UserTokenClaims
534 - //isSenior bool  
535 - //isPartner bool  
536 ) 495 )
537 rsp = &protocolx.CompanysResponse{} 496 rsp = &protocolx.CompanysResponse{}
538 if err = transactionContext.StartTransaction(); err != nil { 497 if err = transactionContext.StartTransaction(); err != nil {
@@ -562,38 +521,13 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco @@ -562,38 +521,13 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco
562 521
563 // 高管标志位初始化 522 // 高管标志位初始化
564 _ = loginSvr.InitSenior(claim.Phone) 523 _ = loginSvr.InitSenior(claim.Phone)
565 - //if len(loginSvr.IsSenior) == 0 {  
566 - // isSenior = false  
567 - //} else {  
568 - // isSenior = true  
569 - //}  
570 524
571 // 合伙人标志位初始化 525 // 合伙人标志位初始化
572 _ = loginSvr.InitPartner(claim.Phone) 526 _ = loginSvr.InitPartner(claim.Phone)
573 - //if len(loginSvr.IsPartnerInfo) == 0 {  
574 - // isPartner = false  
575 - //} else {  
576 - // isPartner = true  
577 - //}  
578 527
579 rsp.Partner, _ = loginSvr.PartnerStaticInfo() 528 rsp.Partner, _ = loginSvr.PartnerStaticInfo()
580 rsp.Manager, _ = loginSvr.ManagerStaticInfo() 529 rsp.Manager, _ = loginSvr.ManagerStaticInfo()
581 530
582 - //if !isSenior { // 非高管普通用户, 显示游客公司  
583 - // var companies []interface{}  
584 - // if len(rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company)) > 0 {  
585 - // for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {  
586 - // companies = append(companies, company)  
587 - // }  
588 - // } else {  
589 - // companies = []interface{}{}  
590 - // }  
591 - // rsp.Partner.(map[string]interface{})["companys"] = companies  
592 - // rsp.Manager.(map[string]interface{})["companys"] = []struct{}{}  
593 - //} else if isSenior && !isPartner { // 高管非合伙人,显示高管公司  
594 - // rsp.Partner.(map[string]interface{})["companys"] = []struct{}{}  
595 - //}  
596 -  
597 if !loginSvr.HasAvailableCompany && !loginSvr.HasAvailableManagerCompany { 531 if !loginSvr.HasAvailableCompany && !loginSvr.HasAvailableManagerCompany {
598 err = protocol.NewErrWithMessage(4140, err) //账号禁用 532 err = protocol.NewErrWithMessage(4140, err) //账号禁用
599 return 533 return
@@ -22,6 +22,7 @@ type PgLoginService struct { @@ -22,6 +22,7 @@ type PgLoginService struct {
22 Phone string 22 Phone string
23 eda.EventCenterPublisher 23 eda.EventCenterPublisher
24 PartnerInfo []*domain.PartnerInfo 24 PartnerInfo []*domain.PartnerInfo
  25 + NormalPartnerInfo []*domain.PartnerInfo
25 IsPartnerInfo []*domain.PartnerInfo 26 IsPartnerInfo []*domain.PartnerInfo
26 Users []*domain.Users 27 Users []*domain.Users
27 IsSenior []*domain.Users 28 IsSenior []*domain.Users
@@ -45,6 +46,18 @@ func (svr *PgLoginService) Init(phone string) (err error) { @@ -45,6 +46,18 @@ func (svr *PgLoginService) Init(phone string) (err error) {
45 return nil 46 return nil
46 } 47 }
47 48
  49 +func (svr *PgLoginService) InitNormal(phone string) (err error) {
  50 + var (
  51 + PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext)
  52 + )
  53 +
  54 + svr.Phone = phone
  55 +
  56 + _, svr.NormalPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC"})
  57 +
  58 + return nil
  59 +}
  60 +
48 func (svr *PgLoginService) InitSenior(phone string) (err error) { 61 func (svr *PgLoginService) InitSenior(phone string) (err error) {
49 var ( 62 var (
50 UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext) 63 UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext)
@@ -411,30 +424,30 @@ func (svr *PgLoginService) RegistryUser(phone string) error { @@ -411,30 +424,30 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
411 fmt.Print("高管:", senior != nil, "\n") 424 fmt.Print("高管:", senior != nil, "\n")
412 425
413 // 游客公司合伙人存在,更新合伙人 426 // 游客公司合伙人存在,更新合伙人
414 - if guestInfo != nil {  
415 - _, err := svr.transactionContext.PgTx.Model(&models.PartnerInfo{  
416 - CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),  
417 - PartnerName: phone,  
418 - Account: phone,  
419 - Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",  
420 - PartnerCategory: 1,  
421 - RegionInfo: &domain.RegionInfo{  
422 - RegionName: "客户区域",  
423 - RegionId: 0,  
424 - },  
425 - Status: guestInfo.Status,  
426 - CooperateTime: time.Now(),  
427 - CreateAt: time.Now(),  
428 - UpdateAt: time.Now(),  
429 - PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},  
430 - Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}}).  
431 - Where("partner_info.account = ?", phone).  
432 - Where("partner_info.company_id = ?", constant.DEFAULT_GUEST_COMPANY).  
433 - Update()  
434 - if err != nil {  
435 - return err  
436 - }  
437 - } 427 + //if guestInfo != nil {
  428 + // _, err := svr.transactionContext.PgTx.Model(&models.PartnerInfo{
  429 + // CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
  430 + // PartnerName: phone,
  431 + // Account: phone,
  432 + // Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
  433 + // PartnerCategory: 1,
  434 + // RegionInfo: &domain.RegionInfo{
  435 + // RegionName: "客户区域",
  436 + // RegionId: 0,
  437 + // },
  438 + // Status: guestInfo.Status,
  439 + // CooperateTime: time.Now(),
  440 + // CreateAt: time.Now(),
  441 + // UpdateAt: time.Now(),
  442 + // PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
  443 + // Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}}).
  444 + // Where("partner_info.account = ?", phone).
  445 + // Where("partner_info.company_id = ?", constant.DEFAULT_GUEST_COMPANY).
  446 + // Update()
  447 + // if err != nil {
  448 + // return err
  449 + // }
  450 + //}
438 451
439 // 合伙人存在、用户存在、是高管(高管合伙人) 452 // 合伙人存在、用户存在、是高管(高管合伙人)
440 // 合伙人不存在、用户存在、是高管(高管)|| partnerInfo == nil && user != nil && senior != nil 453 // 合伙人不存在、用户存在、是高管(高管)|| partnerInfo == nil && user != nil && senior != nil