作者 陈志颖

Merge branch 'dev-chenzhiying' into dev

@@ -705,12 +705,12 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -705,12 +705,12 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
705 if err := updateCooperationContractCommand.ValidateCommand(); err != nil { 705 if err := updateCooperationContractCommand.ValidateCommand(); err != nil {
706 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 706 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
707 } 707 }
708 - transactionContext, err := factory.CreateTransactionContext(nil)  
709 - if err != nil {  
710 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 708 + transactionContext, err1 := factory.CreateTransactionContext(nil)
  709 + if err1 != nil {
  710 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err1.Error())
711 } 711 }
712 - if err := transactionContext.StartTransaction(); err != nil {  
713 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 712 + if err2 := transactionContext.StartTransaction(); err2 != nil {
  713 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error())
714 } 714 }
715 defer func() { 715 defer func() {
716 _ = transactionContext.RollbackTransaction() 716 _ = transactionContext.RollbackTransaction()
@@ -718,59 +718,76 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -718,59 +718,76 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
718 718
719 // 公司REST服务初始化 719 // 公司REST服务初始化
720 var companyService service.CompanyService 720 var companyService service.CompanyService
721 - if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {  
722 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 721 + if value, err3 := factory.CreateCompanyService(map[string]interface{}{}); err3 != nil {
  722 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
723 } else { 723 } else {
724 companyService = value 724 companyService = value
725 } 725 }
726 726
727 // 获取公司信息 727 // 获取公司信息
728 var company *domain.Company 728 var company *domain.Company
729 - if data, err := companyService.CompanyFrom(updateCooperationContractCommand.CompanyId); err != nil {  
730 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 729 + if data, err4 := companyService.CompanyFrom(updateCooperationContractCommand.CompanyId); err4 != nil {
  730 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
731 } else { 731 } else {
732 company = data 732 company = data
733 } 733 }
734 734
735 // 组织机构REST服务初始化 735 // 组织机构REST服务初始化
736 var organizationService service.OrgService 736 var organizationService service.OrgService
737 - if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {  
738 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 737 + if value, err5 := factory.CreateOrganizationService(map[string]interface{}{}); err5 != nil {
  738 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err5.Error())
739 } else { 739 } else {
740 organizationService = value 740 organizationService = value
741 } 741 }
742 742
743 // 获取组织机构信息 743 // 获取组织机构信息
744 var organization *domain.Org 744 var organization *domain.Org
745 - if data, err := organizationService.OrgFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId); err != nil {  
746 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 745 + if data, err6 := organizationService.OrgFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId); err6 != nil {
  746 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err6.Error())
747 } else { 747 } else {
748 organization = data 748 organization = data
749 } 749 }
750 750
751 - var cooperationContractRepository domain.CooperationContractRepository  
752 - if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{ 751 + // 共创合约变更记录仓储初始化
  752 + var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
  753 + if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
753 "transactionContext": transactionContext, 754 "transactionContext": transactionContext,
754 }); err != nil { 755 }); err != nil {
755 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 756 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
756 } else { 757 } else {
  758 + cooperationContractChangeLogRepository = value
  759 + }
  760 +
  761 + // 共创合约仓储初始化
  762 + var cooperationContractRepository domain.CooperationContractRepository
  763 + if value, err7 := factory.CreateCooperationContractRepository(map[string]interface{}{
  764 + "transactionContext": transactionContext,
  765 + }); err7 != nil {
  766 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err7.Error())
  767 + } else {
757 cooperationContractRepository = value 768 cooperationContractRepository = value
758 } 769 }
759 - cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": updateCooperationContractCommand.CooperationContractId})  
760 - if err != nil {  
761 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 770 +
  771 + // 获取待更新的共创合约
  772 + cooperationContract, err8 := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": updateCooperationContractCommand.CooperationContractId})
  773 + if err8 != nil {
  774 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err8.Error())
762 } 775 }
763 if cooperationContract == nil { 776 if cooperationContract == nil {
764 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractCommand.CooperationContractId))) 777 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationContractCommand.CooperationContractId)))
765 } 778 }
  779 +
  780 + cooperationContractFound := cooperationContract
  781 +
766 // 更新合约基础信息 782 // 更新合约基础信息
767 - if err := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err != nil {  
768 - return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 783 + if err9 := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err9 != nil {
  784 + return nil, application.ThrowError(application.BUSINESS_ERROR, err9.Error())
769 } 785 }
  786 +
770 // 用户REST服务初始化 787 // 用户REST服务初始化
771 var userService service.UserService 788 var userService service.UserService
772 - if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {  
773 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 789 + if value, err10 := factory.CreateUserService(map[string]interface{}{}); err10 != nil {
  790 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err10.Error())
774 } else { 791 } else {
775 userService = value 792 userService = value
776 } 793 }
@@ -778,12 +795,20 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -778,12 +795,20 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
778 // 获取发起人 795 // 获取发起人
779 var sponsor *domain.User 796 var sponsor *domain.User
780 sponsorUid, _ := strconv.ParseInt(updateCooperationContractCommand.SponsorUid, 10, 64) 797 sponsorUid, _ := strconv.ParseInt(updateCooperationContractCommand.SponsorUid, 10, 64)
781 - if data, err := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, sponsorUid); err != nil {  
782 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 798 + if data, err11 := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, sponsorUid); err11 != nil {
  799 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err11.Error())
