|
@@ -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
|
|
|
1068
|
+ }
|
|
|
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
|
+ }
|
935
|
}
|
1100
|
}
|
936
|
- return cooperationContract, nil
|
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
|
|