|
@@ -630,7 +630,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
|
@@ -630,7 +630,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
630
|
// 获取分红激励规则列表
|
630
|
// 获取分红激励规则列表
|
631
|
var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
|
631
|
var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
|
632
|
dividendsIncentivesRuleQuery := tx.Model(÷ndsIncentivesRuleModels)
|
632
|
dividendsIncentivesRuleQuery := tx.Model(÷ndsIncentivesRuleModels)
|
633
|
- if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
633
|
+ if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
634
|
return nil, err
|
634
|
return nil, err
|
635
|
} else {
|
635
|
} else {
|
636
|
if _, err := tx.Model(÷ndsIncentivesRuleModels).WherePK().Delete(); err != nil {
|
636
|
if _, err := tx.Model(÷ndsIncentivesRuleModels).WherePK().Delete(); err != nil {
|
|
@@ -640,7 +640,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
|
@@ -640,7 +640,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
640
|
// 获取金额激励规则列表
|
640
|
// 获取金额激励规则列表
|
641
|
var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
|
641
|
var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
|
642
|
moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRuleModels)
|
642
|
moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRuleModels)
|
643
|
- if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
643
|
+ if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
644
|
return nil, err
|
644
|
return nil, err
|
645
|
} else {
|
645
|
} else {
|
646
|
if _, err := tx.Model(&moneyIncentivesRuleModels).WherePK().Delete(); err != nil {
|
646
|
if _, err := tx.Model(&moneyIncentivesRuleModels).WherePK().Delete(); err != nil {
|
|
@@ -650,7 +650,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
|
@@ -650,7 +650,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
650
|
// 获取承接人列表
|
650
|
// 获取承接人列表
|
651
|
var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
|
651
|
var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
|
652
|
cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakerModels)
|
652
|
cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakerModels)
|
653
|
- if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
653
|
+ if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
654
|
return nil, err
|
654
|
return nil, err
|
655
|
} else {
|
655
|
} else {
|
656
|
if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil {
|
656
|
if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil {
|
|
@@ -660,7 +660,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
|
@@ -660,7 +660,7 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
660
|
// 获取相关人列表
|
660
|
// 获取相关人列表
|
661
|
var cooperationContractRelevantModels []*models.CooperationContractRelevant
|
661
|
var cooperationContractRelevantModels []*models.CooperationContractRelevant
|
662
|
cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModels)
|
662
|
cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModels)
|
663
|
- if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContractModel.CooperationContractNumber).Select(); err != nil {
|
663
|
+ if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
664
|
return nil, err
|
664
|
return nil, err
|
665
|
} else {
|
665
|
} else {
|
666
|
if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil {
|
666
|
if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil {
|
|
@@ -671,6 +671,64 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
|
@@ -671,6 +671,64 @@ func (repository *CooperationContractRepository) Remove(cooperationContract *dom |
671
|
return cooperationContract, nil
|
671
|
return cooperationContract, nil
|
672
|
}
|
672
|
}
|
673
|
|
673
|
|
|
|
674
|
+// BatchRemove 批量删除
|
|
|
675
|
+func (repository *CooperationContractRepository) BatchRemove(cooperationContracts []*domain.CooperationContract) ([]*domain.CooperationContract, error) {
|
|
|
676
|
+ tx := repository.transactionContext.PgTx
|
|
|
677
|
+ var cooperationContractModels []*models.CooperationContract
|
|
|
678
|
+ for _, cooperationContract := range cooperationContracts {
|
|
|
679
|
+ cooperationContractModels = append(cooperationContractModels, &models.CooperationContract{
|
|
|
680
|
+ CooperationContractId: cooperationContract.Identify().(int64),
|
|
|
681
|
+ })
|
|
|
682
|
+ }
|
|
|
683
|
+ if _, err := tx.Model(&cooperationContractModels).WherePK().Delete(); err != nil {
|
|
|
684
|
+ return cooperationContracts, err
|
|
|
685
|
+ } else {
|
|
|
686
|
+ for _, cooperationContract := range cooperationContracts {
|
|
|
687
|
+ // 获取分红激励规则列表
|
|
|
688
|
+ var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
|
|
|
689
|
+ dividendsIncentivesRuleQuery := tx.Model(÷ndsIncentivesRuleModels)
|
|
|
690
|
+ if err := dividendsIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
691
|
+ return nil, err
|
|
|
692
|
+ } else {
|
|
|
693
|
+ if _, err := tx.Model(÷ndsIncentivesRuleModels).WherePK().Delete(); err != nil {
|
|
|
694
|
+ return nil, err
|
|
|
695
|
+ }
|
|
|
696
|
+ }
|
|
|
697
|
+ // 获取金额激励规则列表
|
|
|
698
|
+ var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
|
|
|
699
|
+ moneyIncentivesRuleQuery := tx.Model(&moneyIncentivesRuleModels)
|
|
|
700
|
+ if err := moneyIncentivesRuleQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
701
|
+ return nil, err
|
|
|
702
|
+ } else {
|
|
|
703
|
+ if _, err := tx.Model(&moneyIncentivesRuleModels).WherePK().Delete(); err != nil {
|
|
|
704
|
+ return nil, err
|
|
|
705
|
+ }
|
|
|
706
|
+ }
|
|
|
707
|
+ // 获取承接人列表
|
|
|
708
|
+ var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
|
|
|
709
|
+ cooperationContractUndertakerQuery := tx.Model(&cooperationContractUndertakerModels)
|
|
|
710
|
+ if err := cooperationContractUndertakerQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
711
|
+ return nil, err
|
|
|
712
|
+ } else {
|
|
|
713
|
+ if _, err := tx.Model(&cooperationContractUndertakerModels).WherePK().Delete(); err != nil {
|
|
|
714
|
+ return nil, err
|
|
|
715
|
+ }
|
|
|
716
|
+ }
|
|
|
717
|
+ // 获取相关人列表
|
|
|
718
|
+ var cooperationContractRelevantModels []*models.CooperationContractRelevant
|
|
|
719
|
+ cooperationContractRelevantQuery := tx.Model(&cooperationContractRelevantModels)
|
|
|
720
|
+ if err := cooperationContractRelevantQuery.Where("cooperation_contract_number = ?", cooperationContract.CooperationContractNumber).Select(); err != nil {
|
|
|
721
|
+ return nil, err
|
|
|
722
|
+ } else {
|
|
|
723
|
+ if _, err := tx.Model(&cooperationContractRelevantModels).WherePK().Delete(); err != nil {
|
|
|
724
|
+ return nil, err
|
|
|
725
|
+ }
|
|
|
726
|
+ }
|
|
|
727
|
+ }
|
|
|
728
|
+ }
|
|
|
729
|
+ return cooperationContracts, nil
|
|
|
730
|
+}
|
|
|
731
|
+
|
674
|
func (repository *CooperationContractRepository) FindOne(queryOptions map[string]interface{}) (*domain.CooperationContract, error) {
|
732
|
func (repository *CooperationContractRepository) FindOne(queryOptions map[string]interface{}) (*domain.CooperationContract, error) {
|
675
|
tx := repository.transactionContext.PgTx
|
733
|
tx := repository.transactionContext.PgTx
|
676
|
cooperationContractModel := new(models.CooperationContract)
|
734
|
cooperationContractModel := new(models.CooperationContract)
|
|
@@ -738,6 +796,9 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in |
|
@@ -738,6 +796,9 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in |
738
|
if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
|
796
|
if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
|
739
|
query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
|
797
|
query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
|
740
|
}
|
798
|
}
|
|
|
799
|
+ if cooperationContractIds, ok := queryOptions["cooperationContractIds"]; ok && len(cooperationContractIds.([]int64)) != 0 {
|
|
|
800
|
+ query.Where("cooperation_contract_id in (?)", pg.In(cooperationContractIds))
|
|
|
801
|
+ }
|
741
|
offsetLimitFlag := true
|
802
|
offsetLimitFlag := true
|
742
|
if limit, ok := queryOptions["limit"]; ok {
|
803
|
if limit, ok := queryOptions["limit"]; ok {
|
743
|
offsetLimitFlag = limit.(bool)
|
804
|
offsetLimitFlag = limit.(bool)
|