作者 陈志颖

refactor:分红预算

@@ -521,6 +521,7 @@ func (dividendsEstimateService *DividendsEstimateService) CreateDividendsEstimat @@ -521,6 +521,7 @@ func (dividendsEstimateService *DividendsEstimateService) CreateDividendsEstimat
521 521
522 // ConfirmDividendsIncentivesEstimate 确定业绩激励分红预算 522 // ConfirmDividendsIncentivesEstimate 确定业绩激励分红预算
523 func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncentivesEstimate(confirmDividendsIncentivesEstimateCommand *command.ConfirmDividendsIncentivesEstimateCommand) (interface{}, error) { 523 func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncentivesEstimate(confirmDividendsIncentivesEstimateCommand *command.ConfirmDividendsIncentivesEstimateCommand) (interface{}, error) {
  524 + start := time.Now()
524 if err := confirmDividendsIncentivesEstimateCommand.ValidateCommand(); err != nil { 525 if err := confirmDividendsIncentivesEstimateCommand.ValidateCommand(); err != nil {
525 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 526 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
526 } 527 }
@@ -550,12 +551,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -550,12 +551,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
550 } 551 }
551 552
552 // 获取公司信息 553 // 获取公司信息
  554 + startGetCompany := time.Now()
553 var company *domain.Company 555 var company *domain.Company
554 if data, err := companyService.CompanyFrom(confirmDividendsIncentivesEstimateCommand.CompanyId); err != nil { 556 if data, err := companyService.CompanyFrom(confirmDividendsIncentivesEstimateCommand.CompanyId); err != nil {
555 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 557 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
556 } else { 558 } else {
557 company = data 559 company = data
558 } 560 }
  561 + fmt.Println("获取公司信息耗时:", time.Since(startGetCompany))
559 562
560 // 组织机构REST服务初始化 563 // 组织机构REST服务初始化
561 var organizationService service.OrgService 564 var organizationService service.OrgService
@@ -566,12 +569,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -566,12 +569,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
566 } 569 }
567 570
568 // 获取组织机构信息 571 // 获取组织机构信息
  572 + startGetOrg := time.Now()
569 var organization *domain.Org 573 var organization *domain.Org
570 if data, err := organizationService.OrgFrom(confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId); err != nil { 574 if data, err := organizationService.OrgFrom(confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId); err != nil {
571 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 575 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
572 } else { 576 } else {
573 organization = data 577 organization = data
574 } 578 }
  579 + fmt.Println("获取组织机构数据耗时:", time.Since(startGetOrg))
575 580
576 // 用户REST服务初始化 581 // 用户REST服务初始化
577 var userService service.UserService 582 var userService service.UserService
@@ -582,12 +587,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -582,12 +587,14 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
582 } 587 }
583 588
584 // 获取操作人 589 // 获取操作人
  590 + startGetOperator := time.Now()
585 var operator *domain.User 591 var operator *domain.User
586 if data, err := userService.OperatorFrom(confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, confirmDividendsIncentivesEstimateCommand.UserId); err != nil { 592 if data, err := userService.OperatorFrom(confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, confirmDividendsIncentivesEstimateCommand.UserId); err != nil {
587 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 593 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
588 } else { 594 } else {
589 operator = data 595 operator = data
590 } 596 }
  597 + fmt.Println("获取操作人耗时:", time.Since(startGetOperator))
591 598
592 // 订单产品仓储初始化 599 // 订单产品仓储初始化
593 var orderGoodRepository domain.OrderGoodRepository 600 var orderGoodRepository domain.OrderGoodRepository
@@ -669,12 +676,15 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -669,12 +676,15 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
669 estimateFailedDividendsOrders := make(map[string]string) 676 estimateFailedDividendsOrders := make(map[string]string)
670 677
671 // 获取订单产品 678 // 获取订单产品
  679 + startGetOrderGoods := time.Now()
