作者 陈志颖

refactor:优化合约变更记录

... ... @@ -28,7 +28,7 @@ type UpdateCooperationContractCommand struct {
// 金额激励规则列表
MoneyIncentivesRules []*CreateMoneyIncentivesRulesCommand `cname:"金额激励规则列表" json:"moneyIncentivesRules,omitempty"`
// 承接方列表
Undertakers []*CreateUndertakersCommand `cname:"承接方列表" json:"undertakers" valid:"Required"`
Undertakers []*CreateUndertakersCommand `cname:"承接方列表" json:"undertakers"`
// 相关人UID列表
RelevantIds []string `cname:"相关人列表" json:"relevantIds,omitempty"`
// 公司ID,通过集成REST上下文获取
... ...
... ... @@ -1205,7 +1205,6 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
// 保存共创合约变更记录
var incentivesRuleChange string
var incentivesRuleChangeDetail string
var undertakerChange string
// 规则变更,原【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点),(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】-->更新后【(激励阶段:激励百分点,阶段有效期,推荐人抽点,关联业务员抽点)】
if cooperationContractFound.IncentivesType != cooperationContract.IncentivesType { // 1.激励规则类型变更
... ... @@ -1382,6 +1381,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
}
/*********************************************** 承接人变更 *****************************************************/
var undertakerChange string
// 计算原合约哈希值
//cooperationContractFoundByte := *(*[]byte)(unsafe.Pointer(&cooperationContractFound.Undertakers))
var cooperationContractFoundBytes []byte
... ... @@ -1441,7 +1441,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
UserPhone: "",
}
}
undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserInfo.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
}
undertakerChangeTmp1 := "【" + undertakersOriginal + "】"
... ... @@ -1478,7 +1478,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
UserPhone: "",
}
}
undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserInfo.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
}
undertakerChangeTemp2 := "【" + undertakersChanged + "】"
// 拼接承接人变更记录
... ...
... ... @@ -15,9 +15,9 @@ func TransformToCooperationContractChangeLogDomainModelFromPgModels(cooperationC
Company: cooperationContractChangeLogModel.Company,
Org: cooperationContractChangeLogModel.Org,
Operator: cooperationContractChangeLogModel.Operator,
OperatorTime: cooperationContractChangeLogModel.OperatorTime,
OperatorTime: cooperationContractChangeLogModel.OperatorTime.Local(),
UpdatedAt: cooperationContractChangeLogModel.UpdatedAt,
DeletedAt: cooperationContractChangeLogModel.DeletedAt,
CreatedAt: cooperationContractChangeLogModel.CreatedAt,
CreatedAt: cooperationContractChangeLogModel.CreatedAt.Local(),
}, nil
}
... ...
... ... @@ -51,7 +51,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "cooperationContract_id")
updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
tx := repository.transactionContext.PgTx
if cooperationContract.Identify() == nil {
if cooperationContract.Identify() == nil { // 新增合约
cooperationContractId, err := repository.nextIdentify()
if err != nil {
return cooperationContract, err
... ... @@ -256,7 +256,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
return nil, err
}
}
} else {
} else { // 编辑合约
if _, err := tx.QueryOne(
pg.Scan(
&cooperationContract.CooperationContractId,
... ... @@ -823,13 +823,6 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
}
}
}
// 返回新增的合约
//cooperationContractSaved, err := repository.FindOne(map[string]interface{}{
// "cooperationContractId": cooperationContract.CooperationContractId,
//})
//if err != nil {
// return nil, err
//}
return cooperationContract, nil
}
... ... @@ -1111,7 +1104,8 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string
if err := cooperationContractUndertakerQuery.
Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId).
Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
Where("cooperation_contract_id = ?", cooperationContractModel.CooperationContractId).
//Where("cooperation_contract_id = ?", cooperationContractModel.CooperationContractId).
Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).
Select(); err != nil {
return nil, fmt.Errorf("合约承接人不存在")
}
... ...