...
|
...
|
@@ -7,6 +7,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/dto"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationApplication/query"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/event/subscriber"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
|
...
|
...
|
@@ -346,6 +347,32 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova |
|
|
cooperationApplicationRepository = value
|
|
|
}
|
|
|
|
|
|
// 同意共创申请消息推送领域服务初始化
|
|
|
var agreeContractApplicationService service.AgreeContractApplicationService
|
|
|
if value, err := factory.CreateAgreeContractApplicationService(map[string]interface{}{
|
|
|
//"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
agreeContractApplicationService = value
|
|
|
_ = agreeContractApplicationService.Subscribe(&subscriber.MessageServiceSubscriber{
|
|
|
//TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 拒绝共创申请消息推送领域服务初始化
|
|
|
var rejectContractApplicationService service.RejectContractApplicationService
|
|
|
if value, err := factory.CreateRejectContractApplicationService(map[string]interface{}{
|
|
|
//"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
rejectContractApplicationService = value
|
|
|
_ = rejectContractApplicationService.Subscribe(&subscriber.MessageServiceSubscriber{
|
|
|
//TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
|
|
|
})
|
|
|
}
|
|
|
|
|
|
// 共创申请ID类型转换
|
|
|
cooperationApplicationIds, err := utils.SliceAtoi(batchApprovalCooperationApplicationCommand.CooperationApplicationIds)
|
|
|
if err != nil {
|
...
|
...
|
@@ -379,7 +406,7 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova |
|
|
for i, cooperationApplication := range cooperationApplications {
|
|
|
// 校验共创申请是否已经审核过
|
|
|
if cooperationApplication.CooperationApplicationStatus != 1 {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "改申请已经审核过")
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "该申请已经审核过")
|
|
|
}
|
|
|
// 更新共创申请数据
|
|
|
cooperationApplications[i].CooperationApplicationVerifyDescription = batchApprovalCooperationApplicationCommand.CooperationApplicationVerifyDescription
|
...
|
...
|
@@ -392,13 +419,45 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova |
|
|
cooperationApplications[i].CooperationApplicationVerifyTime = time.Now()
|
|
|
cooperationApplications[i].IsCanceled = 1
|
|
|
}
|
|
|
|
|
|
cooperationApplicationsApproved, err := cooperationApplicationRepository.UpdateMany(cooperationApplications)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
// 推送消息
|
|
|
for _, cooperationApplicationApproved := range cooperationApplicationsApproved {
|
|
|
if cooperationApplicationApproved.CooperationApplicationStatus == 2 {
|
|
|
if err1 := agreeContractApplicationService.Agree(
|
|
|
cooperationApplicationApproved.CooperationProject.CooperationProjectId,
|
|
|
cooperationApplicationApproved.CooperationProject.CooperationProjectName,
|
|
|
cooperationApplicationApproved.CooperationProject.CooperationProjectNumber,
|
|
|
cooperationApplicationApproved.CooperationApplicationApplicant.UserId,
|
|
|
cooperationApplicationApproved.CooperationApplicationApplicant.UserBaseId,
|
|
|
cooperationApplicationApproved.CooperationProject.Org.OrgId,
|
|
|
cooperationApplicationApproved.CooperationProject.Company.CompanyId,
|
|
|
); err1 != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err1.Error())
|
|
|
}
|
|
|
} else if cooperationApplicationApproved.CooperationApplicationStatus == 3 {
|
|
|
if err2 := rejectContractApplicationService.Reject(
|
|
|
cooperationApplicationApproved.CooperationProject.CooperationProjectId,
|
|
|
cooperationApplicationApproved.CooperationProject.CooperationProjectName,
|
|
|
cooperationApplicationApproved.CooperationProject.CooperationProjectNumber,
|
|
|
cooperationApplicationApproved.CooperationApplicationApplicant.UserId,
|
|
|
cooperationApplicationApproved.CooperationApplicationApplicant.UserBaseId,
|
|
|
cooperationApplicationApproved.CooperationProject.Org.OrgId,
|
|
|
cooperationApplicationApproved.CooperationProject.Company.CompanyId,
|
|
|
); err2 != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error())
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return map[string]interface{}{
|
|
|
"cooperationApplications": cooperationApplicationsApproved,
|
|
|
}, nil
|
...
|
...
|
|