作者 陈志颖

refactor:优化合约变更记录

@@ -981,10 +981,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -981,10 +981,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
981 } 981 }
982 982
983 // 获取待更新的共创合约 983 // 获取待更新的共创合约
984 - cooperationContract, err8 := cooperationContractRepository.FindOne(map[string]interface{}{ 984 + cooperationContract, err9 := cooperationContractRepository.FindOne(map[string]interface{}{
985 "cooperationContractId": updateCooperationContractCommand.CooperationContractId, 985 "cooperationContractId": updateCooperationContractCommand.CooperationContractId,
986 }) 986 })
987 - if err8 != nil { 987 + if err9 != nil {
988 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在") 988 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
989 } 989 }
990 if cooperationContract == nil { 990 if cooperationContract == nil {
@@ -992,8 +992,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -992,8 +992,8 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
992 } 992 }
993 993
994 // 更新合约基础信息 994 // 更新合约基础信息
995 - if err9 := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err9 != nil {  
996 - return nil, application.ThrowError(application.BUSINESS_ERROR, err9.Error()) 995 + if err10 := cooperationContract.Update(tool_funs.SimpleStructToMap(updateCooperationContractCommand)); err10 != nil {
  996 + return nil, application.ThrowError(application.BUSINESS_ERROR, err10.Error())
997 } 997 }
998 998
999 // 更新发起人 999 // 更新发起人
@@ -1357,7 +1357,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1357,7 +1357,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1357 var moneyIncentivesRuleOriginal string 1357 var moneyIncentivesRuleOriginal string
1358 for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules { 1358 for _, moneyIncentivesRule := range cooperationContractFound.MoneyIncentivesRules {
1359 moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN + 1359 moneyIncentivesRuleOriginal = moneyIncentivesRuleOriginal + moneyIncentivesRule.MoneyIncentivesStageCN +
1360 - ":" + 1360 + ":" + fmt.Sprint(moneyIncentivesRule.MoneyIncentivesAmount) +
1361 "," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") + 1361 "," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") +
1362 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) + 1362 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
1363 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";" 1363 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
@@ -1367,7 +1367,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1367,7 +1367,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1367 var moneyIncentivesRuleChanged string 1367 var moneyIncentivesRuleChanged string
1368 for _, moneyIncentivesRule := range cooperationContract.MoneyIncentivesRules { 1368 for _, moneyIncentivesRule := range cooperationContract.MoneyIncentivesRules {
1369 moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN + 1369 moneyIncentivesRuleChanged = moneyIncentivesRuleChanged + moneyIncentivesRule.MoneyIncentivesStageCN +
1370 - ":" + 1370 + ":" + fmt.Sprint(moneyIncentivesRule.MoneyIncentivesAmount) +
1371 "," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") + 1371 "," + moneyIncentivesRule.MoneyIncentivesTime.Format("2006-01-02") +
1372 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) + 1372 "," + fmt.Sprint(moneyIncentivesRule.ReferrerPercentage) +
1373 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";" 1373 "," + fmt.Sprint(moneyIncentivesRule.SalesmanPercentage) + ";"
@@ -25,8 +25,8 @@ func TransformToCooperationContractDomainModelFromPgModels( @@ -25,8 +25,8 @@ func TransformToCooperationContractDomainModelFromPgModels(
25 DividendsIncentivesPercentage: rule.DividendsIncentivesPercentage, 25 DividendsIncentivesPercentage: rule.DividendsIncentivesPercentage,
26 DividendsIncentivesStage: rule.DividendsIncentivesStage, 26 DividendsIncentivesStage: rule.DividendsIncentivesStage,
27 DividendsIncentivesStageCN: stageString, 27 DividendsIncentivesStageCN: stageString,
28 - DividendsIncentivesStageEnd: rule.DividendsIncentivesStageEnd,  
29 - DividendsIncentivesStageStart: rule.DividendsIncentivesStageStart, 28 + DividendsIncentivesStageEnd: rule.DividendsIncentivesStageEnd.Local(),
  29 + DividendsIncentivesStageStart: rule.DividendsIncentivesStageStart.Local(),
30 Org: rule.Org, 30 Org: rule.Org,
31 Company: rule.Company, 31 Company: rule.Company,
32 UpdatedAt: rule.UpdatedAt, 32 UpdatedAt: rule.UpdatedAt,
@@ -47,7 +47,7 @@ func TransformToCooperationContractDomainModelFromPgModels( @@ -47,7 +47,7 @@ func TransformToCooperationContractDomainModelFromPgModels(
47 MoneyIncentivesStageCN: stageString, 47 MoneyIncentivesStageCN: stageString,
48 MoneyIncentivesStageEnd: rule.MoneyIncentivesStageEnd, 48 MoneyIncentivesStageEnd: rule.MoneyIncentivesStageEnd,
49 MoneyIncentivesStageStart: rule.MoneyIncentivesStageStart, 49 MoneyIncentivesStageStart: rule.MoneyIncentivesStageStart,
50 - MoneyIncentivesTime: rule.MoneyIncentivesTime, 50 + MoneyIncentivesTime: rule.MoneyIncentivesTime.Local(),
51 ReferrerPercentage: rule.ReferrerPercentage, 51 ReferrerPercentage: rule.ReferrerPercentage,
52 SalesmanPercentage: rule.SalesmanPercentage, 52 SalesmanPercentage: rule.SalesmanPercentage,
53 Org: rule.Org, 53 Org: rule.Org,
@@ -1111,7 +1111,7 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string @@ -1111,7 +1111,7 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string
1111 if err := cooperationContractUndertakerQuery. 1111 if err := cooperationContractUndertakerQuery.
1112 Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId). 1112 Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId).
1113 Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). 1113 Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
1114 - Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber). 1114 + Where("cooperation_contract_id = ?", cooperationContractModel.CooperationContractId).
1115 Select(); err != nil { 1115 Select(); err != nil {
1116 return nil, fmt.Errorf("合约承接人不存在") 1116 return nil, fmt.Errorf("合约承接人不存在")
1117 } 1117 }