...
|
...
|
@@ -125,10 +125,10 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
CreatedAt: time.Now(),
|
|
|
})
|
|
|
}
|
|
|
if len(relevantPeopleModel) > 0 {
|
|
|
log.Logger.Info("新增的相关人", map[string]interface{}{
|
|
|
"relevantPeopleModel": relevantPeopleModel,
|
|
|
})
|
|
|
if len(relevantPeopleModel) > 0 {
|
|
|
if _, err := tx.Model(&relevantPeopleModel).Insert(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -158,6 +158,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
})
|
|
|
}
|
|
|
if len(undertakersModel) > 0 {
|
|
|
log.Logger.Info("新增的承接人", map[string]interface{}{
|
|
|
"undertakersModel": undertakersModel,
|
|
|
})
|
|
|
if _, err := tx.Model(&undertakersModel).Insert(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -183,6 +186,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
})
|
|
|
}
|
|
|
if len(dividendsIncentivesRulesModel) > 0 {
|
|
|
log.Logger.Info("新增分红激励规则", map[string]interface{}{
|
|
|
"dividendsIncentivesRulesModel": dividendsIncentivesRulesModel,
|
|
|
})
|
|
|
if _, err := tx.Model(÷ndsIncentivesRulesModel).Insert(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -209,6 +215,9 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai |
|
|
})
|
|
|
}
|
|
|
if len(moneyIncentivesRulesModel) > 0 {
|
|
|
log.Logger.Info("新增金额激励规则", map[string]interface{}{
|
|
|
"moneyIncentivesRulesModel": moneyIncentivesRulesModel,
|
|
|
})
|
|
|
if _, err := tx.Model(&moneyIncentivesRulesModel).Insert(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
...
|
...
|
@@ -1018,31 +1027,51 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in |
|
|
// 获取共创模式
|
|
|
cooperationModeModel := new(models.CooperationMode)
|
|
|
cooperationModeQuery := tx.Model(cooperationModeModel)
|
|
|
if err := cooperationModeQuery.Where("cooperation_mode_number = ?", cooperationContractModel.CooperationModeNumber).First(); err != nil {
|
|
|
if err := cooperationModeQuery.
|
|
|
Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId).
|
|
|
Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
|
|
|
Where("cooperation_mode_number = ?", cooperationContractModel.CooperationModeNumber).
|
|
|
First(); err != nil {
|
|
|
return 0, nil, err
|
|
|
}
|
|
|
// 获取分红激励规则列表
|
|
|
var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
|
|
|
dividendsIncentivesRuleQuery := tx.Model(÷ndsIncentivesRuleModels)
|
|
|
if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
|
|
if err := dividendsIncentivesRuleQuery.
|
|
|
Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId).
|
|
|
Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
|
|
|
Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).
|
|
|
Select(); err != nil {
|
|
|
return 0, nil, err
|
|
|
}
|
|
|
// 获取金额激励规则列表
|
|
|
var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
|
|
|
moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRuleModels)
|
|
|
if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
|
|
if err := moneyIncentivesRuleQuery.
|
|
|
Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId).
|
|
|
Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
|
|
|
Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).
|
|
|
Select(); err != nil {
|
|
|
return 0, nil, err
|
|
|
}
|
|
|
// 获取承接人列表
|
|
|
var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
|
|
|
cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakerModels)
|
|
|
if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
|
|
if err := cooperationContractUndertakerQuery.
|
|
|
Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId).
|
|
|
Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
|
|
|
Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).
|
|
|
Select(); err != nil {
|
|
|
return 0, nil, err
|
|
|
}
|
|
|
// 获取相关人列表
|
|
|
var cooperationContractRelevantModels []*models.CooperationContractRelevant
|
|
|
cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModels)
|
|
|
if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
|
|
if err := cooperationContractRelevantQuery.
|
|
|
Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId).
|
|
|
Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
|
|
|
Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).
|
|
|
Select(); err != nil {
|
|
|
return 0, nil, err
|
|
|
}
|
|
|
if cooperationContract, err := transform.TransformToCooperationContractDomainModelFromPgModels(
|
...
|
...
|
|