作者 陈志颖

feat:分红预算批量取消功能开发

... ... @@ -157,8 +157,8 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
}
// BatchApprovalCooperationApplication 一键审核共创申请
func (cooperationApplicationService *CooperationApplicationService) BatchApprovalCooperationApplication(batchApprovalCooperatioinApplicatonCommand *command.BatchApprovalCooperationApplicationCommand) (interface{}, error) {
if err := batchApprovalCooperatioinApplicatonCommand.ValidateCommand(); err != nil {
func (cooperationApplicationService *CooperationApplicationService) BatchApprovalCooperationApplication(batchApprovalCooperationApplicatonCommand *command.BatchApprovalCooperationApplicationCommand) (interface{}, error) {
if err := batchApprovalCooperationApplicatonCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
... ...
... ... @@ -540,6 +540,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 共创合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ...
... ... @@ -10,6 +10,7 @@ import (
"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"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"strconv"
"time"
)
... ... @@ -169,6 +170,7 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 分红预算仓储初始化
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -216,10 +218,37 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 分红预算仓储初始化
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsEstimateRepository = value
}
dividendsEstimateIds, _ := utils.SliceAtoi(batchCancelEstimateCommand.DividendsEstimateIds)
if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
"dividendsEstimateIds": dividendsEstimateIds,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if count > 0 {
for i, _ := range dividendsEstimates {
dividendsEstimates[i].IsCanceled = true
}
dividendsEstimatesCanceled, err := dividendsEstimateRepository.UpdateMany(dividendsEstimates)
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())
}
return nil, nil
return dividendsEstimatesCanceled, nil
} else {
return map[string]interface{}{}, nil
}
}
}
// CreateDividendsEstimate 创建分红预算单 (预留)
... ...