...
|
...
|
@@ -459,29 +459,91 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro |
|
|
cooperationProjectRepository = value
|
|
|
}
|
|
|
|
|
|
// 共创申请仓储初始化
|
|
|
var cooperationApplicationRepository domain.CooperationApplicationRepository
|
|
|
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
cooperationApplicationRepository = value
|
|
|
}
|
|
|
|
|
|
// 共创项目ID类型转换
|
|
|
cooperationProjectId, err := strconv.ParseInt(updateCooperationProjectCommand.CooperationProjectId, 10, 64)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目编号类型错误")
|
|
|
}
|
|
|
|
|
|
// 查找共创项目
|
|
|
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": cooperationProjectId})
|
|
|
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
|
|
|
"cooperationProjectId": cooperationProjectId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if cooperationProject == nil {
|
|
|
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationProjectCommand.CooperationProjectId)))
|
|
|
}
|
|
|
|
|
|
applicantTypes := make(map[int32]interface{})
|
|
|
|
|
|
// 获取所有申请人
|
|
|
if count, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{
|
|
|
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
|
|
|
"offsetLimit": false,
|
|
|
"companyId": updateCooperationProjectCommand.CompanyId,
|
|
|
"cooperationApplicationStatus": 2, // 共创申请审核状态,1待审核,2已同意,3已拒绝
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if count > 0 {
|
|
|
for _, cooperationApplication := range cooperationApplications {
|
|
|
applicantTypes[cooperationApplication.CooperationApplicationApplicant.UserType] = cooperationApplication.CooperationApplicationApplicant.UserType
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
var undertakerTypes []int32
|
|
|
var k1, k2 int32
|
|
|
if len(applicantTypes) > 0 {
|
|
|
for k, _ := range applicantTypes {
|
|
|
if k == 1 {
|
|
|
k1 = k
|
|
|
} else if k == 2 {
|
|
|
k2 = k
|
|
|
}
|
|
|
undertakerTypes = append(undertakerTypes, k)
|
|
|
}
|
|
|
}
|
|
|
if k1 != 0 && k2 != 0 {
|
|
|
undertakerTypes = append(undertakerTypes, 4)
|
|
|
}
|
|
|
|
|
|
// 校验可以修改的承接人(申请人)类型
|
|
|
for _, t := range undertakerTypes {
|
|
|
if !utils.IsContain(updateCooperationProjectCommand.CooperationProjectUndertakerTypes, t) {
|
|
|
switch t {
|
|
|
case 1:
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "承接对象'员工'存在业务数据,不可取消勾选")
|
|
|
case 2:
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "承接对象'共创用户'存在业务数据,不可取消勾选")
|
|
|
case 4:
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, "承接对象'公开'存在业务数据,不可取消勾选")
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 更新共创项目
|
|
|
if err := cooperationProject.Update(tool_funs.SimpleStructToMap(updateCooperationProjectCommand)); err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
if cooperationProject, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
|
|
|
if cooperationProjectSaved, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return cooperationProject, nil
|
|
|
return cooperationProjectSaved, nil
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
|