作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !77
@@ -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
@@ -649,16 +656,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -649,16 +656,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
649 cooperationContractRepository = value 656 cooperationContractRepository = value
650 } 657 }
651 658
652 - // 共创项目仓储初始化  
653 - //var cooperationProjectRepository domain.CooperationProjectRepository  
654 - //if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{  
655 - // "transactionContext": transactionContext,  
656 - //}); err != nil {  
657 - // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
658 - //} else {  
659 - // cooperationProjectRepository = value  
660 - //}  
661 -  
662 // 初始化确认业绩激励分红预算领域服务 659 // 初始化确认业绩激励分红预算领域服务
663 var confirmDividendsIncentivesEstimateService service.ConfirmDividendsIncentivesEstimateService 660 var confirmDividendsIncentivesEstimateService service.ConfirmDividendsIncentivesEstimateService
664 if value, err := factory.CreateConfirmDividendsIncentivesEstimateService(map[string]interface{}{ 661 if value, err := factory.CreateConfirmDividendsIncentivesEstimateService(map[string]interface{}{
@@ -672,26 +669,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -672,26 +669,6 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
672 }) 669 })
673 } 670 }
674 671
675 - // 查询共创项目  
676 - //cooperationProjectsMap := make(map[string]*domain.CooperationProject, 0)  
677 - //if count, cooperationProjectsFound, err := cooperationProjectRepository.Find(map[string]interface{}{  
678 - // "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,  
679 - // "orgId": confirmDividendsIncentivesEstimateCommand.OrgId,  
680 - // "offsetLimit": false,  
681 - //}); err != nil {  
682 - // return nil, err  
683 - //} else {  
684 - // if count > 0 {  
685 - // for _, cooperationProjectFound := range cooperationProjectsFound {  
686 - // cooperationProjectsMap[cooperationProjectFound.CooperationProjectNumber] = cooperationProjectFound  
687 - // }  
688 - // }  
689 - //}  
690 - //  
691 - //log.Logger.Info("查询共创项目", map[string]interface{}{  
692 - // "cooperationProjectsMap": cooperationProjectsMap,  
693 - //})  
694 -  
695 // 统计成功预算的分红订单 672 // 统计成功预算的分红订单
696 estimateSuccessfullyDividendsOrders := make(map[string]string) 673 estimateSuccessfullyDividendsOrders := make(map[string]string)
697 674
@@ -699,12 +676,15 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -699,12 +676,15 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
699 estimateFailedDividendsOrders := make(map[string]string) 676 estimateFailedDividendsOrders := make(map[string]string)
700 677
701 // 获取订单产品 678 // 获取订单产品
  679 + startGetOrderGoods := time.Now()
702 if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{ 680 if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{
703 "orderGoodIds": orderGoodIds, 681 "orderGoodIds": orderGoodIds,
704 "offsetLimit": false, 682 "offsetLimit": false,
705 }); err != nil { 683 }); err != nil {
706 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 684 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
707 } else { 685 } else {
  686 + fmt.Println("获取订单产品耗时:", time.Since(startGetOrderGoods))
  687 +
708 dividendsEstimates := make([]*domain.DividendsEstimate, 0) 688 dividendsEstimates := make([]*domain.DividendsEstimate, 0)
709 689
710 var cooperationContractNumbers []string 690 var cooperationContractNumbers []string
@@ -716,8 +696,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -716,8 +696,11 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
716 696
717 newCooperationContractNumbers := utils.RemoveDuplicationString(cooperationContractNumbers) 697 newCooperationContractNumbers := utils.RemoveDuplicationString(cooperationContractNumbers)
718 698
719 - // 查询共创合约  
720 cooperationContractsMap := make(map[string]*domain.CooperationContract, 0) 699 cooperationContractsMap := make(map[string]*domain.CooperationContract, 0)
  700 +
  701 + // 查询共创合约
  702 + startQueryContracts := time.Now()
  703 + if len(newCooperationContractNumbers) > 0 {
721 if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{ 704 if count, cooperationContractsFound, err := cooperationContractRepository.Find(map[string]interface{}{
722 "cooperationContractNumbers": newCooperationContractNumbers, 705 "cooperationContractNumbers": newCooperationContractNumbers,
723 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId, 706 "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
@@ -732,10 +715,12 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -732,10 +715,12 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
732 } 715 }
733 } 716 }
734 } 717 }
735 -  
736 - log.Logger.Info("查询共创合约", map[string]interface{}{  
737 - "cooperationContractsMap": cooperationContractsMap,  
738 - }) 718 + } else {
  719 + return map[string]interface{}{
  720 + "report": fmt.Sprintf("已完成0单订单分红预算,生成0单分红预算,失败原因:产品未关联合约"),
  721 + }, nil
  722 + }
  723 + fmt.Println("查询共创合约耗时:", time.Since(startQueryContracts))
