作者 陈志颖

refactor:优化分红预算

@@ -689,6 +689,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -689,6 +689,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
689 } 689 }
690 } 690 }
691 691
  692 + log.Logger.Info("查询共创合约", map[string]interface{}{
  693 + "cooperationContractsMap": cooperationContractsMap,
  694 + })
  695 +
692 // 查询共创项目 696 // 查询共创项目
693 cooperationProjectsMap := make(map[string]*domain.CooperationProject, 0) 697 cooperationProjectsMap := make(map[string]*domain.CooperationProject, 0)
694 if count, cooperationProjectsFound, err := cooperationProjectRepository.Find(map[string]interface{}{ 698 if count, cooperationProjectsFound, err := cooperationProjectRepository.Find(map[string]interface{}{
@@ -705,6 +709,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -705,6 +709,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
705 } 709 }
706 } 710 }
707 711
  712 + log.Logger.Info("查询共创项目", map[string]interface{}{
  713 + "cooperationProjectsMap": cooperationProjectsMap,
  714 + })
  715 +
708 // 统计成功预算的分红订单 716 // 统计成功预算的分红订单
709 estimateSuccessfullyDividendsOrders := make(map[string]string) 717 estimateSuccessfullyDividendsOrders := make(map[string]string)
710 718
@@ -8,7 +8,6 @@ import ( @@ -8,7 +8,6 @@ import (
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
11 - "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"  
12 ) 11 )
13 12
14 type ConfirmDividendsIncentivesEstimateService struct { 13 type ConfirmDividendsIncentivesEstimateService struct {
@@ -85,12 +84,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -85,12 +84,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
85 84
86 // 确认业绩分红预算 85 // 确认业绩分红预算
87 var dividendsEstimateDetails []*service.DividendsEstimateDetail 86 var dividendsEstimateDetails []*service.DividendsEstimateDetail
88 - go func() {  
89 for _, orderGood := range orderGoods { 87 for _, orderGood := range orderGoods {
90 - log.Logger.Info("业绩分红预算产品", map[string]interface{}{  
91 - "orderGood": orderGood,  
92 - })  
93 -  
94 if orderGood.CooperationContractNumber == "" { 88 if orderGood.CooperationContractNumber == "" {
95 var orderNumber string 89 var orderNumber string
96 if orderGood.DividendsOrderNumber != "" { 90 if orderGood.DividendsOrderNumber != "" {
@@ -462,6 +456,18 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -462,6 +456,18 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
462 } 456 }
463 } 457 }
464 // 计算分红 458 // 计算分红
  459 + if len(cooperationContract.Undertakers) <= 0 {
  460 + dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  461 + DividendsUser: nil,
  462 + DividendsParticipateType: 0,
  463 + DividendsStage: 0,
  464 + DividendsAmount: 0,
  465 + OrderOrReturnedOrderNumber: orderGood.DividendsReturnedOrderNumber,
  466 + IsSuccessfully: false,
  467 + Reason: "合约承接人不存在",
  468 + })
  469 + continue
  470 + } else {
465 for _, undertaker := range cooperationContract.Undertakers { 471 for _, undertaker := range cooperationContract.Undertakers {
466 // 添加承接人分红退货预算信息详情 472 // 添加承接人分红退货预算信息详情
467 if dividendsIncentivesRuleMatched.DividendsIncentivesPercentage > 0 { 473 if dividendsIncentivesRuleMatched.DividendsIncentivesPercentage > 0 {
@@ -551,7 +557,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -551,7 +557,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
551 } 557 }
552 } 558 }
553 } 559 }
554 - }() 560 + }
555 561
556 return dividendsEstimateDetails, nil 562 return dividendsEstimateDetails, nil
557 } 563 }