672 if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{ 680 if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{
673 "orderGoodIds": orderGoodIds, 681 "orderGoodIds": orderGoodIds,
674 "offsetLimit": false, 682 "offsetLimit": false,
675 }); err != nil { 683 }); err != nil {
676 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 684 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
677 } else { 685 } else {
  686 + fmt.Println("获取订单产品耗时:", time.Since(startGetOrderGoods))
  687 +
678 dividendsEstimates := make([]*domain.DividendsEstimate, 0) 688 dividendsEstimates := make([]*domain.DividendsEstimate, 0)
679 689
680 var cooperationContractNumbers []string 690 var cooperationContractNumbers []string
@@ -689,6 +699,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -689,6 +699,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
689 cooperationContractsMap := make(map[string]*domain.CooperationContract, 0) 699 cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
690 700
691 // 查询共创合约 701 // 查询共创合约
  702 + startQueryContracts := time.Now()
692 if len(newCooperationContractNumbers) > 0 { 703 if len(newCooperationContractNumbers) > 0 {
693 if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{ 704 if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
694 "cooperationContractNumbers": newCooperationContractNumbers, 705 "cooperationContractNumbers": newCooperationContractNumbers,
@@ -709,6 +720,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -709,6 +720,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
709 "report": fmt.Sprintf("已完成0单订单分红预算,生成0单分红预算,失败原因:产品未关联合约"), 720 "report": fmt.Sprintf("已完成0单订单分红预算,生成0单分红预算,失败原因:产品未关联合约"),
710 }, nil 721 }, nil
711 } 722 }
  723 + fmt.Println("查询共创合约耗时:", time.Since(startQueryContracts))
712 724
713 // 统计当前企业分红预算单数 725 // 统计当前企业分红预算单数
714 count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{ 726 count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
@@ -731,6 +743,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -731,6 +743,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
731 } 743 }
732 } 744 }
733 745
  746 + startConfirm := time.Now()
734 if len(orderGoodsToConfirm) > 0 { // 分红订单产品预算 747 if len(orderGoodsToConfirm) > 0 { // 分红订单产品预算
735 if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil { 748 if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
736 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 749 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -838,127 +851,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -838,127 +851,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
838 } 851 }
839 } 852 }
840 } 853 }
  854 + fmt.Println("订单分红耗时:", time.Since(startConfirm))
