...
|
...
|
@@ -94,6 +94,26 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
|
organization = data
|
|
|
}
|
|
|
|
|
|
// 部门REST服务初始化
|
|
|
var departmentService service.DepartmentService
|
|
|
if value, err := factory.CreateDepartmentService(map[string]interface{}{}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
departmentService = value
|
|
|
}
|
|
|
|
|
|
// 获取部门
|
|
|
var department *domain.Department
|
|
|
departmentId, err := strconv.ParseInt(createCooperationContractCommand.DepartmentId, 10, 64)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
if data, err := departmentService.DepartmentFrom(createCooperationContractCommand.CompanyId, departmentId); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
department = data
|
|
|
}
|
|
|
|
|
|
// 共创合约DAO初始化
|
|
|
var cooperationContractDao *dao.CooperationContractDao
|
|
|
if value, err := factory.CreateCooperationContractDao(map[string]interface{}{
|
...
|
...
|
@@ -103,11 +123,13 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
|
} else {
|
|
|
cooperationContractDao = value
|
|
|
}
|
|
|
|
|
|
// 生成共创合约编号
|
|
|
contractNumber, err2 := cooperationContractDao.GenerateContractNumber()
|
|
|
if err2 != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error())
|
|
|
}
|
|
|
|
|
|
// 校验共创合约编号是否唯一
|
|
|
numberAvailable, _ := cooperationContractDao.CheckContractNumberAvailable(map[string]interface{}{
|
|
|
"companyId": createCooperationContractCommand.CompanyId,
|
...
|
...
|
@@ -122,7 +144,10 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
|
var undertakers []*domain.Undertaker
|
|
|
for _, undertaker := range createCooperationContractCommand.Undertakers {
|
|
|
var undertakerDomain *domain.Undertaker
|
|
|
undertakerUid, _ := strconv.ParseInt(undertaker.UserId, 10, 64)
|
|
|
undertakerUid, err := strconv.ParseInt(undertaker.UserId, 10, 64)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人UID错误")
|
|
|
}
|
|
|
if data, err := userService.UndertakerFrom(createCooperationContractCommand.CompanyId, createCooperationContractCommand.OrgId, undertakerUid); err != nil {
|
|
|
log.Logger.Error(err.Error())
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
@@ -268,6 +293,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC |
|
|
Status: 1,
|
|
|
Org: organization,
|
|
|
Company: company,
|
|
|
Department: department,
|
|
|
Operator: operator,
|
|
|
DividendsIncentivesRules: dividendsIncentivesRules,
|
|
|
MoneyIncentivesRules: moneyIncentivesRules,
|
...
|
...
|
@@ -339,14 +365,39 @@ func (cooperationContractService *CooperationContractService) GetCooperationCont |
|
|
} else {
|
|
|
cooperationContractDao = value
|
|
|
}
|
|
|
// 获取可删除的承接对象类型
|
|
|
undertakerTypesUncheckedAvailable, err := cooperationContractDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
|
|
|
|
|
|
// 可以去除勾选的承接人对象列表
|
|
|
var undertakerTypesUncheckedAvailable []int32
|
|
|
|
|
|
// 判断承接对象是否存在员工
|
|
|
gotUser, err := cooperationContractDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
|
|
|
"cooperationContractNumber": cooperationContract.CooperationContractNumber,
|
|
|
"user": true,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if !gotUser {
|
|
|
undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 1)
|
|
|
}
|
|
|
|
|
|
// 判断承接对象是否存在共创用户
|
|
|
gotPartner, err := cooperationContractDao.CheckUndertakerTypesUncheckedAvailable(map[string]interface{}{
|
|
|
"cooperationContractNumber": cooperationContract.CooperationContractNumber,
|
|
|
"cooperationContractUndertakerTypes": cooperationContract.CooperationContractUndertakerTypes,
|
|
|
"partner": true,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if !gotPartner {
|
|
|
undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 2)
|
|
|
}
|
|
|
|
|
|
// 判断承接人是否存在公开用户
|
|
|
if !gotUser && !gotPartner {
|
|
|
undertakerTypesUncheckedAvailable = append(undertakerTypesUncheckedAvailable, 3)
|
|
|
}
|
|
|
|
|
|
cooperationContractDto := &dto.CooperationContractDto{}
|
|
|
if err := cooperationContractDto.LoadDto(cooperationContract, undertakerTypesUncheckedAvailable); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
...
|
...
|
|