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