作者 陈志颖

refactor:优化合约变更记录

... ... @@ -1195,10 +1195,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
var undertakerChange string
// 规则变更,原【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点),(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】-->更新后【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】
if cooperationContractFound.IncentivesType != cooperationContractSaved.IncentivesType { // 1.激励规则类型变更
if cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES && cooperationContractSaved.IncentivesType == domain.TYPE_MONEY_INCENTIVES { // 业绩分红变更为金额激励
if cooperationContractFound.IncentivesType != cooperationContract.IncentivesType { // 1.激励规则类型变更
if cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES && cooperationContract.IncentivesType == domain.TYPE_MONEY_INCENTIVES { // 业绩分红变更为金额激励
// 业绩分红-->金额激励
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContract.IncentivesType))
//【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
// 原业绩分红激励规则
var dividendsIncentivesRuleOriginal string
... ... @@ -1214,7 +1214,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
// 变更后的金额激励规则
var moneyIncentivesRuleChanged string
for _, moneyIncentivesRule := range cooperationContractSaved.MoneyIncentivesRules {
for _, moneyIncentivesRule := range cooperationContract.MoneyIncentivesRules {
moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN +
":" +
"," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
... ... @@ -1225,9 +1225,9 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
// 拼接规则变更
incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + moneyIncentivesRuleOriginalTmp
} else if cooperationContractFound.IncentivesType == domain.TYPE_MONEY_INCENTIVES && cooperationContractSaved.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES { // 金额激励变更为业绩分红
} else if cooperationContractFound.IncentivesType == domain.TYPE_MONEY_INCENTIVES && cooperationContract.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES { // 金额激励变更为业绩分红
// 金额激励-->业绩分红
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContract.IncentivesType))
//【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
// 原金额激励规则
var moneyIncentivesRuleOriginal string
... ... @@ -1242,7 +1242,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
// 变更后的业绩分红激励规则
var dividendsIncentivesRuleChanged string
for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules {
for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
dividendsIncentivesRuleChanged = dividendsIncentivesRuleChanged + dividendsIncentivesRule.DividendsIncentivesStageCN +
":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
"," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
... ... @@ -1257,9 +1257,9 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
}
} else if cooperationContractFound.IncentivesType == cooperationContractSaved.IncentivesType { // 2.激励规则内容变更
if cooperationContractFound.IncentivesType == domain.TYPE_DIVIDNEDS_INCENTIVES { // 业绩分红规则内容变更
if !cooperationContract.DividendsIncentivesRuleSliceEqualBCE(cooperationContractFound.DividendsIncentivesRules, cooperationContractSaved.DividendsIncentivesRules) {
if !cooperationContract.DividendsIncentivesRuleSliceEqualBCE(cooperationContractFound.DividendsIncentivesRules, cooperationContract.DividendsIncentivesRules) {
// 业绩分红-->业绩分红
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContract.IncentivesType))
//【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
// 原业绩分红激励规则
var dividendsIncentivesRuleOriginal string
... ... @@ -1274,7 +1274,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
dividendsIncentivesRuleOriginalTmp := "【" + dividendsIncentivesRuleOriginal + "】"
// 变更后的业绩分红激励规则
var dividendsIncentivesRuleChanged string
for _, dividendsIncentivesRule := range cooperationContractSaved.DividendsIncentivesRules {
for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
dividendsIncentivesRuleChanged = dividendsIncentivesRuleChanged + dividendsIncentivesRule.DividendsIncentivesStageCN +
":" + fmt.Sprint(dividendsIncentivesRule.DividendsIncentivesPercentage) +
"," + dividendsIncentivesRule.DividendsIncentivesStageStart.Format("2006-01-02") +
... ... @@ -1287,8 +1287,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
incentivesRuleChangeDetail = dividendsIncentivesRuleOriginalTmp + " 变更为 " + dividendsIncentivesRuleChangedTmp
}
} else if cooperationContractFound.IncentivesType == domain.MONEY_INCENTIVES { // 金额激励规则内容变更
if !cooperationContract.MoneyIncentivesRuleSliceEqualBCE(cooperationContractFound.MoneyIncentivesRules, cooperationContractSaved.MoneyIncentivesRules) {
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractSaved.IncentivesType))
if !cooperationContract.MoneyIncentivesRuleSliceEqualBCE(cooperationContractFound.MoneyIncentivesRules, cooperationContract.MoneyIncentivesRules) {
incentivesRuleChange = cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContractFound.IncentivesType)) + "-->" + cooperationContract.ReturnIncentivesName(domain.IncentivesType(cooperationContract.IncentivesType))
//【第一阶段:20,2021-01-01~2021-12-31,,,;第二阶段:20,2021-01-01~2021-12-31,30,10】变更为【第一阶段:20,2021-01-01~2021-12-31,,,;】
// 原金额激励规则
var moneyIncentivesRuleOriginal string
... ... @@ -1302,7 +1302,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
moneyIncentivesRuleOriginalTmp := "【" + moneyIncentivesRuleOriginal + "】"
// 变更后的激励规则
var moneyIncentivesRuleChanged string
for _, moneyIncentivesRule := range cooperationContractSaved.MoneyIncentivesRules {
for _, moneyIncentivesRule := range cooperationContract.MoneyIncentivesRules {
moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN +
":" +
"," + moneyIncentivesRule.MoneyIncentivesStageStart.Format("2006-01-02") +
... ... @@ -1317,7 +1317,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
}
// 承接人变更
if !cooperationContract.UndertakerSliceEqualBCE(cooperationContractFound.Undertakers, cooperationContractSaved.Undertakers) { // 【1(张三,李四,王五)2(买买买,,)】变更为【1(张三,,)】
if !cooperationContract.UndertakerSliceEqualBCE(cooperationContractFound.Undertakers, cooperationContract.Undertakers) { // 【1(张三,李四,王五)2(买买买,,)】变更为【1(张三,,)】
// 原承接人
var undertakersOriginal string
for i, undertaker := range cooperationContractFound.Undertakers {
... ... @@ -1401,7 +1401,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
IncentivesRuleDetail: incentivesRuleChangeDetail,
OperationType: domain.EDIT,
Undertakers: undertakerChange,
CooperationContractNumber: cooperationContractSaved.CooperationContractNumber,
CooperationContractNumber: cooperationContract.CooperationContractNumber,
Company: company,
Org: organization,
Operator: operator,
... ...