...
|
...
|
@@ -630,7 +630,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
|
|
// 获取分红激励规则列表
|
|
|
var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
|
|
|
dividendsIncentivesRuleQuery := tx.Model(÷ndsIncentivesRuleModels)
|
|
|
if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
|
|
if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
if _, err := tx.Model(÷ndsIncentivesRuleModels).WherePK().Delete(); err != nil {
|
...
|
...
|
@@ -640,7 +640,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
|
|
// 获取金额激励规则列表
|
|
|
var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
|
|
|
moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRuleModels)
|
|
|
if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
|
|
if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
if _, err := tx.Model(&moneyIncentivesRuleModels).WherePK().Delete(); err != nil {
|
...
|
...
|
@@ -650,7 +650,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
|
|
// 获取承接人列表
|
|
|
var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
|
|
|
cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakerModels)
|
|
|
if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
|
|
if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil {
|
...
|
...
|
@@ -660,7 +660,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
|
|
// 获取相关人列表
|
|
|
var cooperationContractRelevantModels []*models.CooperationContractRelevant
|
|
|
cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModels)
|
|
|
if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
|
|
if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil {
|
...
|
...
|
@@ -671,6 +671,64 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
|
|
return cooperationContract, nil
|
|
|
}
|
|
|
|
|
|
// BatchRemove 批量删除
|
|
|
func (repository *CooperationContractRepository) BatchRemove(cooperationContracts []*domain.CooperationContract) ([]*domain.CooperationContract, error) {
|
|
|
tx := repository.transactionContext.PgTx
|
|
|
var cooperationContractModels []*models.CooperationContract
|
|
|
for _, cooperationContract := range cooperationContracts {
|
|
|
cooperationContractModels = append(cooperationContractModels, &models.CooperationContract{
|
|
|
CooperationContractId: cooperationContract.Identify().(int64),
|
|
|
})
|
|
|
}
|
|
|
if _, err := tx.Model(&cooperationContractModels).WherePK().Delete(); err != nil {
|
|
|
return cooperationContracts, err
|
|
|
} else {
|
|
|
for _, cooperationContract := range cooperationContracts {
|
|
|
// 获取分红激励规则列表
|
|
|
var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
|
|
|
dividendsIncentivesRuleQuery := tx.Model(÷ndsIncentivesRuleModels)
|
|
|
if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.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 = ?", cooperationContract.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 = ?", cooperationContract.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 = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
return nil, err
|
|
|
} else {
|
|
|
if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return cooperationContracts, nil
|
|
|
}
|
|
|
|
|
|
func (repository *CooperationContractRepository) FindOne(queryOptions map[string]interface{}) (*domain.CooperationContract, error) {
|
|
|
tx := repository.transactionContext.PgTx
|
|
|
cooperationContractModel := new(models.CooperationContract)
|
...
|
...
|
@@ -738,6 +796,9 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in |
|
|
if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
|
|
|
query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
|
|
|
}
|
|
|
if cooperationContractIds, ok := queryOptions["cooperationContractIds"]; ok && len(cooperationContractIds.([]int64)) != 0 {
|
|
|
query.Where("cooperation_contract_id in (?)", pg.In(cooperationContractIds))
|
|
|
}
|
|
|
offsetLimitFlag := true
|
|
|
if limit, ok := queryOptions["limit"]; ok {
|
|
|
offsetLimitFlag = limit.(bool)
|
...
|
...
|
|