739 724
740 // 统计当前企业分红预算单数 725 // 统计当前企业分红预算单数
741 count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{ 726 count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
@@ -747,12 +732,19 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -747,12 +732,19 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
747 732
748 var countDividendsEstimate int64 733 var countDividendsEstimate int64
749 734
750 - for _, orderGood := range orderGoods {  
751 - dividendsEstimate := &domain.DividendsEstimate{}  
752 - if orderGood.DividendsOrderNumber != "" { // 查询分红订单  
753 orderGoodsToConfirm := make([]*domain.OrderGood, 0) 735 orderGoodsToConfirm := make([]*domain.OrderGood, 0)
  736 + returnedOrderGoodsToConfirm := make([]*domain.OrderGood, 0)
  737 +
  738 + for _, orderGood := range orderGoods {
  739 + if orderGood.DividendsOrderNumber != "" {
754 orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood) 740 orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)
755 - // 分红订单产品预算 741 + } else if orderGood.DividendsReturnedOrderNumber != "" {
  742 + returnedOrderGoodsToConfirm = append(returnedOrderGoodsToConfirm, orderGood)
  743 + }
  744 + }
  745 +
  746 + startConfirm := time.Now()
  747 + if len(orderGoodsToConfirm) > 0 { // 分红订单产品预算
756 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 {
757 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 749 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
758 } else { 750 } else {
@@ -770,7 +762,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -770,7 +762,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
770 // 统计分红预算单数目 762 // 统计分红预算单数目
771 countDividendsEstimate = countDividendsEstimate + 1 763 countDividendsEstimate = countDividendsEstimate + 1
772 764
773 - dividendsEstimate = &domain.DividendsEstimate{ 765 + dividendsEstimate := &domain.DividendsEstimate{
774 DividendsEstimateId: 0, 766 DividendsEstimateId: 0,
775 DividendsAccountStatus: domain.TO_BE_ACCOUNT, 767 DividendsAccountStatus: domain.TO_BE_ACCOUNT,
776 DividendsAmount: dividendsEstimateDetail.DividendsAmount, 768 DividendsAmount: dividendsEstimateDetail.DividendsAmount,
@@ -779,8 +771,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -779,8 +771,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
779 DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType, 771 DividendsParticipateType: dividendsEstimateDetail.DividendsParticipateType,
780 DividendsType: domain.ORDER_DIVIDENDS, 772 DividendsType: domain.ORDER_DIVIDENDS,
781 DividendsTypeName: "订单分红", 773 DividendsTypeName: "订单分红",
782 - OrderOrReturnedOrderNum: orderGood.DividendsOrderNumber,  
783 - CooperationContractNumber: orderGood.CooperationContractNumber, 774 + OrderOrReturnedOrderNum: dividendsEstimateDetail.OrderOrReturnedOrderNumber,
  775 + CooperationContractNumber: dividendsEstimateDetail.CooperationContractNumber,
784 DividendsUser: dividendsEstimateDetail.DividendsUser, 776 DividendsUser: dividendsEstimateDetail.DividendsUser,
785 DividendsPercentage: dividendsEstimateDetail.DividendsPercentage, 777 DividendsPercentage: dividendsEstimateDetail.DividendsPercentage,
786 DividendsStage: dividendsEstimateDetail.DividendsStage, 778 DividendsStage: dividendsEstimateDetail.DividendsStage,
@@ -792,8 +784,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -792,8 +784,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
792 CreatedAt: time.Now(), 784 CreatedAt: time.Now(),
793 DeletedAt: time.Time{}, 785 DeletedAt: time.Time{},
794 UpdatedAt: time.Time{}, 786 UpdatedAt: time.Time{},
795 - OrderGoodId: orderGood.OrderGoodId,  
796 - OrderGoodAmount: orderGood.OrderGoodAmount, 787 + OrderGoodId: dividendsEstimateDetail.OrderGoodId,
  788 + OrderGoodAmount: dividendsEstimateDetail.OrderGoodAmount,
797 PaymentStatus: int32(1), 789 PaymentStatus: int32(1),
798 CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId, 790 CooperationContractUndertakerId: dividendsEstimateDetail.CooperationContractUndertakerId,
799 } 791 }
@@ -805,11 +797,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -805,11 +797,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
805 } 797 }
806 } 798 }
807 } 799 }
808 - } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单  
809 - orderGoodsToConfirm := make([]*domain.OrderGood, 0)  
810 - orderGoodsToConfirm = append(orderGoodsToConfirm, orderGood)  
811 - // 分红退货单产品预算  
812 - if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil { 800 + } else if len(returnedOrderGoodsToConfirm) > 0 { // 退货单产品预算
  801 + if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(returnedOrderGoodsToConfirm, confirmDividendsIncentivesEstimateCommand.CompanyId, confirmDividendsIncentivesEstimateCommand.OrgId, cooperationContractsMap); err != nil {
813 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 802 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
814 } else { 803 } else {
815 for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails { 804 for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
@@ -826,7 +815,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -826,7 +815,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
826 // 统计生成的预算单数量 815 // 统计生成的预算单数量
827 countDividendsEstimate = countDividendsEstimate + 1 816 countDividendsEstimate = countDividendsEstimate + 1
828 817
829 - dividendsEstimate = &domain.DividendsEstimate{ 818 + dividendsEstimate := &domain.DividendsEstimate{
830 DividendsEstimateId: 0, 819 DividendsEstimateId: 0,
831 DividendsAccountStatus: domain.TO_BE_ACCOUNT, 820 DividendsAccountStatus: domain.TO_BE_ACCOUNT,
832 DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount, 821 DividendsAmount: dividendsReturnedEstimateDetail.DividendsAmount,
@@ -835,8 +824,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -835,8 +824,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
835 DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType, 824 DividendsParticipateType: dividendsReturnedEstimateDetail.DividendsParticipateType,
836 DividendsType: domain.RETURN_WRITE_OFF, 825 DividendsType: domain.RETURN_WRITE_OFF,
837 DividendsTypeName: "退货冲销", 826 DividendsTypeName: "退货冲销",
838 - OrderOrReturnedOrderNum: orderGood.DividendsReturnedOrderNumber,  
839 - CooperationContractNumber: orderGood.CooperationContractNumber, 827 + OrderOrReturnedOrderNum: dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber,
  828 + CooperationContractNumber: dividendsReturnedEstimateDetail.CooperationContractNumber,
840 DividendsUser: dividendsReturnedEstimateDetail.DividendsUser, 829 DividendsUser: dividendsReturnedEstimateDetail.DividendsUser,
841 DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage, 830 DividendsPercentage: dividendsReturnedEstimateDetail.DividendsPercentage,
842 DividendsStage: dividendsReturnedEstimateDetail.DividendsStage, 831 DividendsStage: dividendsReturnedEstimateDetail.DividendsStage,
@@ -848,8 +837,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -848,8 +837,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
848 CreatedAt: time.Now(), 837 CreatedAt: time.Now(),
849 DeletedAt: time.Time{}, 838 DeletedAt: time.Time{},
850 UpdatedAt: time.Time{}, 839 UpdatedAt: time.Time{},
851 - OrderGoodId: orderGood.OrderGoodId,  
852 - OrderGoodAmount: orderGood.OrderGoodAmount, 840 + OrderGoodId: dividendsReturnedEstimateDetail.OrderGoodId,
  841 + OrderGoodAmount: dividendsReturnedEstimateDetail.OrderGoodAmount,
853 PaymentStatus: int32(1), 842 PaymentStatus: int32(1),
854 CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId, 843 CooperationContractUndertakerId: dividendsReturnedEstimateDetail.CooperationContractUndertakerId,
855 } 844 }
@@ -862,15 +851,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -862,15 +851,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
862 } 851 }
863 } 852 }
864 } 853 }
865 - }  
866 -  
867 - log.Logger.Info("新增的分红预算单", map[string]interface{}{  
868 - "dividendsEstimates": dividendsEstimates,  
869 - }) 854 + fmt.Println("订单分红耗时:", time.Since(startConfirm))
870 855
  856 + startInsert := time.Now()
