|
@@ -459,29 +459,91 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro |
|
@@ -459,29 +459,91 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro |
459
|
cooperationProjectRepository = value
|
459
|
cooperationProjectRepository = value
|
460
|
}
|
460
|
}
|
461
|
|
461
|
|
|
|
462
|
+ // 共创申请仓储初始化
|
|
|
463
|
+ var cooperationApplicationRepository domain.CooperationApplicationRepository
|
|
|
464
|
+ if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
|
|
|
465
|
+ "transactionContext": transactionContext,
|
|
|
466
|
+ }); err != nil {
|
|
|
467
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
468
|
+ } else {
|
|
|
469
|
+ cooperationApplicationRepository = value
|
|
|
470
|
+ }
|
|
|
471
|
+
|
|
|
472
|
+ // 共创项目ID类型转换
|
462
|
cooperationProjectId, err := strconv.ParseInt(updateCooperationProjectCommand.CooperationProjectId, 10, 64)
|
473
|
cooperationProjectId, err := strconv.ParseInt(updateCooperationProjectCommand.CooperationProjectId, 10, 64)
|
463
|
if err != nil {
|
474
|
if err != nil {
|
464
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目编号类型错误")
|
475
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目编号类型错误")
|
465
|
}
|
476
|
}
|
466
|
|
477
|
|
467
|
// 查找共创项目
|
478
|
// 查找共创项目
|
468
|
- cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": cooperationProjectId})
|
479
|
+ cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
|
|
|
480
|
+ "cooperationProjectId": cooperationProjectId,
|
|
|
481
|
+ })
|
469
|
if err != nil {
|
482
|
if err != nil {
|
470
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
483
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
471
|
}
|
484
|
}
|
472
|
if cooperationProject == nil {
|
485
|
if cooperationProject == nil {
|
473
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationProjectCommand.CooperationProjectId)))
|
486
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationProjectCommand.CooperationProjectId)))
|
474
|
}
|
487
|
}
|
|
|
488
|
+
|
|
|
489
|
+ applicantTypes := make(map[int32]interface{})
|
|
|
490
|
+
|
|
|
491
|
+ // 获取所有申请人
|
|
|
492
|
+ if count, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{
|
|
|
493
|
+ "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
|
|
|
494
|
+ "offsetLimit": false,
|
|
|
495
|
+ "companyId": updateCooperationProjectCommand.CompanyId,
|
|
|
496
|
+ "cooperationApplicationStatus": 2, // 共创申请审核状态,1待审核,2已同意,3已拒绝
|
|
|
497
|
+ }); err != nil {
|
|
|
498
|
+ return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
499
|
+ } else {
|
|
|
500
|
+ if count > 0 {
|
|
|
501
|
+ for _, cooperationApplication := range cooperationApplications {
|
|
|
502
|
+ applicantTypes[cooperationApplication.CooperationApplicationApplicant.UserType] = cooperationApplication.CooperationApplicationApplicant.UserType
|
|
|
503
|
+ }
|
|
|
504
|
+ }
|
|
|
505
|
+ }
|
|
|
506
|
+ var undertakerTypes []int32
|
|
|
507
|
+ var k1, k2 int32
|
|
|
508
|
+ if len(applicantTypes) > 0 {
|
|
|
509
|
+ for k, _ := range applicantTypes {
|
|
|
510
|
+ if k == 1 {
|
|
|
511
|
+ k1 = k
|
|
|
512
|
+ } else if k == 2 {
|
|
|
513
|
+ k2 = k
|
|
|
514
|
+ }
|
|
|
515
|
+ undertakerTypes = append(undertakerTypes, k)
|
|
|
516
|
+ }
|
|
|
517
|
+ }
|
|
|
518
|
+ if k1 != 0 && k2 != 0 {
|
|
|
519
|
+ undertakerTypes = append(undertakerTypes, 4)
|
|
|
520
|
+ }
|
|
|
521
|
+
|
|
|
522
|
+ // 校验可以修改的承接人(申请人)类型
|
|
|
523
|
+ for _, t := range undertakerTypes {
|
|
|
524
|
+ if !utils.IsContain(updateCooperationProjectCommand.CooperationProjectUndertakerTypes, t) {
|
|
|
525
|
+ switch t {
|
|
|
526
|
+ case 1:
|
|
|
527
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "承接对象'员工'存在业务数据,不可取消勾选")
|
|
|
528
|
+ case 2:
|
|
|
529
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "承接对象'共创用户'存在业务数据,不可取消勾选")
|
|
|
530
|
+ case 4:
|
|
|
531
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, "承接对象'公开'存在业务数据,不可取消勾选")
|
|
|
532
|
+ }
|
|
|
533
|
+ }
|
|
|
534
|
+ }
|
|
|
535
|
+
|
|
|
536
|
+ // 更新共创项目
|
475
|
if err := cooperationProject.Update(tool_funs.SimpleStructToMap(updateCooperationProjectCommand)); err != nil {
|
537
|
if err := cooperationProject.Update(tool_funs.SimpleStructToMap(updateCooperationProjectCommand)); err != nil {
|
476
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
538
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
477
|
}
|
539
|
}
|
478
|
- if cooperationProject, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
|
540
|
+ if cooperationProjectSaved, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
|
479
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
541
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
480
|
} else {
|
542
|
} else {
|
481
|
if err := transactionContext.CommitTransaction(); err != nil {
|
543
|
if err := transactionContext.CommitTransaction(); err != nil {
|
482
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
544
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
483
|
}
|
545
|
}
|
484
|
- return cooperationProject, nil
|
546
|
+ return cooperationProjectSaved, nil
|
485
|
}
|
547
|
}
|
486
|
}
|
548
|
}
|
487
|
|
549
|
|