841 855
842 - //for _, orderGood := range orderGoods {  
843 - // dividendsEstimate := &domain.DividendsEstimate{}  
844 - // if orderGood.DividendsOrderNumber != "" { // 查询分红订单  
845 - // orderGoodsToConfirm := make([]*domain.OrderGood, 0)  
846 - // orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)  
847 - // // 分红订单产品预算  
848 - // if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {  
849 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
850 - // } else {  
851 - // for _, dividendsEstimateDetail := range dividendsEstimateDetails {  
852 - // if dividendsEstimateDetail.IsSuccessfully {  
853 - // // 生成分红预算单号  
854 - // dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)  
855 - // if err != nil {  
856 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
857 - // }  
858 - //  
859 - // // 记录成功的订单号  
860 - // estimateSuccessfullyDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.OrderOrReturnedOrderNumber  
861 - //  
862 - // // 统计分红预算单数目  
863 - // countDividendsEstimate = countDividendsEstimate + 1  
864 - //  
865 - // dividendsEstimate = &domain.DividendsEstimate{  
866 - // DividendsEstimateId: 0,  
867 - // DividendsAccountStatus: domain.TO_BE_ACCOUNT,  
868 - // DividendsAmount: dividendsEstimateDetail.DividendsAmount,  
869 - // DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,  
870 - // DividendsEstimateTime: time.Now(),  
871 - // DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType,  
872 - // DividendsType: domain.ORDER_DIVIDENDS,  
873 - // DividendsTypeName: "订单分红",  
874 - // OrderOrReturnedOrderNum: orderGood.DividendsOrderNumber,  
875 - // CooperationContractNumber: orderGood.CooperationContractNumber,  
876 - // DividendsUser: dividendsEstimateDetail.DividendsUser,  
877 - // DividendsPercentage: dividendsEstimateDetail.DividendsPercentage,  
878 - // DividendsStage: dividendsEstimateDetail.DividendsStage,  
879 - // Org: organization,  
880 - // Company: company,  
881 - // Operator: operator,  
882 - // OperateTime: time.Time{},  
883 - // IsCanceled: false,  
884 - // CreatedAt: time.Now(),  
885 - // DeletedAt: time.Time{},  
886 - // UpdatedAt: time.Time{},  
887 - // OrderGoodId: orderGood.OrderGoodId,  
888 - // OrderGoodAmount: orderGood.OrderGoodAmount,  
889 - // PaymentStatus: int32(1),  
890 - // CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId,  
891 - // }  
892 - //  
893 - // dividendsEstimates = append(dividendsEstimates, dividendsEstimate)  
894 - // } else {  
895 - // // 记录失败的订单号和原因  
896 - // estimateFailedDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.Reason  
897 - // }  
898 - // }  
899 - // }  
900 - // } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单  
901 - // orderGoodsToConfirm := make([]*domain.OrderGood, 0)  
902 - // orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)  
903 - // // 分红退货单产品预算  
904 - // if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {  
905 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
906 - // } else {  
907 - // for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {  
908 - // if dividendsReturnedEstimateDetail.IsSuccessfully {  
909 - // // 生成分红预算单号  
910 - // dividendsEstimateOrderNumber, err := dividendsReturnedEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)  
911 - // if err != nil {  
912 - // return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
913 - // }  
914 - //  
915 - // // 记录成功的退货单号  
916 - // estimateSuccessfullyDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber  
917 - //  
918 - // // 统计生成的预算单数量  
919 - // countDividendsEstimate = countDividendsEstimate + 1  
920 - //  
921 - // dividendsEstimate = &domain.DividendsEstimate{  
922 - // DividendsEstimateId: 0,  
923 - // DividendsAccountStatus: domain.TO_BE_ACCOUNT,  
924 - // DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount,  
925 - // DividendsEstimateOrderNumber: dividendsEstimateOrderNumber,  
926 - // DividendsEstimateTime: time.Now(),  
927 - // DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType,  
928 - // DividendsType: domain.RETURN_WRITE_OFF,  
929 - // DividendsTypeName: "退货冲销",  
930 - // OrderOrReturnedOrderNum: orderGood.DividendsReturnedOrderNumber,  
931 - // CooperationContractNumber: orderGood.CooperationContractNumber,  
932 - // DividendsUser: dividendsReturnedEstimateDetail.DividendsUser,  
933 - // DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage,  
934 - // DividendsStage: dividendsReturnedEstimateDetail.DividendsStage,  
935 - // Org: organization,  
936 - // Company: company,  
937 - // Operator: operator,  
938 - // OperateTime: time.Time{},  
939 - // IsCanceled: false,  
940 - // CreatedAt: time.Now(),  
941 - // DeletedAt: time.Time{},  
942 - // UpdatedAt: time.Time{},  
943 - // OrderGoodId: orderGood.OrderGoodId,  
944 - // OrderGoodAmount: orderGood.OrderGoodAmount,  
945 - // PaymentStatus: int32(1),  
946 - // CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId,  
947 - // }  
948 - //  
949 - // dividendsEstimates = append(dividendsEstimates, dividendsEstimate)  
950 - // } else {  
951 - // // 记录失败的退货单号和原因  
952 - // estimateFailedDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.Reason  
953 - // }  
954 - // }  
955 - // }  
956 - // }  
957 - //}  
958 - 856 + startInsert := time.Now()
959 if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil { 857 if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil {
960 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 858 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
961 } else { 859 } else {
  860 + fmt.Println("插入预算单耗时:", time.Since(startInsert))
962 // 获取产品ID 861 // 获取产品ID
963 orderGoodSavedIds := make([]int64, 0) 862 orderGoodSavedIds := make([]int64, 0)
964 for _, dividendsEstimate := range dividendsEstimates { 863 for _, dividendsEstimate := range dividendsEstimates {
@@ -966,6 +865,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -966,6 +865,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
966 } 865 }
967 866
968 // 更新订单产品分红状态 867 // 更新订单产品分红状态
  868 + startUpdateGoodStatus := time.Now()
969 var orderGoodsSaved []*domain.OrderGood 869 var orderGoodsSaved []*domain.OrderGood
970 if len(orderGoodSavedIds) > 0 { 870 if len(orderGoodSavedIds) > 0 {
971 // 订单产品ID去重 871 // 订单产品ID去重
@@ -987,6 +887,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -987,6 +887,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
987 } 887 }
988 } 888 }
989 } 889 }
  890 + fmt.Println("更新订单产品分红状态耗时:", time.Since(startUpdateGoodStatus))
