|
@@ -26,6 +26,9 @@ func (s *PgCreateCompanyService) CreateCompany(optUser *domain.User, registerPho |
|
@@ -26,6 +26,9 @@ func (s *PgCreateCompanyService) CreateCompany(optUser *domain.User, registerPho |
26
|
}
|
26
|
}
|
27
|
|
27
|
|
28
|
var err error
|
28
|
var err error
|
|
|
29
|
+ var company *domain.Company
|
|
|
30
|
+ companyRepository, _ := repository.NewCompanyRepository(s.transactionContext)
|
|
|
31
|
+
|
29
|
// 1.检查账号是否被注册过,一个手机号只能注册一家企业
|
32
|
// 1.检查账号是否被注册过,一个手机号只能注册一家企业
|
30
|
var userBase *domain.UserBase
|
33
|
var userBase *domain.UserBase
|
31
|
userBaseRepository, _ := repository.NewUserBaseRepository(s.transactionContext)
|
34
|
userBaseRepository, _ := repository.NewUserBaseRepository(s.transactionContext)
|
|
@@ -33,17 +36,20 @@ func (s *PgCreateCompanyService) CreateCompany(optUser *domain.User, registerPho |
|
@@ -33,17 +36,20 @@ func (s *PgCreateCompanyService) CreateCompany(optUser *domain.User, registerPho |
33
|
userRepository, _ := repository.NewUserRepository(s.transactionContext)
|
36
|
userRepository, _ := repository.NewUserRepository(s.transactionContext)
|
34
|
if _, users, _ := userRepository.Find(map[string]interface{}{"userBaseId": userBase.UserBaseId}); len(users) > 0 {
|
37
|
if _, users, _ := userRepository.Find(map[string]interface{}{"userBaseId": userBase.UserBaseId}); len(users) > 0 {
|
35
|
for i := 0; i < len(users); i++ {
|
38
|
for i := 0; i < len(users); i++ {
|
36
|
- if users[i].UserType&domain.RoleTypeAdmin > 0 {
|
|
|
37
|
- return nil, fmt.Errorf("该手机号已注册")
|
39
|
+ if users[i].UserType&domain.RoleTypeAdmin > 0 && users[i].Company != nil {
|
|
|
40
|
+ if company, err = companyRepository.FindOne(map[string]interface{}{"companyId": users[i].Company.CompanyId}); err != nil {
|
|
|
41
|
+ return nil, err
|
|
|
42
|
+ } else if company.Status != domain.CompanyUnauthenticated {
|
|
|
43
|
+ return nil, fmt.Errorf("该手机号已注册")
|
|
|
44
|
+ }
|
38
|
}
|
45
|
}
|
39
|
}
|
46
|
}
|
40
|
}
|
47
|
}
|
41
|
}
|
48
|
}
|
42
|
|
49
|
|
43
|
// 2.企业名称检查
|
50
|
// 2.企业名称检查
|
44
|
- var company *domain.Company
|
|
|
45
|
- companyRepository, _ := repository.NewCompanyRepository(s.transactionContext)
|
|
|
46
|
- if company, err = companyRepository.FindOne(map[string]interface{}{"companyName": companyInfo.CompanyName}); err != nil && err != domain.ErrorNotFound {
|
51
|
+
|
|
|
52
|
+ if company, err = companyRepository.FindOne(map[string]interface{}{"companyName": companyInfo.CompanyName, "statusNotIn": []int{domain.CompanyUnauthenticated}}); err != nil && err != domain.ErrorNotFound {
|
47
|
return nil, fmt.Errorf("该企业已经注册")
|
53
|
return nil, fmt.Errorf("该企业已经注册")
|
48
|
} else if company != nil && company.CompanyInfo.CompanyName == companyInfo.CompanyName {
|
54
|
} else if company != nil && company.CompanyInfo.CompanyName == companyInfo.CompanyName {
|
49
|
return nil, fmt.Errorf("该企业已经注册")
|
55
|
return nil, fmt.Errorf("该企业已经注册")
|