作者 陈志颖

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

@@ -157,8 +157,8 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -157,8 +157,8 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
157 } 157 }
158 158
159 // BatchApprovalCooperationApplication 一键审核共创申请 159 // BatchApprovalCooperationApplication 一键审核共创申请
160 -func (cooperationApplicationService *CooperationApplicationService) BatchApprovalCooperationApplication(batchApprovalCooperatioinApplicatonCommand *command.BatchApprovalCooperationApplicationCommand) (interface{}, error) {  
161 - if err := batchApprovalCooperatioinApplicatonCommand.ValidateCommand(); err != nil { 160 +func (cooperationApplicationService *CooperationApplicationService) BatchApprovalCooperationApplication(batchApprovalCooperationApplicatonCommand *command.BatchApprovalCooperationApplicationCommand) (interface{}, error) {
  161 + if err := batchApprovalCooperationApplicatonCommand.ValidateCommand(); err != nil {
162 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 162 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
163 } 163 }
164 transactionContext, err := factory.CreateTransactionContext(nil) 164 transactionContext, err := factory.CreateTransactionContext(nil)
@@ -540,6 +540,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper @@ -540,6 +540,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper
540 defer func() { 540 defer func() {
541 _ = transactionContext.RollbackTransaction() 541 _ = transactionContext.RollbackTransaction()
542 }() 542 }()
  543 + // 共创合约仓储初始化
543 var cooperationContractRepository domain.CooperationContractRepository 544 var cooperationContractRepository domain.CooperationContractRepository
544 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{ 545 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
545 "transactionContext": transactionContext, 546 "transactionContext": transactionContext,
@@ -10,6 +10,7 @@ import ( @@ -10,6 +10,7 @@ import (
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" 12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
  13 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
13 "strconv" 14 "strconv"
14 "time" 15 "time"
15 ) 16 )
@@ -169,6 +170,7 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat @@ -169,6 +170,7 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat
169 defer func() { 170 defer func() {
170 _ = transactionContext.RollbackTransaction() 171 _ = transactionContext.RollbackTransaction()
171 }() 172 }()
  173 + // 分红预算仓储初始化
172 var dividendsEstimateRepository domain.DividendsEstimateRepository 174 var dividendsEstimateRepository domain.DividendsEstimateRepository
173 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ 175 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
174 "transactionContext": transactionContext, 176 "transactionContext": transactionContext,
@@ -216,10 +218,37 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs @@ -216,10 +218,37 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
216 defer func() { 218 defer func() {
217 _ = transactionContext.RollbackTransaction() 219 _ = transactionContext.RollbackTransaction()
218 }() 220 }()
219 - if err := transactionContext.CommitTransaction(); err != nil {  
220 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 221 + // 分红预算仓储初始化
  222 + var dividendsEstimateRepository domain.DividendsEstimateRepository
  223 + if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
  224 + "transactionContext": transactionContext,
  225 + }); err != nil {
  226 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  227 + } else {
  228 + dividendsEstimateRepository = value
  229 + }
  230 + dividendsEstimateIds, _ := utils.SliceAtoi(batchCancelEstimateCommand.DividendsEstimateIds)
  231 + if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
  232 + "dividendsEstimateIds": dividendsEstimateIds,
  233 + }); err != nil {
  234 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  235 + } else {
  236 + if count > 0 {
  237 + for i, _ := range dividendsEstimates {
  238 + dividendsEstimates[i].IsCanceled = true
  239 + }
  240 + dividendsEstimatesCanceled, err := dividendsEstimateRepository.UpdateMany(dividendsEstimates)
  241 + if err != nil {
  242 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  243 + }
  244 + if err := transactionContext.CommitTransaction(); err != nil {
  245 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  246 + }
  247 + return dividendsEstimatesCanceled, nil
  248 + } else {
  249 + return map[string]interface{}{}, nil
  250 + }
221 } 251 }
222 - return nil, nil  
223 } 252 }
224 253
225 // CreateDividendsEstimate 创建分红预算单 (预留) 254 // CreateDividendsEstimate 创建分红预算单 (预留)