合并分支 'dev' 到 'test'
Dev 查看合并请求 !12
正在显示
6 个修改的文件
包含
62 行增加
和
15 行删除
| @@ -122,11 +122,13 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop | @@ -122,11 +122,13 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop | ||
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | // 校验:判断用户类型是否属于承接对象 | 124 | // 校验:判断用户类型是否属于承接对象 |
| 125 | - if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, 4) { // 非公开类型校验 | ||
| 126 | - if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType) { | 125 | + if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, 3) { // 非公开类型校验 |
| 126 | + for _, userType := range cooperationProject.CooperationProjectUndertakerTypes { | ||
| 127 | + if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType&userType) { | ||
| 127 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象") | 128 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象") |
| 128 | } | 129 | } |
| 129 | } | 130 | } |
| 131 | + } | ||
| 130 | 132 | ||
| 131 | newCooperationApplication = &domain.CooperationApplication{ | 133 | newCooperationApplication = &domain.CooperationApplication{ |
| 132 | CooperationApplicationApplicant: applicant, | 134 | CooperationApplicationApplicant: applicant, |
| @@ -160,14 +160,12 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -160,14 +160,12 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
| 160 | 160 | ||
| 161 | // 校验承接人是否属于承接对象,1员工,2共创用户,4公开 | 161 | // 校验承接人是否属于承接对象,1员工,2共创用户,4公开 |
| 162 | if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, 3) { | 162 | if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, 3) { |
| 163 | - var userType int32 | ||
| 164 | - if undertakerDomain.UserType > 1024 { | ||
| 165 | - userType = undertakerDomain.UserType - 1024 | ||
| 166 | - } | ||
| 167 | - if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, userType) { | 163 | + for _, userType := range createCooperationContractCommand.CooperationContractUndertakerTypes { |
| 164 | + if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, undertakerDomain.UserType&userType) { | ||
| 168 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象") | 165 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象") |
| 169 | } | 166 | } |
| 170 | } | 167 | } |
| 168 | + } | ||
| 171 | 169 | ||
| 172 | // 获取推荐人 | 170 | // 获取推荐人 |
| 173 | var referrerDomain *domain.Referrer | 171 | var referrerDomain *domain.Referrer |
| @@ -1027,12 +1025,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1027,12 +1025,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
| 1027 | 1025 | ||
| 1028 | // 校验:判断用户类型是否属于承接对象 | 1026 | // 校验:判断用户类型是否属于承接对象 |
| 1029 | if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, 3) { // 非公开类型校验 | 1027 | if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, 3) { // 非公开类型校验 |
| 1030 | - var userType int32 | ||
| 1031 | - if undertakerDomain.UserType > 1024 { | ||
| 1032 | - userType = undertakerDomain.UserType - 1024 | 1028 | + for _, userType := range cooperationContract.CooperationContractUndertakerTypes { |
| 1029 | + if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, undertakerDomain.UserType&userType) { | ||
| 1030 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象") | ||
| 1033 | } | 1031 | } |
| 1034 | - if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, userType) { | ||
| 1035 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象") | ||
| 1036 | } | 1032 | } |
| 1037 | } | 1033 | } |
| 1038 | 1034 |
| @@ -7,6 +7,8 @@ type CooperationProjectsDto struct { | @@ -7,6 +7,8 @@ type CooperationProjectsDto struct { | ||
| 7 | //CooperationMode *CooperationMode `json:"cooperationMode"` | 7 | //CooperationMode *CooperationMode `json:"cooperationMode"` |
| 8 | // 可以去除勾选的共创项目承接对象列表 | 8 | // 可以去除勾选的共创项目承接对象列表 |
| 9 | UndertakerTypesUncheckedAvailable []int32 `json:"undertakerTypesUncheckedAvailable"` | 9 | UndertakerTypesUncheckedAvailable []int32 `json:"undertakerTypesUncheckedAvailable"` |
| 10 | + // 承接人 | ||
| 11 | + Applicants []*domain.User `json:"applicants"` | ||
| 10 | } | 12 | } |
| 11 | 13 | ||
| 12 | type CooperationMode struct { | 14 | type CooperationMode struct { |
| @@ -18,7 +20,7 @@ type CooperationMode struct { | @@ -18,7 +20,7 @@ type CooperationMode struct { | ||
| 18 | CooperationModeName string `json:"cooperationModeName"` | 20 | CooperationModeName string `json:"cooperationModeName"` |
| 19 | } | 21 | } |
| 20 | 22 | ||
| 21 | -func (dto *CooperationProjectsDto) LoadDto(project *domain.CooperationProject, mode *domain.CooperationMode, undertakerTypesUncheckedAvailable []int32) error { | 23 | +func (dto *CooperationProjectsDto) LoadDto(project *domain.CooperationProject, mode *domain.CooperationMode, undertakerTypesUncheckedAvailable []int32, applicants []*domain.User) error { |
| 22 | dto.CooperationProject = project | 24 | dto.CooperationProject = project |
| 23 | dto.UndertakerTypesUncheckedAvailable = undertakerTypesUncheckedAvailable | 25 | dto.UndertakerTypesUncheckedAvailable = undertakerTypesUncheckedAvailable |
| 24 | //dto.CooperationMode = &CooperationMode{ | 26 | //dto.CooperationMode = &CooperationMode{ |
| @@ -26,5 +28,6 @@ func (dto *CooperationProjectsDto) LoadDto(project *domain.CooperationProject, m | @@ -26,5 +28,6 @@ func (dto *CooperationProjectsDto) LoadDto(project *domain.CooperationProject, m | ||
| 26 | // CooperationModeName: mode.CooperationModeName, | 28 | // CooperationModeName: mode.CooperationModeName, |
| 27 | // CooperationModeNumber: mode.CooperationModeNumber, | 29 | // CooperationModeNumber: mode.CooperationModeNumber, |
| 28 | //} | 30 | //} |
| 31 | + dto.Applicants = applicants | ||
| 29 | return nil | 32 | return nil |
| 30 | } | 33 | } |
| @@ -12,6 +12,7 @@ import ( | @@ -12,6 +12,7 @@ import ( | ||
| 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" | 12 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" |
| 13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao" | 13 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao" |
| 14 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" | 14 | "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" |
| 15 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" | ||
| 15 | "strconv" | 16 | "strconv" |
| 16 | "time" | 17 | "time" |
| 17 | ) | 18 | ) |
| @@ -169,6 +170,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | @@ -169,6 +170,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro | ||
| 169 | if err2 != nil { | 170 | if err2 != nil { |
| 170 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error()) | 171 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error()) |
| 171 | } | 172 | } |
| 173 | + | ||
| 172 | // 校验共创项目编号是否唯一 | 174 | // 校验共创项目编号是否唯一 |
| 173 | numberAvailable, _ := cooperationProjectDao.CheckProjectNumberAvailable(map[string]interface{}{ | 175 | numberAvailable, _ := cooperationProjectDao.CheckProjectNumberAvailable(map[string]interface{}{ |
| 174 | "companyId": createCooperationProjectCommand.CompanyId, | 176 | "companyId": createCooperationProjectCommand.CompanyId, |
| @@ -244,6 +246,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -244,6 +246,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
| 244 | defer func() { | 246 | defer func() { |
| 245 | _ = transactionContext.RollbackTransaction() | 247 | _ = transactionContext.RollbackTransaction() |
| 246 | }() | 248 | }() |
| 249 | + | ||
| 250 | + // 共创项目仓储初始化 | ||
| 247 | var cooperationProjectRepository domain.CooperationProjectRepository | 251 | var cooperationProjectRepository domain.CooperationProjectRepository |
| 248 | if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ | 252 | if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{ |
| 249 | "transactionContext": transactionContext, | 253 | "transactionContext": transactionContext, |
| @@ -252,6 +256,18 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -252,6 +256,18 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
| 252 | } else { | 256 | } else { |
| 253 | cooperationProjectRepository = value | 257 | cooperationProjectRepository = value |
| 254 | } | 258 | } |
| 259 | + | ||
| 260 | + // 共创申请仓储初始化 | ||
| 261 | + var cooperationApplicationRepository domain.CooperationApplicationRepository | ||
| 262 | + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{ | ||
| 263 | + "transactionContext": transactionContext, | ||
| 264 | + }); err != nil { | ||
| 265 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 266 | + } else { | ||
| 267 | + cooperationApplicationRepository = value | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + // 获取共创项目 | ||
| 255 | cooperationProject, err := cooperationProjectRepository.FindOne(tool_funs.SimpleStructToMap(getCooperationProjectQuery)) | 271 | cooperationProject, err := cooperationProjectRepository.FindOne(tool_funs.SimpleStructToMap(getCooperationProjectQuery)) |
| 256 | if err != nil { | 272 | if err != nil { |
| 257 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 273 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| @@ -276,6 +292,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -276,6 +292,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
| 276 | gotUser, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ | 292 | gotUser, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ |
| 277 | "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, | 293 | "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, |
| 278 | "user": true, | 294 | "user": true, |
| 295 | + "companyId": getCooperationProjectQuery.CompanyId, | ||
| 296 | + "orgId": getCooperationProjectQuery.OrgId, | ||
| 279 | }) | 297 | }) |
| 280 | if err != nil { | 298 | if err != nil { |
| 281 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 299 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| @@ -288,6 +306,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -288,6 +306,8 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
| 288 | gotPartner, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ | 306 | gotPartner, err := cooperationProjectDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{ |
| 289 | "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, | 307 | "cooperationProjectNumber": cooperationProject.CooperationProjectNumber, |
| 290 | "partner": true, | 308 | "partner": true, |
| 309 | + "companyId": getCooperationProjectQuery.CompanyId, | ||
| 310 | + "orgId": getCooperationProjectQuery.OrgId, | ||
| 291 | }) | 311 | }) |
| 292 | if err != nil { | 312 | if err != nil { |
| 293 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 313 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
| @@ -301,10 +321,32 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | @@ -301,10 +321,32 @@ func (cooperationProjectService *CooperationProjectService) GetCooperationProjec | ||
| 301 | undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3) | 321 | undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3) |
| 302 | } | 322 | } |
| 303 | 323 | ||
| 304 | - // TODO 返回所有员工类型的申请通过人 | 324 | + // 返回所有员工类型的申请通过人 |
| 325 | + applicants := make([]*domain.User, 0) | ||
| 326 | + // 获取当前项目的所有申请 | ||
| 327 | + if countApplication, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{ | ||
| 328 | + "cooperationProjectNumberExact": cooperationProject.CooperationProjectNumber, | ||
| 329 | + "companyId": cooperationProject.Company.CompanyId, | ||
| 330 | + "orgId": cooperationProject.Org.OrgId, | ||
| 331 | + }); err != nil { | ||
| 332 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
| 333 | + } else { | ||
| 334 | + if countApplication > 0 { | ||
| 335 | + for _, cooperationApplication := range cooperationApplications { | ||
| 336 | + log.Logger.Info("申请人", map[string]interface{}{ | ||
| 337 | + "applicant": cooperationApplication.CooperationApplicationApplicant, | ||
| 338 | + }) | ||
| 339 | + userType := cooperationApplication.CooperationApplicationApplicant.UserType & 1 | ||
| 340 | + fmt.Printf("用户类型值: %d\n", userType) | ||
| 341 | + if userType == 1 && cooperationApplication.CooperationApplicationStatus == 2 { // 申请人中的员工类型,审核中通过的 | ||
| 342 | + applicants = append(applicants, cooperationApplication.CooperationApplicationApplicant) | ||
| 343 | + } | ||
| 344 | + } | ||
| 345 | + } | ||
| 346 | + } | ||
| 305 | 347 | ||
| 306 | cooperationProjectDto := &dto.CooperationProjectsDto{} | 348 | cooperationProjectDto := &dto.CooperationProjectsDto{} |
| 307 | - if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable); err != nil { | 349 | + if err := cooperationProjectDto.LoadDto(cooperationProject, nil, undertakerTypesUncheckedAvailable, applicants); err != nil { |
| 308 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 350 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 309 | } | 351 | } |
| 310 | if err := transactionContext.CommitTransaction(); err != nil { | 352 | if err := transactionContext.CommitTransaction(); err != nil { |
| @@ -118,6 +118,7 @@ func (dao *CooperationProjectDao) CheckProjectNameAvailable(queryOptions map[str | @@ -118,6 +118,7 @@ func (dao *CooperationProjectDao) CheckProjectNameAvailable(queryOptions map[str | ||
| 118 | if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { | 118 | if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { |
| 119 | query = query.Where(`cooperation_project.org @> '{"orgId":"?"}'`, orgId) | 119 | query = query.Where(`cooperation_project.org @> '{"orgId":"?"}'`, orgId) |
| 120 | } | 120 | } |
| 121 | + query.Where("cooperation_project.status = ?", 1) | ||
| 121 | ok, err := query.Exists() | 122 | ok, err := query.Exists() |
| 122 | return !ok, err | 123 | return !ok, err |
| 123 | } | 124 | } |
| @@ -231,6 +231,9 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string | @@ -231,6 +231,9 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string | ||
| 231 | if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" { | 231 | if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" { |
| 232 | query.Where("cooperation_project_number like ?", fmt.Sprintf("%%%s%%", cooperationProjectNumber)) | 232 | query.Where("cooperation_project_number like ?", fmt.Sprintf("%%%s%%", cooperationProjectNumber)) |
| 233 | } | 233 | } |
| 234 | + if cooperationProjectNumberExact, ok := queryOptions["cooperationProjectNumberExact"]; ok && cooperationProjectNumberExact != "" { | ||
| 235 | + query.Where("cooperation_project_number = ? ", cooperationProjectNumberExact) | ||
| 236 | + } | ||
| 234 | if cooperationProjectName, ok := queryOptions["cooperationProjectName"]; ok && cooperationProjectName != "" { | 237 | if cooperationProjectName, ok := queryOptions["cooperationProjectName"]; ok && cooperationProjectName != "" { |
| 235 | query.Join("LEFT JOIN cooperation_projects AS a"). | 238 | query.Join("LEFT JOIN cooperation_projects AS a"). |
| 236 | JoinOn("a.cooperation_project_number = cooperation_application.cooperation_project_number"). | 239 | JoinOn("a.cooperation_project_number = cooperation_application.cooperation_project_number"). |
-
请 注册 或 登录 后发表评论