作者 陈志颖

refactor:优化合约变更记录

@@ -28,7 +28,7 @@ type UpdateCooperationContractCommand struct { @@ -28,7 +28,7 @@ type UpdateCooperationContractCommand struct {
28 // 金额激励规则列表 28 // 金额激励规则列表
29 MoneyIncentivesRules []*CreateMoneyIncentivesRulesCommand `cname:"金额激励规则列表" json:"moneyIncentivesRules,omitempty"` 29 MoneyIncentivesRules []*CreateMoneyIncentivesRulesCommand `cname:"金额激励规则列表" json:"moneyIncentivesRules,omitempty"`
30 // 承接方列表 30 // 承接方列表
31 - Undertakers []*CreateUndertakersCommand `cname:"承接方列表" json:"undertakers" valid:"Required"` 31 + Undertakers []*CreateUndertakersCommand `cname:"承接方列表" json:"undertakers"`
32 // 相关人UID列表 32 // 相关人UID列表
33 RelevantIds []string `cname:"相关人列表" json:"relevantIds,omitempty"` 33 RelevantIds []string `cname:"相关人列表" json:"relevantIds,omitempty"`
34 // 公司ID,通过集成REST上下文获取 34 // 公司ID,通过集成REST上下文获取
@@ -1205,7 +1205,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1205,7 +1205,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1205 // 保存共创合约变更记录 1205 // 保存共创合约变更记录
1206 var incentivesRuleChange string 1206 var incentivesRuleChange string
1207 var incentivesRuleChangeDetail string 1207 var incentivesRuleChangeDetail string
1208 - var undertakerChange string  
1209 1208
1210 // 规则变更,原【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点),(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】-->更新后【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】 1209 // 规则变更,原【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点),(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】-->更新后【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】
1211 if cooperationContractFound.IncentivesType != cooperationContract.IncentivesType { // 1.激励规则类型变更 1210 if cooperationContractFound.IncentivesType != cooperationContract.IncentivesType { // 1.激励规则类型变更
@@ -1382,6 +1381,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1382,6 +1381,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1382 } 1381 }
1383 1382
1384 /*********************************************** 承接人变更 *****************************************************/ 1383 /*********************************************** 承接人变更 *****************************************************/
  1384 + var undertakerChange string
1385 // 计算原合约哈希值 1385 // 计算原合约哈希值
1386 //cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.Undertakers)) 1386 //cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.Undertakers))
1387 var cooperationContractFoundBytes []byte 1387 var cooperationContractFoundBytes []byte
@@ -1441,7 +1441,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1441,7 +1441,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1441 UserPhone: "", 1441 UserPhone: "",
1442 } 1442 }
1443 } 1443 }
1444 - undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" 1444 + undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserInfo.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
1445 } 1445 }
1446 undertakerChangeTmp1 := "【" + undertakersOriginal + "】" 1446 undertakerChangeTmp1 := "【" + undertakersOriginal + "】"
1447 1447
@@ -1478,7 +1478,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1478,7 +1478,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1478 UserPhone: "", 1478 UserPhone: "",
1479 } 1479 }
1480 } 1480 }
1481 - undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" 1481 + undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserInfo.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
1482 } 1482 }
1483 undertakerChangeTemp2 := "【" + undertakersChanged + "】" 1483 undertakerChangeTemp2 := "【" + undertakersChanged + "】"
1484 // 拼接承接人变更记录 1484 // 拼接承接人变更记录
@@ -15,9 +15,9 @@ func TransformToCooperationContractChangeLogDomainModelFromPgModels(cooperationC @@ -15,9 +15,9 @@ func TransformToCooperationContractChangeLogDomainModelFromPgModels(cooperationC
15 Company: cooperationContractChangeLogModel.Company, 15 Company: cooperationContractChangeLogModel.Company,
16 Org: cooperationContractChangeLogModel.Org, 16 Org: cooperationContractChangeLogModel.Org,
17 Operator: cooperationContractChangeLogModel.Operator, 17 Operator: cooperationContractChangeLogModel.Operator,
18 - OperatorTime: cooperationContractChangeLogModel.OperatorTime, 18 + OperatorTime: cooperationContractChangeLogModel.OperatorTime.Local(),
19 UpdatedAt: cooperationContractChangeLogModel.UpdatedAt, 19 UpdatedAt: cooperationContractChangeLogModel.UpdatedAt,
20 DeletedAt: cooperationContractChangeLogModel.DeletedAt, 20 DeletedAt: cooperationContractChangeLogModel.DeletedAt,
21 - CreatedAt: cooperationContractChangeLogModel.CreatedAt, 21 + CreatedAt: cooperationContractChangeLogModel.CreatedAt.Local(),
22 }, nil 22 }, nil
23 } 23 }
@@ -51,7 +51,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -51,7 +51,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
51 updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "cooperationContract_id") 51 updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "cooperationContract_id")
52 updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields) 52 updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
53 tx := repository.transactionContext.PgTx 53 tx := repository.transactionContext.PgTx
54 - if cooperationContract.Identify() == nil { 54 + if cooperationContract.Identify() == nil { // 新增合约
55 cooperationContractId, err := repository.nextIdentify() 55 cooperationContractId, err := repository.nextIdentify()
56 if err != nil { 56 if err != nil {
57 return cooperationContract, err 57 return cooperationContract, err
@@ -256,7 +256,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -256,7 +256,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
256 return nil, err 256 return nil, err
257 } 257 }
258 } 258 }
259 - } else { 259 + } else { // 编辑合约
260 if _, err := tx.QueryOne( 260 if _, err := tx.QueryOne(
261 pg.Scan( 261 pg.Scan(
262 &cooperationContract.CooperationContractId, 262 &cooperationContract.CooperationContractId,
@@ -823,13 +823,6 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -823,13 +823,6 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
823 } 823 }
824 } 824 }
825 } 825 }
826 - // 返回新增的合约  
827 - //cooperationContractSaved, err := repository.FindOne(map[string]interface{}{  
828 - // "cooperationContractId": cooperationContract.CooperationContractId,  
829 - //})  
830 - //if err != nil {  
831 - // return nil, err  
832 - //}  
833 return cooperationContract, nil 826 return cooperationContract, nil
834 } 827 }
835 828
@@ -1111,7 +1104,8 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string @@ -1111,7 +1104,8 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string
1111 if err := cooperationContractUndertakerQuery. 1104 if err := cooperationContractUndertakerQuery.
1112 Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId). 1105 Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId).
1113 Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId). 1106 Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
1114 - Where("cooperation_contract_id = ?", cooperationContractModel.CooperationContractId). 1107 + //Where("cooperation_contract_id = ?", cooperationContractModel.CooperationContractId).
  1108 + Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).
1115 Select(); err != nil { 1109 Select(); err != nil {
1116 return nil, fmt.Errorf("合约承接人不存在") 1110 return nil, fmt.Errorf("合约承接人不存在")
1117 } 1111 }