871 if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil { 857 if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil {
872 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 858 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
873 } else { 859 } else {
  860 + fmt.Println("插入预算单耗时:", time.Since(startInsert))
874 // 获取产品ID 861 // 获取产品ID
875 orderGoodSavedIds := make([]int64, 0) 862 orderGoodSavedIds := make([]int64, 0)
876 for _, dividendsEstimate := range dividendsEstimates { 863 for _, dividendsEstimate := range dividendsEstimates {
@@ -878,6 +865,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -878,6 +865,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
878 } 865 }
879 866
880 // 更新订单产品分红状态 867 // 更新订单产品分红状态
  868 + startUpdateGoodStatus := time.Now()
881 var orderGoodsSaved []*domain.OrderGood 869 var orderGoodsSaved []*domain.OrderGood
882 if len(orderGoodSavedIds) > 0 { 870 if len(orderGoodSavedIds) > 0 {
883 // 订单产品ID去重 871 // 订单产品ID去重
@@ -899,6 +887,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -899,6 +887,7 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
899 } 887 }
900 } 888 }
901 } 889 }
  890 + fmt.Println("更新订单产品分红状态耗时:", time.Since(startUpdateGoodStatus))
902 891
903 // 分离分红订单和退货单 892 // 分离分红订单和退货单
904 dividendsOrderNumbers := make([]string, 0) 893 dividendsOrderNumbers := make([]string, 0)
@@ -915,15 +904,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -915,15 +904,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
915 } 904 }
916 } 905 }
917 906
918 - log.Logger.Info("分红订单", map[string]interface{}{  
919 - "dividendsOrderNumbers": dividendsOrderNumbers,  
920 - })  
921 -  
922 - log.Logger.Info("分红退货单", map[string]interface{}{  
923 - "dividendsReturnedOrderNumbers": dividendsReturnedOrderNumbers,  
924 - })  
925 -  
926 // 查找分红订单 907 // 查找分红订单
  908 + startUpdateOrder := time.Now()
