|
@@ -358,6 +358,7 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
@@ -358,6 +358,7 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
358
|
imInfo *domain.ImInfo
|
358
|
imInfo *domain.ImInfo
|
359
|
loginSvr = domain_service.NewPgLoginService(transactionContext)
|
359
|
loginSvr = domain_service.NewPgLoginService(transactionContext)
|
360
|
isSenior bool
|
360
|
isSenior bool
|
|
|
361
|
+ isPartner bool
|
361
|
)
|
362
|
)
|
362
|
|
363
|
|
363
|
// 转换手机号码
|
364
|
// 转换手机号码
|
|
@@ -381,15 +382,15 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
@@ -381,15 +382,15 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
381
|
}()
|
382
|
}()
|
382
|
|
383
|
|
383
|
// 通过短信验证码登录的游客,注册一个账号到配置的公司去(ios审核使用)
|
384
|
// 通过短信验证码登录的游客,注册一个账号到配置的公司去(ios审核使用)
|
384
|
- if request.GrantType == protocol.LoginBySmsCode {
|
|
|
385
|
- guestErr := loginSvr.RegistryGuest(request.Phone)
|
|
|
386
|
- if guestErr != nil {
|
|
|
387
|
- log.Error(guestErr)
|
|
|
388
|
- }
|
|
|
389
|
- }
|
385
|
+ //if request.GrantType == protocol.LoginBySmsCode {
|
|
|
386
|
+ // guestErr := loginSvr.RegistryGuest(request.Phone)
|
|
|
387
|
+ // if guestErr != nil {
|
|
|
388
|
+ // log.Error(guestErr)
|
|
|
389
|
+ // }
|
|
|
390
|
+ //}
|
390
|
|
391
|
|
391
|
- // 通过密码登录的普通用户,注册一个账号到配置的公司去
|
|
|
392
|
- if request.GrantType == protocol.LoginByPassword {
|
392
|
+ // 通过密码或校验码登录的普通用户或通过校验码登录的游客,注册一个账号到配置的公司去
|
|
|
393
|
+ if request.GrantType == protocol.LoginBySmsCode || request.GrantType == protocol.LoginByPassword {
|
393
|
userErr := loginSvr.RegistryUser(request.Phone)
|
394
|
userErr := loginSvr.RegistryUser(request.Phone)
|
394
|
if userErr != nil {
|
395
|
if userErr != nil {
|
395
|
log.Error(userErr)
|
396
|
log.Error(userErr)
|
|
@@ -403,14 +404,25 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
@@ -403,14 +404,25 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
403
|
return
|
404
|
return
|
404
|
}
|
405
|
}
|
405
|
|
406
|
|
406
|
- // 高管初始化
|
407
|
+ // 高管标志位初始化
|
407
|
_ = loginSvr.InitSenior(request.Phone)
|
408
|
_ = loginSvr.InitSenior(request.Phone)
|
408
|
- if len(loginSvr.Users) == 0 {
|
409
|
+ if len(loginSvr.IsSenior) == 0 {
|
409
|
isSenior = false
|
410
|
isSenior = false
|
410
|
} else {
|
411
|
} else {
|
411
|
isSenior = true
|
412
|
isSenior = true
|
412
|
}
|
413
|
}
|
413
|
|
414
|
|
|
|
415
|
+ // 合伙人标志位初始化
|
|
|
416
|
+ _ = loginSvr.InitPartner(request.Phone)
|
|
|
417
|
+ if len(loginSvr.IsPartnerInfo) == 0 {
|
|
|
418
|
+ isPartner = false
|
|
|
419
|
+ } else {
|
|
|
420
|
+ isPartner = true
|
|
|
421
|
+ }
|
|
|
422
|
+
|
|
|
423
|
+ fmt.Print(isPartner, "\n")
|
|
|
424
|
+ fmt.Print(isSenior, "\n")
|
|
|
425
|
+
|
414
|
switch request.GrantType {
|
426
|
switch request.GrantType {
|
415
|
case protocol.LoginByPassword:
|
427
|
case protocol.LoginByPassword:
|
416
|
if len(request.Password) == 0 {
|
428
|
if len(request.Password) == 0 {
|
|
@@ -422,6 +434,19 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
@@ -422,6 +434,19 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
422
|
err = protocol.NewCustomMessage(1, "密码输入有误!")
|
434
|
err = protocol.NewCustomMessage(1, "密码输入有误!")
|
423
|
return
|
435
|
return
|
424
|
}
|
436
|
}
|
|
|
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
|
+
|
425
|
break
|
450
|
break
|
426
|
case protocol.LoginBySmsCode:
|
451
|
case protocol.LoginBySmsCode:
|
427
|
if _, err = CheckSmsCode(request.Phone, request.Captcha); err != nil {
|
452
|
if _, err = CheckSmsCode(request.Phone, request.Captcha); err != nil {
|
|
@@ -477,23 +502,32 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
|
@@ -477,23 +502,32 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom |
477
|
userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials)
|
502
|
userAuth.NewRedisUserCredential(request.Phone).AddAuth(rsp.Credentials)
|
478
|
|
503
|
|
479
|
// 判断是否高管
|
504
|
// 判断是否高管
|
480
|
- if isSenior {
|
505
|
+ if isSenior && isPartner { // 高管且合伙人
|
481
|
v = map[string]interface{}{"center": rsp}
|
506
|
v = map[string]interface{}{"center": rsp}
|
482
|
- } else {
|
507
|
+ } else if isSenior && !isPartner { // 高管非合伙人
|
483
|
var companies []interface{}
|
508
|
var companies []interface{}
|
484
|
|
509
|
|
485
|
- if rsp.Partner.(map[string]interface{})["companys"] != nil {
|
|
|
486
|
- for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {
|
510
|
+ if rsp.Manager.(map[string]interface{})["companys"] != nil {
|
|
|
511
|
+ for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]protocol.CompanyBase) {
|
487
|
companies = append(companies, company)
|
512
|
companies = append(companies, company)
|
488
|
}
|
513
|
}
|
489
|
} else {
|
514
|
} else {
|
490
|
companies = []interface{}{}
|
515
|
companies = []interface{}{}
|
491
|
}
|
516
|
}
|
492
|
|
517
|
|
493
|
- if rsp.Manager.(map[string]interface{})["companys"] != nil {
|
|
|
494
|
- for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]struct{}) {
|
518
|
+ rsp.Partner.(map[string]interface{})["companys"] = []struct{}{}
|
|
|
519
|
+ rsp.Manager.(map[string]interface{})["companys"] = companies
|
|
|
520
|
+
|
|
|
521
|
+ v = map[string]interface{}{"center": rsp}
|
|
|
522
|
+ } else { // 非高管合伙人
|
|
|
523
|
+ var companies []interface{}
|
|
|
524
|
+
|
|
|
525
|
+ if rsp.Partner.(map[string]interface{})["companys"] != nil {
|
|
|
526
|
+ for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {
|
495
|
companies = append(companies, company)
|
527
|
companies = append(companies, company)
|
496
|
}
|
528
|
}
|
|
|
529
|
+ } else {
|
|
|
530
|
+ companies = []interface{}{}
|
497
|
}
|
531
|
}
|
498
|
|
532
|
|
499
|
rsp.Partner.(map[string]interface{})["companys"] = companies
|
533
|
rsp.Partner.(map[string]interface{})["companys"] = companies
|
|
@@ -519,6 +553,7 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco |
|
@@ -519,6 +553,7 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco |
519
|
loginSvr = domain_service.NewPgLoginService(transactionContext)
|
553
|
loginSvr = domain_service.NewPgLoginService(transactionContext)
|
520
|
claim *utils.UserTokenClaims
|
554
|
claim *utils.UserTokenClaims
|
521
|
isSenior bool
|
555
|
isSenior bool
|
|
|
556
|
+ isPartner bool
|
522
|
)
|
557
|
)
|
523
|
rsp = &protocolx.CompanysResponse{}
|
558
|
rsp = &protocolx.CompanysResponse{}
|
524
|
if err = transactionContext.StartTransaction(); err != nil {
|
559
|
if err = transactionContext.StartTransaction(); err != nil {
|
|
@@ -528,10 +563,12 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco |
|
@@ -528,10 +563,12 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco |
528
|
defer func() {
|
563
|
defer func() {
|
529
|
transactionContext.RollbackTransaction()
|
564
|
transactionContext.RollbackTransaction()
|
530
|
}()
|
565
|
}()
|
|
|
566
|
+
|
531
|
if claim, err = utils.ParseJWTToken(request.Credentials); err != nil {
|
567
|
if claim, err = utils.ParseJWTToken(request.Credentials); err != nil {
|
532
|
err = protocol.NewErrWithMessage(4140, err)
|
568
|
err = protocol.NewErrWithMessage(4140, err)
|
533
|
return
|
569
|
return
|
534
|
}
|
570
|
}
|
|
|
571
|
+
|
535
|
//凭证是否存在
|
572
|
//凭证是否存在
|
536
|
if constant.DISENABLE_MULTI_DEVICE_LOGIN {
|
573
|
if constant.DISENABLE_MULTI_DEVICE_LOGIN {
|
537
|
if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) {
|
574
|
if credential, e := userAuth.NewRedisUserCredential(claim.Phone).GetAuth(); e != nil || !strings.EqualFold(credential, request.Credentials) {
|
|
@@ -544,27 +581,41 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco |
|
@@ -544,27 +581,41 @@ func CompaniesLoginByCredential(header *protocol.RequestHeader, request *protoco |
544
|
// loginSvr 初始化
|
581
|
// loginSvr 初始化
|
545
|
loginSvr.Init(claim.Phone)
|
582
|
loginSvr.Init(claim.Phone)
|
546
|
|
583
|
|
547
|
- // 高管初始化
|
584
|
+ // 高管标志位初始化
|
548
|
_ = loginSvr.InitSenior(claim.Phone)
|
585
|
_ = loginSvr.InitSenior(claim.Phone)
|
549
|
- if len(loginSvr.Users) == 0 {
|
586
|
+ if len(loginSvr.IsSenior) == 0 {
|
550
|
isSenior = false
|
587
|
isSenior = false
|
551
|
} else {
|
588
|
} else {
|
552
|
isSenior = true
|
589
|
isSenior = true
|
553
|
}
|
590
|
}
|
554
|
|
591
|
|
|
|
592
|
+ // 合伙人标志位初始化
|
|
|
593
|
+ _ = loginSvr.InitPartner(claim.Phone)
|
|
|
594
|
+ if len(loginSvr.IsPartnerInfo) == 0 {
|
|
|
595
|
+ isPartner = false
|
|
|
596
|
+ } else {
|
|
|
597
|
+ isPartner = true
|
|
|
598
|
+ }
|
|
|
599
|
+
|
555
|
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
|
600
|
rsp.Partner, _ = loginSvr.PartnerStaticInfo()
|
556
|
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
|
601
|
rsp.Manager, _ = loginSvr.ManagerStaticInfo()
|
557
|
|
602
|
|
558
|
- if !isSenior { // 非高管普通用户
|
603
|
+ if !isSenior { // 非高管普通用户, 显示游客公司
|
559
|
var companies []interface{}
|
604
|
var companies []interface{}
|
560
|
- for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]struct{}) {
|
|
|
561
|
- companies = append(companies, company)
|
|
|
562
|
- }
|
|
|
563
|
- for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {
|
|
|
564
|
- companies = append(companies, company)
|
605
|
+ //for _, company := range rsp.Manager.(map[string]interface{})["companys"].([]protocol.CompanyBase) {
|
|
|
606
|
+ // companies = append(companies, company)
|
|
|
607
|
+ //}
|
|
|
608
|
+ if rsp.Partner.(map[string]interface{})["companys"] != nil {
|
|
|
609
|
+ for _, company := range rsp.Partner.(map[string]interface{})["companys"].([]*domain_service.Company) {
|
|
|
610
|
+ companies = append(companies, company)
|
|
|
611
|
+ }
|
|
|
612
|
+ } else {
|
|
|
613
|
+ companies = []interface{}{}
|
565
|
}
|
614
|
}
|
566
|
rsp.Partner.(map[string]interface{})["companys"] = companies
|
615
|
rsp.Partner.(map[string]interface{})["companys"] = companies
|
567
|
rsp.Manager.(map[string]interface{})["companys"] = []struct{}{}
|
616
|
rsp.Manager.(map[string]interface{})["companys"] = []struct{}{}
|
|
|
617
|
+ } else if isSenior && !isPartner { // 高管非合伙人,显示高管公司
|
|
|
618
|
+ rsp.Partner.(map[string]interface{})["companys"] = []struct{}{}
|
568
|
}
|
619
|
}
|
569
|
|
620
|
|
570
|
if !loginSvr.HasAvailableCompany {
|
621
|
if !loginSvr.HasAvailableCompany {
|