作者 陈志颖

feat:账期结算增加校验

@@ -308,39 +308,10 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje @@ -308,39 +308,10 @@ func (cooperationProjectService *CooperationProjectService) ListCooperationProje
308 if count, cooperationProjects, err := cooperationProjectRepository.Find(tool_funs.SimpleStructToMap(listCooperationProjectQuery)); err != nil { 308 if count, cooperationProjects, err := cooperationProjectRepository.Find(tool_funs.SimpleStructToMap(listCooperationProjectQuery)); err != nil {
309 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 309 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
310 } else { 310 } else {
311 - //var cooperationModeRepository domain.CooperationModeRepository  
312 - //if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{  
313 - // "transactionContext": transactionContext,  
314 - //}); err != nil {  
315 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
316 - //} else {  
317 - // cooperationProjectRepository = value  
318 - //}  
319 - //var modeMap = make(map[string]*domain.CooperationMode)  
320 - //if _, cooperationProjects, err := cooperationModeRepository.Find(map[string]interface{}{"companyId":listCooperationProjectQuery.CompanyId,"orgId":listCooperationProjectQuery.OrgId}); err != nil {  
321 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
322 - //}else{  
323 - // for i:=range cooperationProjects{  
324 - // p :=cooperationProjects[i]  
325 - // modeMap[p.CooperationModeNumber]=p  
326 - // }  
327 - //}  
328 - //  
329 - //var res []*dto.CooperationProjectsDto  
330 - //for i := range cooperationProjects {  
331 - // p := cooperationProjects[i]  
332 - // tp := &dto.CooperationProjectsDto{}  
333 - // tp.LoadDto(p, &domain.CooperationMode{})  
334 - // res = append(res, tp)  
335 - //}  
336 if err := transactionContext.CommitTransaction(); err != nil { 311 if err := transactionContext.CommitTransaction(); err != nil {
337 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 312 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
338 } 313 }
339 return map[string]interface{}{ 314 return map[string]interface{}{
340 - //"grid": map[string]interface{}{  
341 - //"total": count,  
342 - //"list": res,  
343 - //},  
344 "list": cooperationProjects, 315 "list": cooperationProjects,
345 "total": count, 316 "total": count,
346 }, nil 317 }, nil
@@ -119,6 +119,16 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred @@ -119,6 +119,16 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
119 }); err != nil { 119 }); err != nil {
120 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 120 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
121 } else { 121 } else {
  122 + // 校验分红预算单是否可以进行预算
  123 + for _, dividendsEstimate := range dividendsEstimates {
  124 + if dividendsEstimate.DividendsAccountStatus == 2 {
  125 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "请勾选“待结算”的分红单结算")
  126 + }
  127 + if dividendsEstimate.IsCanceled {
  128 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "请勾选未取消的分红单结算")
  129 + }
  130 + }
  131 + // 预算操作
122 var creditAccounts []*domain.CreditAccount 132 var creditAccounts []*domain.CreditAccount
123 for _, dividendsEstimate := range dividendsEstimates { 133 for _, dividendsEstimate := range dividendsEstimates {
124 // 生成账期结算单号 134 // 生成账期结算单号
@@ -140,6 +140,8 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentivesEst @@ -140,6 +140,8 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentivesEst
140 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 140 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
141 } else { 141 } else {
142 // TODO 判断承接人是否已分红 142 // TODO 判断承接人是否已分红
  143 +
  144 + // 数据传输对象
143 var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto 145 var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
144 for _, cooperationContract := range cooperationContracts { 146 for _, cooperationContract := range cooperationContracts {
145 moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{} 147 moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
@@ -45,3 +45,11 @@ func CreateConfirmMoneyIncentivesEstimateService(options map[string]interface{}) @@ -45,3 +45,11 @@ func CreateConfirmMoneyIncentivesEstimateService(options map[string]interface{})
45 } 45 }
46 return domain_service.NewConfirmMoneyIncentivesEstimateService(transactionContext) 46 return domain_service.NewConfirmMoneyIncentivesEstimateService(transactionContext)
47 } 47 }
  48 +
  49 +func CreateCancelDividendsEstimateService(options map[string]interface{}) (*domain_service.CancelDividendsEstimateService, error) {
  50 + var transactionContext *pgTransaction.TransactionContext
  51 + if value, ok := options["transactionContext"]; ok {
  52 + transactionContext = value.(*pgTransaction.TransactionContext)
  53 + }
  54 + return domain_service.NewCancelDividendsEstimateService(transactionContext)
  55 +}
1 package service 1 package service
2 2
  3 +import (
  4 + coreDomain "github.com/linmadan/egglib-go/core/domain"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  6 +)
  7 +
3 type CancelDividendsEstimate interface { 8 type CancelDividendsEstimate interface {
4 - CancelEstimate() 9 + coreDomain.DomainEventPublisher
  10 + CancelEstimate(dividendsEstimateId int64, operatorId int64) ([]*domain.DividendsEstimate, error)
5 } 11 }
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "fmt" 4 "fmt"
5 coreDomain "github.com/linmadan/egglib-go/core/domain" 5 coreDomain "github.com/linmadan/egglib-go/core/domain"
6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
7 ) 8 )
8 9
9 type CancelDividendsEstimateService struct { 10 type CancelDividendsEstimateService struct {
@@ -11,8 +12,8 @@ type CancelDividendsEstimateService struct { @@ -11,8 +12,8 @@ type CancelDividendsEstimateService struct {
11 transactionContext *pgTransaction.TransactionContext 12 transactionContext *pgTransaction.TransactionContext
12 } 13 }
13 14
14 -func (c *CancelDividendsEstimateService) CancelEstimate() {  
15 - panic("implement me") 15 +func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEstimateId int64, operatorId int64) ([]*domain.DividendsEstimate, error) {
  16 + return nil, nil
16 } 17 }
17 18
18 func NewCancelDividendsEstimateService(transactionContext *pgTransaction.TransactionContext) (*CancelDividendsEstimateService, error) { 19 func NewCancelDividendsEstimateService(transactionContext *pgTransaction.TransactionContext) (*CancelDividendsEstimateService, error) {