990 891
991 // 分离分红订单和退货单 892 // 分离分红订单和退货单
992 dividendsOrderNumbers := make([]string, 0) 893 dividendsOrderNumbers := make([]string, 0)
@@ -1004,6 +905,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -1004,6 +905,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
1004 } 905 }
1005 906
1006 // 查找分红订单 907 // 查找分红订单
  908 + startUpdateOrder := time.Now()
1007 if len(dividendsOrderNumbers) > 0 { 909 if len(dividendsOrderNumbers) > 0 {
1008 if countDividendsOrdersFound, dividendsOrdersFound, err := dividendsOrderRepository.Find(map[string]interface{}{ 910 if countDividendsOrdersFound, dividendsOrdersFound, err := dividendsOrderRepository.Find(map[string]interface{}{
1009 "dividendsOrderNumbers": dividendsOrderNumbers, 911 "dividendsOrderNumbers": dividendsOrderNumbers,
@@ -1046,8 +948,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -1046,8 +948,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
1046 } 948 }
1047 } 949 }
1048 } 950 }
  951 + fmt.Println("更新订单耗时:", time.Since(startUpdateOrder))
1049 952
1050 // 查找分红退货单 953 // 查找分红退货单
  954 + startUpdateReturnedOrder := time.Now()
1051 if len(dividendsReturnedOrderNumbers) > 0 { 955 if len(dividendsReturnedOrderNumbers) > 0 {
1052 if countDividendsReturnedOrdersFound, dividendsReturnedOrdersFound, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{ 956 if countDividendsReturnedOrdersFound, dividendsReturnedOrdersFound, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{
1053 "dividendsReturnedOrderNumbers": dividendsReturnedOrderNumbers, 957 "dividendsReturnedOrderNumbers": dividendsReturnedOrderNumbers,
@@ -1090,9 +994,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -1090,9 +994,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
1090 } 994 }
1091 } 995 }
1092 996
  997 + fmt.Println("更新退货单耗时:", time.Since(startUpdateReturnedOrder))
  998 +
  999 + startCommit := time.Now()
1093 if err := transactionContext.CommitTransaction(); err != nil { 1000 if err := transactionContext.CommitTransaction(); err != nil {
1094 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1001 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1095 } 1002 }
  1003 + fmt.Println("提交事务耗时:", time.Since(startCommit))
1096 1004
1097 // 统计成功的分红预算 1005 // 统计成功的分红预算
1098 successfullyCount := len(dividendsEstimatesSaved) 1006 successfullyCount := len(dividendsEstimatesSaved)
@@ -1109,6 +1017,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -1109,6 +1017,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
1109 failedReasonStr = "无" 1017 failedReasonStr = "无"
1110 } 1018 }
1111 1019
  1020 + fmt.Println("函数执行完毕:", time.Since(start))
  1021 +
1112 return map[string]interface{}{ 1022 return map[string]interface{}{
1113 "report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr), 1023 "report": fmt.Sprintf("已完成%d单订单分红预算,生成%d单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr),
1114 }, nil 1024 }, nil
@@ -26,7 +26,7 @@ func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber(queryOptions ma @@ -26,7 +26,7 @@ func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber(queryOptions ma
26 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { 26 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
27 query = query.Where(`dividends_estimate.company @> '{"companyId":"?"}'`, companyId) 27 query = query.Where(`dividends_estimate.company @> '{"companyId":"?"}'`, companyId)
28 } 28 }
29 - if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { 29 + if count, err := query.AllWithDeleted().Count(); err != nil {
30 return "", err 30 return "", err
31 } else { 31 } else {
32 if count < 1000 { 32 if count < 1000 {
@@ -118,7 +118,7 @@ func (dao *DividendsEstimateDao) CountDividendsEstimate(queryOptions map[string] @@ -118,7 +118,7 @@ func (dao *DividendsEstimateDao) CountDividendsEstimate(queryOptions map[string]
118 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 { 118 if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
119 query = query.Where(`dividends_estimate.org @> '{"orgId":"?"}'`, orgId) 119 query = query.Where(`dividends_estimate.org @> '{"orgId":"?"}'`, orgId)
120 } 120 }
121 - if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { 121 + if count, err := query.AllWithDeleted().Count(); err != nil {
122 return 0, err 122 return 0, err
123 } else { 123 } else {
124 return count, nil 124 return count, nil