作者 陈志颖

test:测试预算分红

@@ -699,6 +699,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -699,6 +699,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
699 // 统计预算失败的分红订单 699 // 统计预算失败的分红订单
700 estimateFailedDividendsOrders := make(map[string]string) 700 estimateFailedDividendsOrders := make(map[string]string)
701 701
  702 + initRepo := time.Since(start)
  703 + log.Logger.Info("初始化耗时", map[string]interface{}{
  704 + "初始化耗时": initRepo,
  705 + })
  706 +
  707 + startFindOrderGood := time.Now() // 获取当前时间
  708 +
702 // 获取订单产品 709 // 获取订单产品
703 if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{ 710 if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{
704 "orderGoodIds": orderGoodIds, 711 "orderGoodIds": orderGoodIds,
@@ -706,6 +713,12 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -706,6 +713,12 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
706 }); err != nil { 713 }); err != nil {
707 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 714 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
708 } else { 715 } else {
  716 +
  717 + findOrderGood := time.Since(startFindOrderGood)
  718 + log.Logger.Info("查询预算产品耗时", map[string]interface{}{
  719 + "初始化耗时": findOrderGood,
  720 + })
  721 +
709 dividendsEstimates := make([]*domain.DividendsEstimate, 0) 722 dividendsEstimates := make([]*domain.DividendsEstimate, 0)
710 723
711 var cooperationContractNumbers []string 724 var cooperationContractNumbers []string
@@ -715,6 +728,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -715,6 +728,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
715 cooperationContractNumbers = append(cooperationContractNumbers, orderGood.CooperationContractNumber) 728 cooperationContractNumbers = append(cooperationContractNumbers, orderGood.CooperationContractNumber)
716 } 729 }
717 730
  731 + startFindContracts := time.Now()
  732 +
718 // 查询共创合约 733 // 查询共创合约
719 cooperationContractsMap := make(map[string]*domain.CooperationContract, 0) 734 cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
720 if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{ 735 if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
@@ -732,6 +747,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -732,6 +747,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
732 } 747 }
733 } 748 }
734 749
  750 + endFindContracts := time.Since(startFindContracts)
  751 + log.Logger.Info("查询合约耗时", map[string]interface{}{
  752 + "查询合约耗时": endFindContracts,
  753 + })
  754 +
735 log.Logger.Info("查询共创合约", map[string]interface{}{ 755 log.Logger.Info("查询共创合约", map[string]interface{}{
736 "cooperationContractsMap": cooperationContractsMap, 756 "cooperationContractsMap": cooperationContractsMap,
737 }) 757 })
@@ -746,6 +766,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -746,6 +766,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
746 766
747 var countDividendsEstimate int64 767 var countDividendsEstimate int64
748 768
  769 + startConfirm := time.Now()
  770 +
749 for _, orderGood := range orderGoods { 771 for _, orderGood := range orderGoods {
750 dividendsEstimate := &domain.DividendsEstimate{} 772 dividendsEstimate := &domain.DividendsEstimate{}
751 if orderGood.DividendsOrderNumber != "" { // 查询分红订单 773 if orderGood.DividendsOrderNumber != "" { // 查询分红订单
@@ -863,10 +885,17 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -863,10 +885,17 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
863 } 885 }
864 } 886 }
865 887
  888 + endConfirm := time.Since(startConfirm)
  889 + log.Logger.Info("预算耗时", map[string]interface{}{
  890 + "预算耗时": endConfirm,
  891 + })
  892 +
866 log.Logger.Info("新增的分红预算单", map[string]interface{}{ 893 log.Logger.Info("新增的分红预算单", map[string]interface{}{
867 "dividendsEstimates": dividendsEstimates, 894 "dividendsEstimates": dividendsEstimates,
868 }) 895 })
869 896
  897 + startSave := time.Now()
  898 +
870 if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil { 899 if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil {
871 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 900 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
872 } else { 901 } else {
@@ -1031,6 +1060,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -1031,6 +1060,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
1031 elapsed := time.Since(start) 1060 elapsed := time.Since(start)
1032 fmt.Println("该函数执行完成耗时:", elapsed) 1061 fmt.Println("该函数执行完成耗时:", elapsed)
1033 1062
  1063 + endSave := time.Since(startSave)
  1064 + log.Logger.Info("保存预算单耗时", map[string]interface{}{
  1065 + "保存预算单耗时": endSave,
  1066 + })
  1067 +
1034 return map[string]interface{}{ 1068 return map[string]interface{}{
1035 "report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr), 1069 "report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr),
1036 }, nil 1070 }, nil