927 if len(dividendsOrderNumbers) > 0 { 909 if len(dividendsOrderNumbers) > 0 {
928 if countDividendsOrdersFound, dividendsOrdersFound, err := dividendsOrderRepository.Find(map[string]interface{}{ 910 if countDividendsOrdersFound, dividendsOrdersFound, err := dividendsOrderRepository.Find(map[string]interface{}{
929 "dividendsOrderNumbers": dividendsOrderNumbers, 911 "dividendsOrderNumbers": dividendsOrderNumbers,
@@ -966,8 +948,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -966,8 +948,10 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
966 } 948 }
967 } 949 }
968 } 950 }
  951 + fmt.Println("更新订单耗时:", time.Since(startUpdateOrder))
969 952
970 // 查找分红退货单 953 // 查找分红退货单
  954 + startUpdateReturnedOrder := time.Now()
971 if len(dividendsReturnedOrderNumbers) > 0 { 955 if len(dividendsReturnedOrderNumbers) > 0 {
972 if countDividendsReturnedOrdersFound, dividendsReturnedOrdersFound, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{ 956 if countDividendsReturnedOrdersFound, dividendsReturnedOrdersFound, err := dividendsReturnedOrderRepository.Find(map[string]interface{}{
973 "dividendsReturnedOrderNumbers": dividendsReturnedOrderNumbers, 957 "dividendsReturnedOrderNumbers": dividendsReturnedOrderNumbers,
@@ -1010,9 +994,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -1010,9 +994,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
1010 } 994 }
1011 } 995 }
1012 996
  997 + fmt.Println("更新退货单耗时:", time.Since(startUpdateReturnedOrder))
  998 +
  999 + startCommit := time.Now()
1013 if err := transactionContext.CommitTransaction(); err != nil { 1000 if err := transactionContext.CommitTransaction(); err != nil {
1014 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 1001 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
1015 } 1002 }
  1003 + fmt.Println("提交事务耗时:", time.Since(startCommit))
1016 1004
1017 // 统计成功的分红预算 1005 // 统计成功的分红预算
1018 successfullyCount := len(dividendsEstimatesSaved) 1006 successfullyCount := len(dividendsEstimatesSaved)
@@ -1029,6 +1017,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -1029,6 +1017,8 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
1029 failedReasonStr = "无" 1017 failedReasonStr = "无"
1030 } 1018 }
1031 1019
  1020 + fmt.Println("函数执行完毕:", time.Since(start))
  1021 +
