正在显示
3 个修改的文件
包含
37 行增加
和
6 行删除
@@ -688,7 +688,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -688,7 +688,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
688 | // 更新合约相关人 | 688 | // 更新合约相关人 |
689 | cooperationContract.RelevantPeople = relevantPeople | 689 | cooperationContract.RelevantPeople = relevantPeople |
690 | 690 | ||
691 | - //TODO 获取承接人 | 691 | + // 获取承接人 |
692 | var undertakers []*domain.Undertaker | 692 | var undertakers []*domain.Undertaker |
693 | for _, undertaker := range updateCooperationContractCommand.Undertakers { | 693 | for _, undertaker := range updateCooperationContractCommand.Undertakers { |
694 | var undertakerDomain *domain.Undertaker | 694 | var undertakerDomain *domain.Undertaker |
@@ -735,10 +735,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -735,10 +735,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
735 | ContractAttachment: nil, | 735 | ContractAttachment: nil, |
736 | }) | 736 | }) |
737 | } | 737 | } |
738 | - //TODO 更新承接人 | 738 | + // 更新承接人 |
739 | cooperationContract.Undertakers = undertakers | 739 | cooperationContract.Undertakers = undertakers |
740 | 740 | ||
741 | - //TODO 获取分红规则列表 | 741 | + // 获取分红规则列表 |
742 | var dividendsIncentivesRules []*domain.DividendsIncentivesRule | 742 | var dividendsIncentivesRules []*domain.DividendsIncentivesRule |
743 | for _, dividendsIncentivesRule := range updateCooperationContractCommand.DividendsIncentivesRules { | 743 | for _, dividendsIncentivesRule := range updateCooperationContractCommand.DividendsIncentivesRules { |
744 | dividendsIncentivesRuleId, _ := strconv.ParseInt(dividendsIncentivesRule.DividendsIncentivesRuleId, 10, 64) | 744 | dividendsIncentivesRuleId, _ := strconv.ParseInt(dividendsIncentivesRule.DividendsIncentivesRuleId, 10, 64) |
@@ -758,10 +758,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -758,10 +758,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
758 | CreatedAt: time.Now(), | 758 | CreatedAt: time.Now(), |
759 | }) | 759 | }) |
760 | } | 760 | } |
761 | - //TODO 更新分红规则列表 | 761 | + // 更新分红规则列表 |
762 | cooperationContract.DividendsIncentivesRules = dividendsIncentivesRules | 762 | cooperationContract.DividendsIncentivesRules = dividendsIncentivesRules |
763 | 763 | ||
764 | - //TODO 获取金额激励规则列表 | 764 | + // 获取金额激励规则列表 |
765 | var moneyIncentivesRules []*domain.MoneyIncentivesRule | 765 | var moneyIncentivesRules []*domain.MoneyIncentivesRule |
766 | for _, moneyIncentivesRule := range updateCooperationContractCommand.MoneyIncentivesRules { | 766 | for _, moneyIncentivesRule := range updateCooperationContractCommand.MoneyIncentivesRules { |
767 | moneyIncentivesRuleId, _ := strconv.ParseInt(moneyIncentivesRule.MoneyIncentivesRuleId, 10, 64) | 767 | moneyIncentivesRuleId, _ := strconv.ParseInt(moneyIncentivesRule.MoneyIncentivesRuleId, 10, 64) |
@@ -782,7 +782,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -782,7 +782,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
782 | CreatedAt: time.Now(), | 782 | CreatedAt: time.Now(), |
783 | }) | 783 | }) |
784 | } | 784 | } |
785 | - //TODO 更新金额激励规则列表 | 785 | + // 更新金额激励规则列表 |
786 | cooperationContract.MoneyIncentivesRules = moneyIncentivesRules | 786 | cooperationContract.MoneyIncentivesRules = moneyIncentivesRules |
787 | 787 | ||
788 | if cooperationContract, err := cooperationContractRepository.Save(cooperationContract); err != nil { | 788 | if cooperationContract, err := cooperationContractRepository.Save(cooperationContract); err != nil { |
@@ -50,6 +50,7 @@ type CooperationContract struct { | @@ -50,6 +50,7 @@ type CooperationContract struct { | ||
50 | 50 | ||
51 | type CooperationContractRepository interface { | 51 | type CooperationContractRepository interface { |
52 | Save(cooperationContract *CooperationContract) (*CooperationContract, error) | 52 | Save(cooperationContract *CooperationContract) (*CooperationContract, error) |
53 | + UpdateMany(cooperationContract []*CooperationContract) ([]*CooperationContract, error) | ||
53 | Remove(cooperationContract *CooperationContract) (*CooperationContract, error) | 54 | Remove(cooperationContract *CooperationContract) (*CooperationContract, error) |
54 | FindOne(queryOptions map[string]interface{}) (*CooperationContract, error) | 55 | FindOne(queryOptions map[string]interface{}) (*CooperationContract, error) |
55 | Find(queryOptions map[string]interface{}) (int64, []*CooperationContract, error) | 56 | Find(queryOptions map[string]interface{}) (int64, []*CooperationContract, error) |
@@ -591,6 +591,36 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | @@ -591,6 +591,36 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai | ||
591 | return cooperationContract, nil | 591 | return cooperationContract, nil |
592 | } | 592 | } |
593 | 593 | ||
594 | +func (repository *CooperationContractRepository) UpdateMany(cooperationContracts []*domain.CooperationContract) ([]*domain.CooperationContract, error) { | ||
595 | + tx := repository.transactionContext.PgTx | ||
596 | + var cooperationContractModels []*models.CooperationContract | ||
597 | + cooperationContractQuery := tx.Model(&cooperationContractModels) | ||
598 | + for _, cooperationContract := range cooperationContracts { | ||
599 | + cooperationContractModels = append(cooperationContractModels, &models.CooperationContract{ | ||
600 | + CooperationContractId: cooperationContract.CooperationContractId, | ||
601 | + CooperationContractDescription: cooperationContract.CooperationContractDescription, | ||
602 | + CooperationContractName: cooperationContract.CooperationContractName, | ||
603 | + CooperationContractNumber: cooperationContract.CooperationContractNumber, | ||
604 | + CooperationProjectNumber: cooperationContract.CooperationProjectNumber, | ||
605 | + CooperationContractUndertakerTypes: cooperationContract.CooperationContractUndertakerTypes, | ||
606 | + CooperationContractSponsor: cooperationContract.CooperationContractSponsor, | ||
607 | + CooperationModeNumber: cooperationContract.CooperationMode.CooperationModeNumber, | ||
608 | + Status: cooperationContract.Status, | ||
609 | + Org: cooperationContract.Org, | ||
610 | + Company: cooperationContract.Company, | ||
611 | + Operator: cooperationContract.Operator, | ||
612 | + OperateTime: cooperationContract.OperateTime, | ||
613 | + CreatedAt: cooperationContract.CreatedAt, | ||
614 | + DeletedAt: cooperationContract.DeletedAt, | ||
615 | + UpdatedAt: time.Now(), | ||
616 | + }) | ||
617 | + } | ||
618 | + if _, err := tx.Model(&cooperationContractQuery).WherePK().Update(); err != nil { | ||
619 | + return nil, err | ||
620 | + } | ||
621 | + return cooperationContracts, nil | ||
622 | +} | ||
623 | + | ||
594 | func (repository *CooperationContractRepository) Remove(cooperationContract *domain.CooperationContract) (*domain.CooperationContract, error) { | 624 | func (repository *CooperationContractRepository) Remove(cooperationContract *domain.CooperationContract) (*domain.CooperationContract, error) { |
595 | tx := repository.transactionContext.PgTx | 625 | tx := repository.transactionContext.PgTx |
596 | cooperationContractModel := new(models.CooperationContract) | 626 | cooperationContractModel := new(models.CooperationContract) |
-
请 注册 或 登录 后发表评论