783 } else { 800 } else {
784 sponsor = data 801 sponsor = data
785 } 802 }
786 803
  804 + // 获取操作人
  805 + var operator *domain.User
  806 + if data, err := userService.OperatorFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, updateCooperationContractCommand.UserId); err != nil {
  807 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  808 + } else {
  809 + operator = data
  810 + }
  811 +
787 // 更新发起人 812 // 更新发起人
788 cooperationContract.CooperationContractSponsor = sponsor 813 cooperationContract.CooperationContractSponsor = sponsor
789 814
@@ -792,8 +817,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -792,8 +817,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
792 for _, relevantPersonUid := range updateCooperationContractCommand.RelevantPeople { 817 for _, relevantPersonUid := range updateCooperationContractCommand.RelevantPeople {
793 var relevantDomain *domain.Relevant 818 var relevantDomain *domain.Relevant
794 relevantUid, _ := strconv.ParseInt(relevantPersonUid, 10, 64) 819 relevantUid, _ := strconv.ParseInt(relevantPersonUid, 10, 64)
795 - if data, err := userService.RelevantFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, relevantUid); err != nil {  
796 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 820 + if data, err12 := userService.RelevantFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, relevantUid); err12 != nil {
  821 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err12.Error())
797 } else { 822 } else {
798 relevantDomain = data 823 relevantDomain = data
799 } 824 }
@@ -821,8 +846,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -821,8 +846,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
821 for _, undertaker := range updateCooperationContractCommand.Undertakers { 846 for _, undertaker := range updateCooperationContractCommand.Undertakers {
822 var undertakerDomain *domain.Undertaker 847 var undertakerDomain *domain.Undertaker
823 undertakerUid, _ := strconv.ParseInt(undertaker.UserId, 10, 64) 848 undertakerUid, _ := strconv.ParseInt(undertaker.UserId, 10, 64)
824 - if data, err := userService.UndertakerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, undertakerUid); err != nil {  
825 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 849 + if data, err13 := userService.UndertakerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, undertakerUid); err13 != nil {
  850 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err13.Error())
826 } else { 851 } else {
827 undertakerDomain = data 852 undertakerDomain = data
828 } 853 }
@@ -831,8 +856,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -831,8 +856,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
831 var referrerDomain *domain.Referrer 856 var referrerDomain *domain.Referrer
832 referrerUid, _ := strconv.ParseInt(undertaker.ReferrerId, 10, 64) 857 referrerUid, _ := strconv.ParseInt(undertaker.ReferrerId, 10, 64)
833 if referrerUid > 0 { 858 if referrerUid > 0 {
834 - if data, err := userService.ReferrerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, referrerUid); err != nil {  
835 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 859 + if data, err14 := userService.ReferrerFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, referrerUid); err14 != nil {
  860 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err14.Error())
836 } else { 861 } else {
837 referrerDomain = data 862 referrerDomain = data
838 } 863 }
@@ -840,18 +865,21 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -840,18 +865,21 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
840 865
841 // 获取业务员 866 // 获取业务员
842 var salesmanDomain *domain.Salesman 867 var salesmanDomain *domain.Salesman
843 - salesmanUid, _ := strconv.ParseInt(undertaker.SalesmanId, 10, 64) 868 + salesmanUid, err22 := strconv.ParseInt(undertaker.SalesmanId, 10, 64)
  869 + if err22 != nil {
  870 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err22.Error())
  871 + }
844 if salesmanUid > 0 { 872 if salesmanUid > 0 {
845 - if data, err := userService.SalesmanFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, salesmanUid); err != nil {  
846 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 873 + if data, err15 := userService.SalesmanFrom(updateCooperationContractCommand.CompanyId, updateCooperationContractCommand.OrgId, salesmanUid); err15 != nil {
  874 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err15.Error())
847 } else { 875 } else {
848 salesmanDomain = data 876 salesmanDomain = data
849 } 877 }
850 } 878 }
851 879
852 - undertakerId, err3 := strconv.ParseInt(undertaker.UndertakerId, 10, 64)  
853 - if err3 != nil {  
854 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error()) 880 + undertakerId, err16 := strconv.ParseInt(undertaker.UndertakerId, 10, 64)
  881 + if err16 != nil {
  882 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err16.Error())