1032 return map[string]interface{}{ 1022 return map[string]interface{}{
1033 "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),
1034 }, nil 1024 }, nil
@@ -17,7 +17,6 @@ var USER_MODULE_HOST = "http://127.0.0.1:8081" @@ -17,7 +17,6 @@ var USER_MODULE_HOST = "http://127.0.0.1:8081"
17 // BASIC_MODULE_HOST 基础服务模块 17 // BASIC_MODULE_HOST 基础服务模块
18 var BASIC_MODULE_HOST = "http://127.0.0.1:8080" 18 var BASIC_MODULE_HOST = "http://127.0.0.1:8080"
19 19
20 -  
21 // ENABLE_HTTPS 是否开启https访问 20 // ENABLE_HTTPS 是否开启https访问
22 var ENABLE_HTTPS = "false" 21 var ENABLE_HTTPS = "false"
23 22
@@ -17,6 +17,9 @@ type DividendsEstimateDetail struct { @@ -17,6 +17,9 @@ type DividendsEstimateDetail struct {
17 IsSuccessfully bool `json:"isSuccessfully"` // 是否预算成功 17 IsSuccessfully bool `json:"isSuccessfully"` // 是否预算成功
18 Reason string `json:"reason"` // 错误原因 18 Reason string `json:"reason"` // 错误原因
19 CooperationContractUndertakerId int64 `json:"cooperationContractUndertakerId"` // 承接人记录ID 19 CooperationContractUndertakerId int64 `json:"cooperationContractUndertakerId"` // 承接人记录ID
  20 + CooperationContractNumber string `json:"cooperationContractNumber"`
  21 + OrderGoodId int64 `json:"orderGoodId"`
  22 + OrderGoodAmount float64 `json:"orderGoodAmount"`
20 } 23 }
21 24
22 // GenerateSpecificDividendsEstimateNumber 批量生成自定义分红预算单号 25 // GenerateSpecificDividendsEstimateNumber 批量生成自定义分红预算单号
@@ -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
@@ -97,26 +97,6 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -97,26 +97,6 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
97 } 97 }
98 } 98 }
99 99
100 - // 判断共创项目是否存在  
101 - //if _, ok := cooperationProjectsMap[cooperationContract.CooperationProjectNumber]; !ok {  
102 - // var orderNumber string  
103 - // if orderGood.DividendsOrderNumber != "" {  
104 - // orderNumber = orderGood.DividendsOrderNumber  
105 - // } else {  
106 - // orderNumber = orderGood.DividendsReturnedOrderNumber  
107 - // }  
108 - // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{  
109 - // DividendsUser: nil,  
110 - // DividendsParticipateType: 0,  
111 - // DividendsStage: 0,  
112 - // DividendsAmount: 0,  
113 - // OrderOrReturnedOrderNumber: orderNumber,  
114 - // IsSuccessfully: false,  
115 - // Reason: "共创项目" + cooperationContract.CooperationProjectNumber + "已结束或不存在",  
116 - // })  
117 - // continue  
118 - //}  
119 -  
120 if orderGood.DividendsOrderNumber != "" { // 获取分红订单 100 if orderGood.DividendsOrderNumber != "" { // 获取分红订单
121 // 获取分红订单 101 // 获取分红订单
122 dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{ 102 dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{
@@ -199,6 +179,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -199,6 +179,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
199 IsSuccessfully: true, 179 IsSuccessfully: true,
200 CooperationContractUndertakerId: undertaker.UndertakerId, 180 CooperationContractUndertakerId: undertaker.UndertakerId,
201 DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage, 181 DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage,
  182 + CooperationContractNumber: orderGood.CooperationContractNumber,
  183 + OrderGoodId: orderGood.OrderGoodId,
  184 + OrderGoodAmount: orderGood.OrderGoodAmount,
202 }) 185 })
203 } 186 }
204 // 添加推荐人分红预算信息详情 187 // 添加推荐人分红预算信息详情
@@ -226,6 +209,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -226,6 +209,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
226 IsSuccessfully: true, 209 IsSuccessfully: true,
227 CooperationContractUndertakerId: undertaker.UndertakerId, 210 CooperationContractUndertakerId: undertaker.UndertakerId,
228 DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage, 211 DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage,
  212 + CooperationContractNumber: orderGood.CooperationContractNumber,
  213 + OrderGoodId: orderGood.OrderGoodId,
  214 + OrderGoodAmount: orderGood.OrderGoodAmount,
