|
...
|
...
|
@@ -32,7 +32,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
|
"cooperation_contract_number",
|
|
|
|
"cooperation_contract_referrer",
|
|
|
|
"cooperation_contract_salesman",
|
|
|
|
"cooperation_contract_undertaker_type",
|
|
|
|
"cooperation_contract_undertaker_types",
|
|
|
|
"cooperation_contract_sponsor",
|
|
|
|
"cooperation_mode_number",
|
|
|
|
"status",
|
|
...
|
...
|
@@ -65,7 +65,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
|
&cooperationContract.CooperationContractNumber,
|
|
|
|
&cooperationContract.CooperationContractReferrer,
|
|
|
|
&cooperationContract.CooperationContractSalesman,
|
|
|
|
pg.Array(&cooperationContract.CooperationContractUndertakerType),
|
|
|
|
pg.Array(&cooperationContract.CooperationContractUndertakerTypes),
|
|
|
|
&cooperationContract.CooperationContractSponsor,
|
|
|
|
&cooperationContract.CooperationMode.CooperationModeNumber,
|
|
|
|
&cooperationContract.Status,
|
|
...
|
...
|
@@ -84,7 +84,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
|
cooperationContract.CooperationContractNumber,
|
|
|
|
cooperationContract.CooperationContractReferrer,
|
|
|
|
cooperationContract.CooperationContractSalesman,
|
|
|
|
pg.Array(cooperationContract.CooperationContractUndertakerType),
|
|
|
|
pg.Array(cooperationContract.CooperationContractUndertakerTypes),
|
|
|
|
cooperationContract.CooperationContractSponsor,
|
|
|
|
cooperationContract.CooperationMode.CooperationModeNumber,
|
|
|
|
cooperationContract.Status,
|
|
...
|
...
|
@@ -189,7 +189,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
|
&cooperationContract.CooperationContractNumber,
|
|
|
|
&cooperationContract.CooperationContractReferrer,
|
|
|
|
&cooperationContract.CooperationContractSalesman,
|
|
|
|
pg.Array(&cooperationContract.CooperationContractUndertakerType),
|
|
|
|
pg.Array(&cooperationContract.CooperationContractUndertakerTypes),
|
|
|
|
&cooperationContract.CooperationContractSponsor,
|
|
|
|
&cooperationContract.CooperationMode.CooperationModeNumber,
|
|
|
|
&cooperationContract.Status,
|
|
...
|
...
|
@@ -208,7 +208,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
|
cooperationContract.CooperationContractNumber,
|
|
|
|
cooperationContract.CooperationContractReferrer,
|
|
|
|
cooperationContract.CooperationContractSalesman,
|
|
|
|
pg.Array(cooperationContract.CooperationContractUndertakerType),
|
|
|
|
pg.Array(cooperationContract.CooperationContractUndertakerTypes),
|
|
|
|
cooperationContract.CooperationContractSponsor,
|
|
|
|
cooperationContract.CooperationMode.CooperationModeNumber,
|
|
|
|
cooperationContract.Status,
|
|
...
|
...
|
@@ -224,6 +224,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
|
return cooperationContract, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO 更新相关人
|
|
|
|
// 查找相关人列表
|
|
|
|
var cooperationContractRelevantFetched []*models.CooperationContractRelevant
|
|
|
|
cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantFetched)
|
|
...
|
...
|
@@ -233,8 +234,10 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
|
|
|
|
|
// 待更新相关人
|
|
|
|
var cooperationContractRelevantPeopleToUpdate []*domain.Relevant
|
|
|
|
|
|
|
|
// 待添加相关人
|
|
|
|
var cooperationContractRelevantPeopleToAdd []*domain.Relevant
|
|
|
|
|
|
|
|
for _, relevant := range cooperationContract.RelevantPeople {
|
|
|
|
if relevant.RelevantId != 0 {
|
|
|
|
cooperationContractRelevantPeopleToUpdate = append(cooperationContractRelevantPeopleToUpdate, relevant)
|
|
...
|
...
|
@@ -285,30 +288,26 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 待删除的相关人
|
|
|
|
|
|
|
|
// 待新增的相关人
|
|
|
|
|
|
|
|
//TODO 更新承接人
|
|
|
|
// 获取承接人列表
|
|
|
|
var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
|
|
|
|
cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakerModels)
|
|
|
|
var cooperationContractUndertakersFetched []*models.CooperationContractUndertaker
|
|
|
|
cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakersFetched)
|
|
|
|
if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO 更新分红激励规则
|
|
|
|
// 获取分红激励规则列表
|
|
|
|
var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
|
|
|
|
dividendsIncentivesRuleQuery := tx.Model(÷ndsIncentivesRuleModels)
|
|
|
|
var dividendsIncentivesRulesFetched []*models.DividendsIncentivesRule
|
|
|
|
dividendsIncentivesRuleQuery := tx.Model(÷ndsIncentivesRulesFetched)
|
|
|
|
if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
//TODO 更新金额激励规则
|
|
|
|
// 获取金额激励规则列表
|
|
|
|
var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
|
|
|
|
moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRuleModels)
|
|
|
|
var moneyIncentivesRulesFetched []*models.MoneyIncentivesRule
|
|
|
|
moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRulesFetched)
|
|
|
|
if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
...
|
...
|
@@ -322,7 +321,46 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
|
|
|
if _, err := tx.Model(cooperationContractModel).WherePK().Delete(); err != nil {
|
|
|
|
return cooperationContract, err
|
|
|
|
} else {
|
|
|
|
//TODO 删除关联数据
|
|
|
|
// 获取分红激励规则列表
|
|
|
|
var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
|
|
|
|
dividendsIncentivesRuleQuery := tx.Model(÷ndsIncentivesRuleModels)
|
|
|
|
if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
if _, err := tx.Model(÷ndsIncentivesRuleModels).WherePK().Delete(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 获取金额激励规则列表
|
|
|
|
var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
|
|
|
|
moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRuleModels)
|
|
|
|
if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
if _, err := tx.Model(&moneyIncentivesRuleModels).WherePK().Delete(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 获取承接人列表
|
|
|
|
var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
|
|
|
|
cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakerModels)
|
|
|
|
if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 获取相关人列表
|
|
|
|
var cooperationContractRelevantModels []*models.CooperationContractRelevant
|
|
|
|
cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModels)
|
|
|
|
if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
} else {
|
|
|
|
if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return cooperationContract, nil
|
|
|
|
}
|
...
|
...
|
|