|
@@ -801,6 +801,14 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -801,6 +801,14 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
801
|
sponsor = data
|
801
|
sponsor = data
|
|
802
|
}
|
802
|
}
|
|
803
|
|
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
|
+
|
|
804
|
// 更新发起人
|
812
|
// 更新发起人
|
|
805
|
cooperationContract.CooperationContractSponsor = sponsor
|
813
|
cooperationContract.CooperationContractSponsor = sponsor
|
|
806
|
|
814
|
|
|
@@ -947,28 +955,183 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
@@ -947,28 +955,183 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC |
|
947
|
// 更新金额激励规则列表
|
955
|
// 更新金额激励规则列表
|
|
948
|
cooperationContract.MoneyIncentivesRules = moneyIncentivesRules
|
956
|
cooperationContract.MoneyIncentivesRules = moneyIncentivesRules
|
|
949
|
|
957
|
|
|
|
|
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
|
+
|
|
950
|
// 保存共创合约变更
|
967
|
// 保存共创合约变更
|
|
951
|
if cooperationContractSaved, err19 := cooperationContractRepository.Save(cooperationContract); err19 != nil {
|
968
|
if cooperationContractSaved, err19 := cooperationContractRepository.Save(cooperationContract); err19 != nil {
|
|
952
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err19.Error())
|
969
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err19.Error())
|
|
953
|
} else {
|
970
|
} else {
|
|
954
|
- // TODO 保存共创合约变更记录
|
|
|
|
955
|
- var incentivesRule string
|
|
|
|
956
|
- var incentivesRuleDetail string
|
|
|
|
957
|
- if cooperationContractFound.IncentivesType != cooperationContractSaved.IncentivesType { // 1.激励规则变更
|
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 + "】"
|
|
958
|
|
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
|
+ }
|
|
959
|
}
|
1100
|
}
|
|
960
|
|
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
|
+ // 新增共创合约变更记录
|
|
961
|
newCooperationContractChangeLog := &domain.CooperationContractChangeLog{
|
1122
|
newCooperationContractChangeLog := &domain.CooperationContractChangeLog{
|
|
962
|
- IncentivesRule: incentivesRule,
|
|
|
|
963
|
- IncentivesRuleDetail: incentivesRuleDetail,
|
|
|
|
964
|
- OperationType: 0,
|
|
|
|
965
|
- Undertakers: "",
|
1123
|
+ IncentivesRule: incentivesRuleChange,
|
|
|
|
1124
|
+ IncentivesRuleDetail: incentivesRuleChangeDetail,
|
|
|
|
1125
|
+ OperationType: domain.EDIT,
|
|
|
|
1126
|
+ Undertakers: undertakerChange,
|
|
966
|
CooperationContractNumber: cooperationContractSaved.CooperationContractNumber,
|
1127
|
CooperationContractNumber: cooperationContractSaved.CooperationContractNumber,
|
|
967
|
Company: company,
|
1128
|
Company: company,
|
|
968
|
- Operator: nil,
|
1129
|
+ Operator: operator,
|
|
969
|
UpdatedAt: time.Time{},
|
1130
|
UpdatedAt: time.Time{},
|
|
970
|
CreatedAt: time.Now(),
|
1131
|
CreatedAt: time.Now(),
|
|
971
|
}
|
1132
|
}
|
|
|
|
1133
|
+
|
|
|
|
1134
|
+ // 保存共创合约变更记录
|
|
972
|
if _, err20 := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err20 != nil {
|
1135
|
if _, err20 := cooperationContractChangeLogRepository.Save(newCooperationContractChangeLog); err20 != nil {
|
|
973
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err20.Error())
|
1136
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err20.Error())
|
|
974
|
}
|
1137
|
}
|