229 }) 215 })
230 } 216 }
231 } 217 }
@@ -254,6 +240,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -254,6 +240,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
254 IsSuccessfully: true, 240 IsSuccessfully: true,
255 CooperationContractUndertakerId: undertaker.UndertakerId, 241 CooperationContractUndertakerId: undertaker.UndertakerId,
256 DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage, 242 DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage,
  243 + CooperationContractNumber: orderGood.CooperationContractNumber,
  244 + OrderGoodId: orderGood.OrderGoodId,
  245 + OrderGoodAmount: orderGood.OrderGoodAmount,
257 }) 246 })
258 } 247 }
259 } 248 }
@@ -337,6 +326,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -337,6 +326,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
337 IsSuccessfully: true, 326 IsSuccessfully: true,
338 CooperationContractUndertakerId: undertaker.UndertakerId, 327 CooperationContractUndertakerId: undertaker.UndertakerId,
339 DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage, 328 DividendsPercentage: dividendsIncentivesRuleMatched.DividendsIncentivesPercentage,
  329 + CooperationContractNumber: orderGood.CooperationContractNumber,
  330 + OrderGoodId: orderGood.OrderGoodId,
  331 + OrderGoodAmount: orderGood.OrderGoodAmount,
340 }) 332 })
341 } 333 }
342 334
@@ -365,6 +357,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -365,6 +357,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
365 IsSuccessfully: true, 357 IsSuccessfully: true,
366 CooperationContractUndertakerId: undertaker.UndertakerId, 358 CooperationContractUndertakerId: undertaker.UndertakerId,
367 DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage, 359 DividendsPercentage: dividendsIncentivesRuleMatched.ReferrerPercentage,
  360 + CooperationContractNumber: orderGood.CooperationContractNumber,
  361 + OrderGoodId: orderGood.OrderGoodId,
  362 + OrderGoodAmount: orderGood.OrderGoodAmount,
368 }) 363 })
369 } 364 }
370 } 365 }
@@ -394,6 +389,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -394,6 +389,9 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
394 IsSuccessfully: true, 389 IsSuccessfully: true,
395 CooperationContractUndertakerId: undertaker.UndertakerId, 390 CooperationContractUndertakerId: undertaker.UndertakerId,
396 DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage, 391 DividendsPercentage: dividendsIncentivesRuleMatched.SalesmanPercentage,
  392 + CooperationContractNumber: orderGood.CooperationContractNumber,
  393 + OrderGoodId: orderGood.OrderGoodId,
  394 + OrderGoodAmount: orderGood.OrderGoodAmount,