855 } 883 }
856 undertakers = append(undertakers, &domain.Undertaker{ 884 undertakers = append(undertakers, &domain.Undertaker{
857 UndertakerId: undertakerId, 885 UndertakerId: undertakerId,
@@ -877,9 +905,9 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -877,9 +905,9 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
877 // 获取分红规则列表 905 // 获取分红规则列表
878 var dividendsIncentivesRules []*domain.DividendsIncentivesRule 906 var dividendsIncentivesRules []*domain.DividendsIncentivesRule
879 for _, dividendsIncentivesRule := range updateCooperationContractCommand.DividendsIncentivesRules { 907 for _, dividendsIncentivesRule := range updateCooperationContractCommand.DividendsIncentivesRules {
880 - dividendsIncentivesRuleId, err2 := strconv.ParseInt(dividendsIncentivesRule.DividendsIncentivesRuleId, 10, 64)  
881 - if err2 != nil {  
882 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error()) 908 + dividendsIncentivesRuleId, err17 := strconv.ParseInt(dividendsIncentivesRule.DividendsIncentivesRuleId, 10, 64)
  909 + if err17 != nil {
  910 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err17.Error())
883 } 911 }
884 dividendsIncentivesRules = append(dividendsIncentivesRules, &domain.DividendsIncentivesRule{ 912 dividendsIncentivesRules = append(dividendsIncentivesRules, &domain.DividendsIncentivesRule{
885 DividendsIncentivesRuleId: dividendsIncentivesRuleId, 913 DividendsIncentivesRuleId: dividendsIncentivesRuleId,
@@ -903,9 +931,9 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -903,9 +931,9 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
903 // 获取金额激励规则列表 931 // 获取金额激励规则列表
904 var moneyIncentivesRules []*domain.MoneyIncentivesRule 932 var moneyIncentivesRules []*domain.MoneyIncentivesRule
905 for _, moneyIncentivesRule := range updateCooperationContractCommand.MoneyIncentivesRules { 933 for _, moneyIncentivesRule := range updateCooperationContractCommand.MoneyIncentivesRules {
906 - moneyIncentivesRuleId, err4 := strconv.ParseInt(moneyIncentivesRule.MoneyIncentivesRuleId, 10, 64)  
907 - if err4 != nil {  
908 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error()) 934 + moneyIncentivesRuleId, err18 := strconv.ParseInt(moneyIncentivesRule.MoneyIncentivesRuleId, 10, 64)
  935 + if err18 != nil {
  936 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err18.Error())
909 } 937 }
910 moneyIncentivesRules = append(moneyIncentivesRules, &domain.MoneyIncentivesRule{ 938 moneyIncentivesRules = append(moneyIncentivesRules, &domain.MoneyIncentivesRule{
911 MoneyIncentivesRuleId: moneyIncentivesRuleId, 939 MoneyIncentivesRuleId: moneyIncentivesRuleId,
@@ -927,13 +955,190 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -927,13 +955,190 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
927 // 更新金额激励规则列表 955 // 更新金额激励规则列表
928 cooperationContract.MoneyIncentivesRules = moneyIncentivesRules 956 cooperationContract.MoneyIncentivesRules = moneyIncentivesRules
929 957
930 - if cooperationContract, err := cooperationContractRepository.Save(cooperationContract); err != nil {  
931 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 958 + // 判断激励规则变更
  959 + incentivesType := 0
  960 + if len(dividendsIncentivesRules) > 0 {
  961 + incentivesType = domain.TYPE_DIVIDNEDS_INCENTIVES
  962 + } else if len(moneyIncentivesRules) > 0 {
  963 + incentivesType = domain.TYPE_MONEY_INCENTIVES
  964 + }
  965 + cooperationContract.IncentivesType = int32(incentivesType)
  966 +
  967 + // 保存共创合约变更
  968 + if cooperationContractSaved, err19 := cooperationContractRepository.Save(cooperationContract); err19 != nil {
  969 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err19.Error())
932 } else { 970 } else {
933 - if err := transactionContext.CommitTransaction(); err != nil {  
934 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 971 + // 保存共创合约变更记录
  972 + // 原【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点),(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】-->更新后【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】
  973 + var incentivesRuleChange string
  974 + var incentivesRuleChangeDetail string
  975 + if cooperationContractFound.IncentivesType != cooperationContractSaved.IncentivesType && cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES && cooperationContractSaved.IncentivesType == domain.TYPE_MONEY_INCENTIVES { // 1.激励类型变更
  976 + // 业绩分红-->金额激励
  977 + incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
  978 +
  979 + //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
  980 + // 原业绩分红激励规则
  981 + var dividendsIncentivesRuleOriginal string
  982 + for _, dividendsIncentivesRule := range cooperationContractFound.DividendsIncentivesRules {
  983 + dividendsIncentivesRuleOriginal = dividendsIncentivesRuleOriginal + dividendsIncentivesRule.DividendsIncentivesStageCN +
  984 + ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
  985 + "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
  986 + "~" + dividendsIncentivesRule.DividendsIncentivesStageEnd.Format("2006-01-02") +
  987 + "," + fmt.Sprint(dividendsIncentivesRule.ReferrerPercentage) +
  988 + "," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
  989 + }
  990 + dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleOriginal + "】"
  991 +
  992 + // 变更后的金额激励规则
  993 + var moneyIncentivesRuleChanged string
  994 + for _, moneyIncentivesRule := range cooperationContractSaved.MoneyIncentivesRules {
  995 + moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN +
  996 + ":" +
  997 + "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
  998 + "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
  999 + "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
  1000 + }
  1001 + moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleChanged + "】"
  1002 +
  1003 + // 拼接规则变更
  1004 + incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + moneyIncentivesRuleOriginalTmp
  1005 + } else if cooperationContractFound.IncentivesType != cooperationContractSaved.IncentivesType && cooperationContractFound.IncentivesType == domain.TYPE_MONEY_INCENTIVES && cooperationContractSaved.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES {
  1006 + // 金额激励-->业绩分红
  1007 + incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
  1008 + //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
  1009 +
  1010 + // 原金额激励规则
  1011 + var moneyIncentivesRuleOriginal string
  1012 + for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
  1013 + moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN +
  1014 + ":" +
  1015 + "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
  1016 + "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
  1017 + "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
  1018 + }
  1019 + moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleOriginal + "】"
  1020 +
  1021 + // 变更后的业绩分红激励规则
  1022 + var dividendsIncentivesRuleChanged string
  1023 + for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules {
  1024 + dividendsIncentivesRuleChanged = dividendsIncentivesRuleChanged + dividendsIncentivesRule.DividendsIncentivesStageCN +
  1025 + ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
  1026 + "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
  1027 + "~" + dividendsIncentivesRule.DividendsIncentivesStageEnd.Format("2006-01-02") +
  1028 + "," + fmt.Sprint(dividendsIncentivesRule.ReferrerPercentage) +
  1029 + "," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
  1030 + }
  1031 + dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleChanged + "】"
  1032 +
  1033 + // 拼接规则变更
  1034 + incentivesRuleChangeDetail = moneyIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleOriginalTmp
  1035 + } else { // 2.激励规则变更
  1036 + if cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES { // 业绩分红激励规则变更
  1037 + if !cooperationContract.DividendsIncentivesRuleSliceEqualBCE(cooperationContractFound.DividendsIncentivesRules, cooperationContractSaved.DividendsIncentivesRules) {
  1038 + // 业绩分红-->业绩分红
  1039 + incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
  1040 + //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
  1041 +
  1042 + // 原业绩分红激励规则
  1043 + var dividendsIncentivesRuleOriginal string
  1044 + for _, dividendsIncentivesRule := range cooperationContractFound.DividendsIncentivesRules {
  1045 + dividendsIncentivesRuleOriginal = dividendsIncentivesRuleOriginal + dividendsIncentivesRule.DividendsIncentivesStageCN +
  1046 + ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
  1047 + "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
  1048 + "~" + dividendsIncentivesRule.DividendsIncentivesStageEnd.Format("2006-01-02") +
  1049 + "," + fmt.Sprint(dividendsIncentivesRule.ReferrerPercentage) +
  1050 + "," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
  1051 + }
  1052 + dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleOriginal + "】"
  1053 +
  1054 + // 变更后的业绩分红激励规则
  1055 + var dividendsIncentivesRuleChanged string
  1056 + for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules {
  1057 + dividendsIncentivesRuleChanged = dividendsIncentivesRuleChanged + dividendsIncentivesRule.DividendsIncentivesStageCN +
  1058 + ":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
  1059 + "," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
  1060 + "~" + dividendsIncentivesRule.DividendsIncentivesStageEnd.Format("2006-01-02") +
  1061 + "," + fmt.Sprint(dividendsIncentivesRule.ReferrerPercentage) +
  1062 + "," + fmt.Sprint(dividendsIncentivesRule.SalesmanPercentage) + ";"
  1063 + }
  1064 + dividendsIncentivesRuleChangedTmp := "【" + dividendsIncentivesRuleChanged + "】"
  1065 +
  1066 + // 拼接规则变更
  1067 + incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleChangedTmp
935 } 1068 }
936 - return cooperationContract, nil 1069 + } else if cooperationContractFound.IncentivesType == domain.MONEY_INCENTIVES { // 金额激励规则变更
  1070 + if !cooperationContract.MoneyIncentivesRuleSliceEqualBCE(cooperationContractFound.MoneyIncentivesRules, cooperationContractSaved.MoneyIncentivesRules) {
  1071 + incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
  1072 + //【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
  1073 +
  1074 + // 原金额激励规则
  1075 + var moneyIncentivesRuleOriginal string
  1076 + for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
  1077 + moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN +
  1078 + ":" +
  1079 + "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
  1080 + "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
  1081 + "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
  1082 + }
  1083 + moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleOriginal + "】"
  1084 +
  1085 + // 变更后的激励规则
  1086 + var moneyIncentivesRuleChanged string
  1087 + for _, moneyIncentivesRule := range cooperationContractSaved.MoneyIncentivesRules {
  1088 + moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN +
  1089 + ":" +
  1090 + "," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
  1091 + "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
  1092 + "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
  1093 + }
  1094 + moneyIncentivesRuleChangedTmp := "【" + moneyIncentivesRuleChanged + "】"
  1095 +
  1096 + // 拼接规则变更
  1097 + incentivesRuleChangeDetail = moneyIncentivesRuleOriginalTmp + " 变更为 " + moneyIncentivesRuleChangedTmp
  1098 + }
  1099 + }
  1100 + }
  1101 +
  1102 + // 【1(张三,李四,王五)2(买买买,,)】变更为【1(张三,,)】
  1103 + var undertakerChange string
  1104 + if !cooperationContract.UndertakerSliceEqualBCE(cooperationContractFound.Undertakers, cooperationContractSaved.Undertakers) { // 3.承接人变更
  1105 + // 原承接人
  1106 + var undertakersOriginal string
  1107 + for i, undertaker := range cooperationContractFound.Undertakers {
  1108 + undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
  1109 + }
  1110 + undertakerChangeTmp1 := "【" + undertakersOriginal + "】"
  1111 + // 变更承接人
  1112 + var undertakersChanged string
  1113 + for i, undertaker := range cooperationContractSaved.Undertakers {
  1114 + undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
  1115 + }
  1116 + undertakerChangeTemp2 := "【" + undertakersChanged + "】"
  1117 + // 拼接承接人变更记录
  1118 + undertakerChange = undertakerChangeTmp1 + " 变更为 " + undertakerChangeTemp2
  1119 + }
  1120 +
  1121 + // 新增共创合约变更记录
  1122 + newCooperationContractChangeLog := &domain.CooperationContractChangeLog{
  1123 + IncentivesRule: incentivesRuleChange,
  1124 + IncentivesRuleDetail: incentivesRuleChangeDetail,
  1125 + OperationType: domain.EDIT,
  1126 + Undertakers: undertakerChange,
  1127 + CooperationContractNumber: cooperationContractSaved.CooperationContractNumber,
  1128 + Company: company,
  1129 + Operator: operator,
  1130 + UpdatedAt: time.Time{},
  1131 + CreatedAt: time.Now(),
  1132 + }
  1133 +
  1134 + // 保存共创合约变更记录
  1135 + if _, err20 := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err20 != nil {
  1136 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err20.Error())
  1137 + }
  1138 + if err21 := transactionContext.CommitTransaction(); err21 != nil {
  1139 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err21.Error())
  1140 + }
  1141 + return cooperationContractSaved, nil
937 } 1142 }
938 } 1143 }
939 1144
@@ -65,6 +65,16 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -65,6 +65,16 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
65 operator = data 65 operator = data
66 } 66 }
67 67
  68 + // 共创合约变更记录仓储初始化
  69 + var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository
  70 + if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{
  71 + "transactionContext": transactionContext,
  72 + }); err != nil {
  73 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  74 + } else {
  75 + cooperationContractChangeLogRepository = value
  76 + }
  77 +
68 newCooperationContractChangeLog := &domain.CooperationContractChangeLog{ 78 newCooperationContractChangeLog := &domain.CooperationContractChangeLog{
69 IncentivesRule: createCooperationContractChangeLogCommand.IncentivesRule, 79 IncentivesRule: createCooperationContractChangeLogCommand.IncentivesRule,
70 IncentivesRuleDetail: createCooperationContractChangeLogCommand.IncentivesRuleDetail, 80 IncentivesRuleDetail: createCooperationContractChangeLogCommand.IncentivesRuleDetail,
@@ -77,14 +87,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService) @@ -77,14 +87,7 @@ func (cooperationContractChangeLogService *CooperationContractChangeLogService)
77 DeletedAt: time.Time{}, 87 DeletedAt: time.Time{},
78 CreatedAt: time.Now(), 88 CreatedAt: time.Now(),
79 } 89 }
80 - var cooperationContractChangeLogRepository domain.CooperationContractChangeLogRepository  
81 - if value, err := factory.CreateCooperationContractChangeLogRepository(map[string]interface{}{  
82 - "transactionContext": transactionContext,  
83 - }); err != nil {  
84 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
85 - } else {  
86 - cooperationContractChangeLogRepository = value  
87 - } 90 +
88 if cooperationContractChangeLog, err := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err != nil { 91 if cooperationContractChangeLog, err := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err != nil {
89 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 92 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
90 } else { 93 } else {
@@ -126,8 +126,8 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD @@ -126,8 +126,8 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
126 DividendsReturnedOrderNumber: "", 126 DividendsReturnedOrderNumber: "",
127 CooperationContractNumber: orderGood.CooperationContractNumber, 127 CooperationContractNumber: orderGood.CooperationContractNumber,
128 OrderGoodExpense: orderGood.OrderGoodExpense, 128 OrderGoodExpense: orderGood.OrderGoodExpense,
129 - OrgId: organization.OrgId,  
130 - CompanyId: company.CompanyId, 129 + OrgId: createDividendsOrderCommand.OrgId,
  130 + CompanyId: createDividendsOrderCommand.CompanyId,
131 CreatedAt: time.Time{}, 131 CreatedAt: time.Time{},
132 DeletedAt: time.Time{}, 132 DeletedAt: time.Time{},
133 UpdatedAt: time.Time{}, 133 UpdatedAt: time.Time{},
@@ -148,7 +148,7 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD @@ -148,7 +148,7 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
148 DividendsOrderAmount: dividendsOrderAmount, 148 DividendsOrderAmount: dividendsOrderAmount,
149 OrderTime: orderTime, 149 OrderTime: orderTime,
150 DividendTime: time.Time{}, 150 DividendTime: time.Time{},
151 - DividendStatus: 0, 151 + DividendStatus: domain.TO_BE_DIVIDEND,
152 Region: &domain.RegionInfo{ 152 Region: &domain.RegionInfo{
153 RegionNumber: "", 153 RegionNumber: "",
154 RegionName: createDividendsOrderCommand.RegionName, 154 RegionName: createDividendsOrderCommand.RegionName,
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "github.com/beego/beego/v2/core/validation" 5 "github.com/beego/beego/v2/core/validation"
6 "reflect" 6 "reflect"
7 "strings" 7 "strings"
  8 + "time"
8 ) 9 )
9 10
10 type OrderGoods struct { 11 type OrderGoods struct {
@@ -36,7 +37,7 @@ type CreateDividendsReturnedOrderCommand struct { @@ -36,7 +37,7 @@ type CreateDividendsReturnedOrderCommand struct {
36 // 备注 37 // 备注
37 Remarks string `cname:"备注" json:"remarks" valid:"Required"` 38 Remarks string `cname:"备注" json:"remarks" valid:"Required"`
38 // 退货日期 39 // 退货日期
39 - DividendsReturnedDate string `cname:"退货日期" json:"dividendsReturnedDate" valid:"Required"` 40 + DividendsReturnedDate time.Time `cname:"退货日期" json:"dividendsReturnedDate" valid:"Required"`
40 // 退货区域名称 41 // 退货区域名称
41 RegionName string `cname:"退货区域名称" json:"regionName,omitempty"` 42 RegionName string `cname:"退货区域名称" json:"regionName,omitempty"`
42 // 订单产品列表 43 // 订单产品列表
@@ -121,8 +121,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide @@ -121,8 +121,8 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
121 DividendsReturnedOrderNumber: dividendsReturnedOrderNumber, 121 DividendsReturnedOrderNumber: dividendsReturnedOrderNumber,
122 CooperationContractNumber: orderGood.CooperationContractNumber, 122 CooperationContractNumber: orderGood.CooperationContractNumber,
123 OrderGoodExpense: 0, 123 OrderGoodExpense: 0,
124 - OrgId: organization.OrgId,  
125 - CompanyId: company.CompanyId, 124 + OrgId: createDividendsReturnedOrderCommand.OrgId,
  125 + CompanyId: createDividendsReturnedOrderCommand.CompanyId,
126 CreatedAt: time.Now(), 126 CreatedAt: time.Now(),
127 DeletedAt: time.Time{}, 127 DeletedAt: time.Time{},
128 UpdatedAt: time.Time{}, 128 UpdatedAt: time.Time{},
@@ -135,19 +135,18 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide @@ -135,19 +135,18 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
135 OriginalOrderNum: createDividendsReturnedOrderCommand.OriginalOrderNum, 135 OriginalOrderNum: createDividendsReturnedOrderCommand.OriginalOrderNum,
136 DividendsOrderNumber: createDividendsReturnedOrderCommand.DividendsOrderNumber, 136 DividendsOrderNumber: createDividendsReturnedOrderCommand.DividendsOrderNumber,
137 DividendsReturnedCustomerName: createDividendsReturnedOrderCommand.DividendsReturnedCustomerName, 137 DividendsReturnedCustomerName: createDividendsReturnedOrderCommand.DividendsReturnedCustomerName,
138 - DividendsReturnedDate: time.Time{}, 138 + DividendsReturnedDate: createDividendsReturnedOrderCommand.DividendsReturnedDate,
139 Region: &domain.RegionInfo{ 139 Region: &domain.RegionInfo{
140 RegionNumber: "", 140 RegionNumber: "",
141 RegionName: createDividendsReturnedOrderCommand.RegionName, 141 RegionName: createDividendsReturnedOrderCommand.RegionName,
142 }, 142 },
143 Goods: orderGoods, 143 Goods: orderGoods,
144 Remarks: createDividendsReturnedOrderCommand.Remarks, 144 Remarks: createDividendsReturnedOrderCommand.Remarks,
145 - DividendStatus: 1, 145 + DividendStatus: domain.TO_BE_DIVIDENDED,
146 DividendTime: time.Time{}, 146 DividendTime: time.Time{},
147 Org: organization, 147 Org: organization,
148 Company: company, 148 Company: company,
149 CreatedAt: time.Now(), 149 CreatedAt: time.Now(),
150 - DeletedAt: time.Time{},  
151 UpdatedAt: time.Time{}, 150 UpdatedAt: time.Time{},
152 Operator: operator, 151 Operator: operator,
153 OperateTime: time.Now(), 152 OperateTime: time.Now(),
@@ -9,6 +9,28 @@ const ( @@ -9,6 +9,28 @@ const (
9 TYPE_MONEY_INCENTIVES 9 TYPE_MONEY_INCENTIVES
10 ) 10 )
11 11
  12 +type IncentivesType int32
  13 +
  14 +const (
  15 + DividendsIncentives IncentivesType = 1
  16 + MoneyIncentives IncentivesType = 2
  17 +)
  18 +
  19 +func (p IncentivesType) String() string {
  20 + switch p {
  21 + case DividendsIncentives:
  22 + return "业绩分红"
  23 + case MoneyIncentives:
  24 + return "金额激励"
  25 + default:
  26 + return "未知类型"
  27 + }
  28 +}
  29 +
  30 +func (cooperationContract *CooperationContract) ReturnIncentivesName(p IncentivesType) string {
  31 + return p.String()
  32 +}
  33 +
12 // CooperationContract 共创项目合约实体 34 // CooperationContract 共创项目合约实体
13 type CooperationContract struct { 35 type CooperationContract struct {
14 // 共创合约ID 36 // 共创合约ID
@@ -101,3 +123,54 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface @@ -101,3 +123,54 @@ func (cooperationContract *CooperationContract) Update(data map[string]interface
101 } 123 }
102 return nil 124 return nil
103 } 125 }
  126 +
  127 +// UndertakerSliceEqualBCE 判断承接人Slice是否一样
  128 +func (cooperationContract *CooperationContract) UndertakerSliceEqualBCE(a, b []*Undertaker) bool {
  129 + if len(a) != len(b) {
  130 + return false
  131 + }
  132 + if (a == nil) != (b == nil) {
  133 + return false
  134 + }
  135 + b = b[:len(a)]
  136 + for i, v := range a {
  137 + if v != b[i] {
  138 + return false
  139 + }
  140 + }
  141 + return true
  142 +}
  143 +
  144 +// DividendsIncentivesRuleSliceEqualBCE 判断业绩分红激励规则Slice是否一样
  145 +func (cooperationContract *CooperationContract) DividendsIncentivesRuleSliceEqualBCE(a, b []*DividendsIncentivesRule) bool {
  146 + if len(a) != len(b) {
  147 + return false
  148 + }
  149 + if (a == nil) != (b == nil) {
  150 + return false
  151 + }
  152 + b = b[:len(a)]
  153 + for i, v := range a {
  154 + if v != b[i] {
  155 + return false
  156 + }
  157 + }
  158 + return true
  159 +}
  160 +
  161 +// MoneyIncentivesRuleSliceEqualBCE 判断金额激励规则Slice是否一样
  162 +func (cooperationContract *CooperationContract) MoneyIncentivesRuleSliceEqualBCE(a, b []*MoneyIncentivesRule) bool {
  163 + if len(a) != len(b) {
  164 + return false
  165 + }
  166 + if (a == nil) != (b == nil) {
  167 + return false
  168 + }
  169 + b = b[:len(a)]
  170 + for i, v := range a {
  171 + if v != b[i] {
  172 + return false
  173 + }
  174 + }
  175 + return true
  176 +}
@@ -2,6 +2,12 @@ package domain @@ -2,6 +2,12 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
  5 +const (
  6 + EDIT = iota + 1 // 编辑
  7 + PAUSE // 暂停
  8 + RECOVER // 恢复
  9 +)
  10 +
5 // CooperationContractChangeLog 共创合约变更日志 11 // CooperationContractChangeLog 共创合约变更日志
6 type CooperationContractChangeLog struct { 12 type CooperationContractChangeLog struct {
7 // 共创合约变更日志 13 // 共创合约变更日志
@@ -20,6 +26,8 @@ type CooperationContractChangeLog struct { @@ -20,6 +26,8 @@ type CooperationContractChangeLog struct {
20 Company *Company `json:"company"` 26 Company *Company `json:"company"`
21 // 操作人 27 // 操作人
22 Operator *User `json:"operator"` 28 Operator *User `json:"operator"`
  29 + // 操作时间
  30 + OperatorTime time.Time `json:"operatorTime"`
23 // 更新时间 31 // 更新时间
24 UpdatedAt time.Time `json:"updatedAt"` 32 UpdatedAt time.Time `json:"updatedAt"`
25 // 删除时间 33 // 删除时间
@@ -58,56 +66,5 @@ func (cooperationContractChangeLog *CooperationContractChangeLog) Update(data ma @@ -58,56 +66,5 @@ func (cooperationContractChangeLog *CooperationContractChangeLog) Update(data ma
58 if undertakers, ok := data["undertakers"]; ok { 66 if undertakers, ok := data["undertakers"]; ok {
59 cooperationContractChangeLog.Undertakers = undertakers.(string) 67 cooperationContractChangeLog.Undertakers = undertakers.(string)
60 } 68 }
61 - if companyId, ok := data["companyId"]; ok {  
62 - cooperationContractChangeLog.Company.CompanyId = companyId.(int64)  
63 - }  
64 - if companyLogo, ok := data["companyLogo"]; ok {  
65 - cooperationContractChangeLog.Company.CompanyLogo = companyLogo.(string)  
66 - }  
67 - if companyName, ok := data["companyName"]; ok {  
68 - cooperationContractChangeLog.Company.CompanyName = companyName.(string)  
69 - }  
70 - if userId, ok := data["userId"]; ok {  
71 - cooperationContractChangeLog.Operator.UserId = userId.(int64)  
72 - }  
73 - if userBaseId, ok := data["userBaseId"]; ok {  
74 - cooperationContractChangeLog.Operator.UserBaseId = userBaseId.(int64)  
75 - }  
76 - if orgId, ok := data["orgId"]; ok {  
77 - cooperationContractChangeLog.Operator.Org.OrgId = orgId.(int64)  
78 - }  
79 - if orgName, ok := data["orgName"]; ok {  
80 - cooperationContractChangeLog.Operator.Org.OrgName = orgName.(string)  
81 - }  
82 - if departmentId, ok := data["departmentId"]; ok {  
83 - cooperationContractChangeLog.Operator.Department.DepartmentId = departmentId.(int64)  
84 - }  
85 - if departmentName, ok := data["departmentName"]; ok {  
86 - cooperationContractChangeLog.Operator.Department.DepartmentName = departmentName.(string)  
87 - }  
88 - if departmentNumber, ok := data["departmentNumber"]; ok {  
89 - cooperationContractChangeLog.Operator.Department.DepartmentNumber = departmentNumber.(string)  
90 - }  
91 - if userAvatar, ok := data["userAvatar"]; ok {  
92 - cooperationContractChangeLog.Operator.UserInfo.UserAvatar = userAvatar.(string)  
93 - }  
94 - if userEmail, ok := data["userEmail"]; ok {  
95 - cooperationContractChangeLog.Operator.UserInfo.UserEmail = userEmail.(string)  
96 - }  
97 - if userName, ok := data["userName"]; ok {  
98 - cooperationContractChangeLog.Operator.UserInfo.UserName = userName.(string)  
99 - }  
100 - if userPhone, ok := data["userPhone"]; ok {  
101 - cooperationContractChangeLog.Operator.UserInfo.UserPhone = userPhone.(string)  
102 - }  
103 - if userAccount, ok := data["userAccount"]; ok {  
104 - cooperationContractChangeLog.Operator.UserInfo.UserAccount = userAccount.(string)  
105 - }  
106 - if userType, ok := data["userType"]; ok {  
107 - cooperationContractChangeLog.Operator.UserType = userType.(int32)  
108 - }  
109 - if status, ok := data["status"]; ok {  
110 - cooperationContractChangeLog.Operator.Status = status.(int32)  
111 - }  
112 return nil 69 return nil
113 } 70 }
@@ -2,6 +2,12 @@ package domain @@ -2,6 +2,12 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
  5 +const (
  6 + TO_BE_DIVIDEND = iota + 1
  7 + ALL_DIVIDENDED
  8 + PART_DIVIDENDED
  9 +)
  10 +
5 // DividendsOrder 分红订单实体 11 // DividendsOrder 分红订单实体
6 type DividendsOrder struct { 12 type DividendsOrder struct {
7 // 分红订单ID 13 // 分红订单ID
@@ -23,6 +23,8 @@ type CooperationContractChangeLog struct { @@ -23,6 +23,8 @@ type CooperationContractChangeLog struct {
23 Company *domain.Company `comment:"公司"` 23 Company *domain.Company `comment:"公司"`
24 // 操作人 24 // 操作人
25 Operator *domain.User `comment:"操作人"` 25 Operator *domain.User `comment:"操作人"`
  26 + // 操作时间
  27 + OperatorTime time.Time `comment:"操作时间"`
26 // 更新时间 28 // 更新时间
27 UpdatedAt time.Time `comment:"更新时间"` 29 UpdatedAt time.Time `comment:"更新时间"`
28 // 删除时间 30 // 删除时间
@@ -34,6 +34,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra @@ -34,6 +34,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra
34 "undertakers", 34 "undertakers",
35 "company", 35 "company",
36 "operator", 36 "operator",
  37 + "operator_time",
37 "updated_at", 38 "updated_at",
38 "deleted_at", 39 "deleted_at",
39 "created_at", 40 "created_at",
@@ -60,6 +61,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra @@ -60,6 +61,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra
60 &cooperationContractChangeLog.Undertakers, 61 &cooperationContractChangeLog.Undertakers,
61 &cooperationContractChangeLog.Company, 62 &cooperationContractChangeLog.Company,
62 &cooperationContractChangeLog.Operator, 63 &cooperationContractChangeLog.Operator,
  64 + &cooperationContractChangeLog.OperatorTime,
63 &cooperationContractChangeLog.UpdatedAt, 65 &cooperationContractChangeLog.UpdatedAt,
64 &cooperationContractChangeLog.DeletedAt, 66 &cooperationContractChangeLog.DeletedAt,
65 &cooperationContractChangeLog.CreatedAt, 67 &cooperationContractChangeLog.CreatedAt,
@@ -72,6 +74,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra @@ -72,6 +74,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra
72 cooperationContractChangeLog.Undertakers, 74 cooperationContractChangeLog.Undertakers,
73 cooperationContractChangeLog.Company, 75 cooperationContractChangeLog.Company,
74 cooperationContractChangeLog.Operator, 76 cooperationContractChangeLog.Operator,
  77 + cooperationContractChangeLog.OperatorTime,
75 cooperationContractChangeLog.UpdatedAt, 78 cooperationContractChangeLog.UpdatedAt,
76 nil, 79 nil,
77 cooperationContractChangeLog.CreatedAt, 80 cooperationContractChangeLog.CreatedAt,
@@ -88,6 +91,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra @@ -88,6 +91,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra
88 &cooperationContractChangeLog.Undertakers, 91 &cooperationContractChangeLog.Undertakers,
89 &cooperationContractChangeLog.Company, 92 &cooperationContractChangeLog.Company,
90 &cooperationContractChangeLog.Operator, 93 &cooperationContractChangeLog.Operator,
  94 + &cooperationContractChangeLog.OperatorTime,
91 &cooperationContractChangeLog.UpdatedAt, 95 &cooperationContractChangeLog.UpdatedAt,
92 &cooperationContractChangeLog.DeletedAt, 96 &cooperationContractChangeLog.DeletedAt,
93 &cooperationContractChangeLog.CreatedAt, 97 &cooperationContractChangeLog.CreatedAt,
@@ -100,6 +104,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra @@ -100,6 +104,7 @@ func (repository *CooperationContractChangeLogRepository) Save(cooperationContra
100 cooperationContractChangeLog.Undertakers, 104 cooperationContractChangeLog.Undertakers,
101 cooperationContractChangeLog.Company, 105 cooperationContractChangeLog.Company,
102 cooperationContractChangeLog.Operator, 106 cooperationContractChangeLog.Operator,
  107 + cooperationContractChangeLog.OperatorTime,
103 cooperationContractChangeLog.UpdatedAt, 108 cooperationContractChangeLog.UpdatedAt,
104 nil, 109 nil,
105 cooperationContractChangeLog.CreatedAt, 110 cooperationContractChangeLog.CreatedAt,