...
|
...
|
@@ -1041,7 +1041,15 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string |
|
|
cooperationContractModel := new(models.CooperationContract)
|
|
|
query := sqlbuilder.BuildQuery(tx.Model(cooperationContractModel), queryOptions)
|
|
|
query.SetWhereByQueryOption("cooperation_contract.cooperation_contract_id = ?", "cooperationContractId")
|
|
|
query.SetWhereByQueryOption("cooperation_contract.cooperation_contract_number = ?", "cooperationContractNumber")
|
|
|
if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
|
|
|
query.Where("cooperation_contract.cooperation_contract_number = ?", cooperationContractNumber)
|
|
|
}
|
|
|
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
|
|
|
query.Where("company->>'companyId' = '?'", companyId)
|
|
|
}
|
|
|
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
|
|
|
query.Where("org->>'orgId' = '?'", orgId)
|
|
|
}
|
|
|
if err := query.First(); err != nil {
|
|
|
if err.Error() == "pg: no rows in result set" {
|
|
|
return nil, fmt.Errorf("共创合约不存在")
|
...
|
...
|
@@ -1053,15 +1061,28 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string |
|
|
return nil, nil
|
|
|
} else {
|
|
|
// 获取共创模式
|
|
|
cooperationModeModels := new(models.CooperationMode)
|
|
|
cooperationModeQuery := tx.Model(cooperationModeModels)
|
|
|
if err := cooperationModeQuery.
|
|
|
//cooperationModeModels := new(models.CooperationMode)
|
|
|
//cooperationModeQuery := tx.Model(cooperationModeModels)
|
|
|
//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 nil, fmt.Errorf("共创合约关联的共创模式不存在")
|
|
|
//}
|
|
|
var cooperationModeModels []*models.CooperationMode
|
|
|
cooperationModeQuery := tx.Model(&cooperationModeModels)
|
|
|
if countMode, err := cooperationModeQuery.
|
|
|
Where("company->>'companyId' = '?'", cooperationContractModel.Company.CompanyId).
|
|
|
Where("org->>'orgId' = '?'", cooperationContractModel.Org.OrgId).
|
|
|
Where("cooperation_mode_number = ?", cooperationContractModel.CooperationModeNumber).
|
|
|
First(); err != nil {
|
|
|
return nil, fmt.Errorf("共创合约关联的共创模式不存在")
|
|
|
}
|
|
|
Limit(1).
|
|
|
SelectAndCount(); err != nil {
|
|
|
log.Logger.Error("合约关联的共创模式不存在", map[string]interface{}{
|
|
|
"cooperationContractModel": cooperationContractModel,
|
|
|
})
|
|
|
} else {
|
|
|
if countMode > 0 {
|
|
|
// 获取分红激励规则列表
|
|
|
var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
|
|
|
dividendsIncentivesRuleQuery := tx.Model(÷ndsIncentivesRuleModels)
|
...
|
...
|
@@ -1104,12 +1125,15 @@ func (repository *CooperationContractRepository) FindOne(queryOptions map[string |
|
|
}
|
|
|
return transform.TransformToCooperationContractDomainModelFromPgModels(
|
|
|
cooperationContractModel,
|
|
|
cooperationModeModels,
|
|
|
cooperationModeModels[0],
|
|
|
dividendsIncentivesRuleModels,
|
|
|
moneyIncentivesRuleModels,
|
|
|
cooperationContractRelevantModels,
|
|
|
cooperationContractUndertakerModels)
|
|
|
}
|
|
|
}
|
|
|
return nil, fmt.Errorf("共创合约不存在")
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (repository *CooperationContractRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.CooperationContract, error) {
|
...
|
...
|
|