397 }) 395 })
398 } 396 }
399 } 397 }
@@ -9,7 +9,6 @@ import ( @@ -9,7 +9,6 @@ import (
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
10 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" 10 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
12 -  
13 rawlog "log" 12 rawlog "log"
14 ) 13 )
15 14
@@ -223,15 +223,16 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do @@ -223,15 +223,16 @@ func (repository *DividendsEstimateRepository) SaveMany(dividendsEstimates []*do
223 if _, err := tx.Model(&dividendsEstimateModels).Insert(); err != nil { 223 if _, err := tx.Model(&dividendsEstimateModels).Insert(); err != nil {
224 return nil, err 224 return nil, err
225 } 225 }
226 - var dividendsEstimatesSaved []*domain.DividendsEstimate  
227 - for _, dividendsEstimateModel := range dividendsEstimateModels {  
228 - if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil {  
229 - return dividendsEstimates, err  
230 - } else {  
231 - dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimate)  
232 - }  
233 - }  
234 - return dividendsEstimatesSaved, nil 226 + //var dividendsEstimatesSaved []*domain.DividendsEstimate
  227 + //for _, dividendsEstimateModel := range dividendsEstimateModels {
  228 + // if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil {
  229 + // return dividendsEstimates, err
  230 + // } else {
  231 + // dividendsEstimatesSaved = append(dividendsEstimatesSaved, dividendsEstimate)
  232 + // }
  233 + //}
  234 + //return dividendsEstimatesSaved, nil
  235 + return dividendsEstimates, nil
235 } 236 }
236 return nil, nil 237 return nil, nil
237 } 238 }
@@ -270,15 +271,16 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []* @@ -270,15 +271,16 @@ func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []*
270 if _, err := tx.Model(&dividendsEstimateModels).WherePK().Update(); err != nil { 271 if _, err := tx.Model(&dividendsEstimateModels).WherePK().Update(); err != nil {
271 return nil, err 272 return nil, err
272 } 273 }
273 - var dividendsEstimatesUpdated []*domain.DividendsEstimate  
274 - for _, dividendsEstimateModel := range dividendsEstimateModels {  
275 - if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil {  
276 - return dividendsEstimates, err  
277 - } else {  
278 - dividendsEstimatesUpdated = append(dividendsEstimatesUpdated, dividendsEstimate)  
279 - }  
280 - }  
281 - return dividendsEstimatesUpdated, nil 274 + //var dividendsEstimatesUpdated []*domain.DividendsEstimate
  275 + //for _, dividendsEstimateModel := range dividendsEstimateModels {
  276 + // if dividendsEstimate, err := transform.TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel); err != nil {
  277 + // return dividendsEstimates, err
  278 + // } else {
  279 + // dividendsEstimatesUpdated = append(dividendsEstimatesUpdated, dividendsEstimate)
  280 + // }
  281 + //}
  282 + //return dividendsEstimatesUpdated, nil
  283 + return dividendsEstimates, nil
282 } 284 }
283 285
284 func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain.DividendsEstimate) (*domain.DividendsEstimate, error) { 286 func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain.DividendsEstimate) (*domain.DividendsEstimate, error) {
@@ -50,7 +50,8 @@ func (logger *BeegoLog) Debug(msg string, appends ...map[string]interface{}) { @@ -50,7 +50,8 @@ func (logger *BeegoLog) Debug(msg string, appends ...map[string]interface{}) {
50 logs.Debug(msg, make(map[string]interface{}, 0)) 50 logs.Debug(msg, make(map[string]interface{}, 0))
51 } else { 51 } else {
52 var out bytes.Buffer 52 var out bytes.Buffer
53 - err := json.Indent(&out, appendsJson, "", " ") 53 + //err := json.Indent(&out, appendsJson, "", " ")
  54 + err := json.Compact(&out, appendsJson)
54 if err != nil { 55 if err != nil {
55 fmt.Println(msg) 56 fmt.Println(msg)
56 return 57 return
@@ -65,7 +66,8 @@ func (logger *BeegoLog) Info(msg string, appends ...map[string]interface{}) { @@ -65,7 +66,8 @@ func (logger *BeegoLog) Info(msg string, appends ...map[string]interface{}) {
65 logs.Info(msg, make(map[string]interface{}, 0)) 66 logs.Info(msg, make(map[string]interface{}, 0))
66 } else { 67 } else {
67 var out bytes.Buffer 68 var out bytes.Buffer
68 - err := json.Indent(&out, appendsJson, "", " ") 69 + //err := json.Indent(&out, appendsJson, "", " ")
  70 + err := json.Compact(&out, appendsJson)
69 if err != nil { 71 if err != nil {
70 fmt.Println(msg) 72 fmt.Println(msg)
71 return 73 return