|
@@ -48,20 +48,23 @@ func (svr *PgLoginService) Init(phone string) (err error) { |
|
@@ -48,20 +48,23 @@ func (svr *PgLoginService) Init(phone string) (err error) { |
48
|
_, svr.NormalPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC"})
|
48
|
_, svr.NormalPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC"})
|
49
|
// 所有公司有效合伙人
|
49
|
// 所有公司有效合伙人
|
50
|
_, svr.PartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC"})
|
50
|
_, svr.PartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC"})
|
|
|
51
|
+
|
51
|
// 真实公司有效合伙人
|
52
|
// 真实公司有效合伙人
|
52
|
_, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})
|
53
|
_, svr.IsPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "isNot": constant.DEFAULT_GUEST_COMPANY})
|
|
|
54
|
+
|
53
|
// 游客公司合伙人
|
55
|
// 游客公司合伙人
|
54
|
_, svr.GuestPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
|
56
|
_, svr.GuestPartnerInfo, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
|
55
|
// 游客公司有效合伙人
|
57
|
// 游客公司有效合伙人
|
56
|
_, svr.GuestPartnerInfoAvailable, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
|
58
|
_, svr.GuestPartnerInfoAvailable, err = PartnerInfoService.Find(map[string]interface{}{"account": phone, "status": 1, "sortByCreateTime": "ASC", "companyId": constant.DEFAULT_GUEST_COMPANY})
|
57
|
|
59
|
|
58
|
- // 所有公司用户
|
60
|
+ // 所有公司非删除用户
|
59
|
_, svr.NormalUsers, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "sortByCreateTime": "ASC", "deleteAtIsNull": true})
|
61
|
_, svr.NormalUsers, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "sortByCreateTime": "ASC", "deleteAtIsNull": true})
|
60
|
- // 所有公司有效用户
|
62
|
+ // 所有公司非删除非禁用用户
|
61
|
_, svr.Users, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true})
|
63
|
_, svr.Users, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true})
|
62
|
// 所有公司有效高管
|
64
|
// 所有公司有效高管
|
63
|
_, svr.IsSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1})
|
65
|
_, svr.IsSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1})
|
64
|
- // 真实公司有效高管
|
66
|
+
|
|
|
67
|
+ // 真实公司非禁用非删除高管
|
65
|
_, svr.IsRealSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1, "isNot": constant.DEFAULT_GUEST_COMPANY})
|
68
|
_, svr.IsRealSenior, err = UsersRepository.Find(map[string]interface{}{"phone": phone, "status": 1, "sortByCreateTime": "ASC", "deleteAtIsNull": true, "isSenior": 1, "isNot": constant.DEFAULT_GUEST_COMPANY})
|
66
|
|
69
|
|
67
|
return nil
|
70
|
return nil
|
|
@@ -576,8 +579,8 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
|
@@ -576,8 +579,8 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
576
|
CooperateTime: time.Now(),
|
579
|
CooperateTime: time.Now(),
|
577
|
CreateAt: time.Now(),
|
580
|
CreateAt: time.Now(),
|
578
|
UpdateAt: time.Now(),
|
581
|
UpdateAt: time.Now(),
|
579
|
- PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
|
|
|
580
|
- Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
|
582
|
+ PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
|
|
|
583
|
+ Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
|
581
|
})
|
584
|
})
|
582
|
}
|
585
|
}
|
583
|
|
586
|
|
|
@@ -600,14 +603,74 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
|
@@ -600,14 +603,74 @@ func (svr *PgLoginService) RegistryUser(phone string) error { |
600
|
CooperateTime: time.Now(),
|
603
|
CooperateTime: time.Now(),
|
601
|
CreateAt: time.Now(),
|
604
|
CreateAt: time.Now(),
|
602
|
UpdateAt: time.Now(),
|
605
|
UpdateAt: time.Now(),
|
603
|
- PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
|
|
|
604
|
- Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
|
606
|
+ PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
|
|
|
607
|
+ Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
|
605
|
})
|
608
|
})
|
606
|
}
|
609
|
}
|
607
|
|
610
|
|
608
|
return errPartner
|
611
|
return errPartner
|
609
|
}
|
612
|
}
|
610
|
|
613
|
|
|
|
614
|
+/**
|
|
|
615
|
+ * @Author SteveChan
|
|
|
616
|
+ * @Description //TODO 操作游客
|
|
|
617
|
+ * @Date 15:20 2021/2/7
|
|
|
618
|
+ * @Param
|
|
|
619
|
+ * @return
|
|
|
620
|
+ **/
|
|
|
621
|
+func (svr *PgLoginService) OperateGuest(phone string) error {
|
|
|
622
|
+ var (
|
|
|
623
|
+ PartnerInfoService, _ = repository.NewPartnerInfoRepository(svr.transactionContext)
|
|
|
624
|
+ UsersRepository, _ = repository.NewUsersRepository(svr.transactionContext)
|
|
|
625
|
+ )
|
|
|
626
|
+
|
|
|
627
|
+ // 真实公司检索合伙人身份(账号未禁用)
|
|
|
628
|
+ partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "status": 1, "isNot": constant.DEFAULT_GUEST_COMPANY})
|
|
|
629
|
+
|
|
|
630
|
+ // 真实公司检索用户身份(账号未删除且是高管)
|
|
|
631
|
+ user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "isSenior": 1, "deleteAtIsNull": true, "isNot": constant.DEFAULT_GUEST_COMPANY})
|
|
|
632
|
+
|
|
|
633
|
+ // 存在合伙人或者用户身份,不进行游客注册操作
|
|
|
634
|
+ if partnerInfo != nil || user != nil {
|
|
|
635
|
+ return nil
|
|
|
636
|
+ }
|
|
|
637
|
+
|
|
|
638
|
+ if errUser != nil && errPartner != nil { // 合伙人身份和用户身份均不存在,注册游客合伙人
|
|
|
639
|
+ id := time.Now().Unix()
|
|
|
640
|
+ _, errInsert := svr.transactionContext.PgDd.Model(models.PartnerInfo{
|
|
|
641
|
+ Id: id,
|
|
|
642
|
+ CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
|
|
|
643
|
+ PartnerName: phone,
|
|
|
644
|
+ Account: phone,
|
|
|
645
|
+ Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
|
|
|
646
|
+ Status: 1,
|
|
|
647
|
+ PartnerCategory: 1,
|
|
|
648
|
+ RegionInfo: &domain.RegionInfo{
|
|
|
649
|
+ RegionName: "客户区域",
|
|
|
650
|
+ RegionId: 0,
|
|
|
651
|
+ },
|
|
|
652
|
+ CooperateTime: time.Now(),
|
|
|
653
|
+ CreateAt: time.Now(),
|
|
|
654
|
+ UpdateAt: time.Now(),
|
|
|
655
|
+ PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
|
|
|
656
|
+ Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
|
|
|
657
|
+ }).Insert()
|
|
|
658
|
+ if errInsert != nil {
|
|
|
659
|
+ return errInsert
|
|
|
660
|
+ }
|
|
|
661
|
+ } else { // 真实公司存在合伙人或者高管用户,删除游客合伙人
|
|
|
662
|
+ _, errDelete := svr.transactionContext.PgDd.Model((*models.PartnerInfo)(nil)).
|
|
|
663
|
+ Where("account = ?", phone).
|
|
|
664
|
+ Where("company_id = ?", constant.DEFAULT_GUEST_COMPANY).
|
|
|
665
|
+ Delete()
|
|
|
666
|
+ if errDelete != nil {
|
|
|
667
|
+ return errDelete
|
|
|
668
|
+ }
|
|
|
669
|
+ }
|
|
|
670
|
+
|
|
|
671
|
+ return nil
|
|
|
672
|
+}
|
|
|
673
|
+
|
611
|
// 注册游客到指定的公司
|
674
|
// 注册游客到指定的公司
|
612
|
func (svr *PgLoginService) RegistryGuest(phone string) error {
|
675
|
func (svr *PgLoginService) RegistryGuest(phone string) error {
|
613
|
var (
|
676
|
var (
|
|
@@ -622,6 +685,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { |
|
@@ -622,6 +685,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { |
622
|
return nil
|
685
|
return nil
|
623
|
}
|
686
|
}
|
624
|
|
687
|
|
|
|
688
|
+ // 注册用户
|
625
|
if errUser != nil && errPartner != nil {
|
689
|
if errUser != nil && errPartner != nil {
|
626
|
id := time.Now().Unix()
|
690
|
id := time.Now().Unix()
|
627
|
errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
|
691
|
errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
|
|
@@ -639,11 +703,13 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { |
|
@@ -639,11 +703,13 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { |
639
|
CooperateTime: time.Now(),
|
703
|
CooperateTime: time.Now(),
|
640
|
CreateAt: time.Now(),
|
704
|
CreateAt: time.Now(),
|
641
|
UpdateAt: time.Now(),
|
705
|
UpdateAt: time.Now(),
|
642
|
- PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
|
|
|
643
|
- Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
|
706
|
+ PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
|
|
|
707
|
+ Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
|
644
|
})
|
708
|
})
|
645
|
}
|
709
|
}
|
646
|
|
710
|
|
|
|
711
|
+ // 删除用户
|
|
|
712
|
+
|
647
|
return errPartner
|
713
|
return errPartner
|
648
|
}
|
714
|
}
|
649
|
|
715
|
|