作者 陈志颖

feat:增加金额激励分红预算信息列表返回功能

@@ -8,6 +8,8 @@ import ( @@ -8,6 +8,8 @@ import (
8 type StageAndUndertaker struct { 8 type StageAndUndertaker struct {
9 // 分红阶段 9 // 分红阶段
10 Stage int32 `json:"stage"` 10 Stage int32 `json:"stage"`
  11 + // 共创承接人
  12 + Undertakers []*domain.Undertaker `json:"undertakers"`
11 } 13 }
12 14
13 type MoneyIncentivesEstimateDto struct { 15 type MoneyIncentivesEstimateDto struct {
@@ -18,11 +20,11 @@ type MoneyIncentivesEstimateDto struct { @@ -18,11 +20,11 @@ type MoneyIncentivesEstimateDto struct {
18 // 共创合约名称 20 // 共创合约名称
19 CooperationContractName string `json:"cooperationContractName"` 21 CooperationContractName string `json:"cooperationContractName"`
20 // 共创模式或者合伙模式 22 // 共创模式或者合伙模式
21 - CooperationMode *domain.CooperationMode `json:"cooperationMode"` 23 + CooperationModeName string `json:"cooperationMode"`
22 // 共创合约发起部门 24 // 共创合约发起部门
23 Department *domain.Department `json:"department"` 25 Department *domain.Department `json:"department"`
24 // 共创合约发起人 26 // 共创合约发起人
25 - CooperationContractSponsor *domain.User `json:"cooperationContractSponsor"` 27 + CooperationContractSponsorName string `json:"cooperationContractSponsor"`
26 // 创建合约时间 28 // 创建合约时间
27 CreatedAt time.Time `json:"createdAt"` 29 CreatedAt time.Time `json:"createdAt"`
28 // 阶段和承接人 30 // 阶段和承接人
@@ -31,5 +33,15 @@ type MoneyIncentivesEstimateDto struct { @@ -31,5 +33,15 @@ type MoneyIncentivesEstimateDto struct {
31 33
32 func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContract) error { 34 func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContract) error {
33 dto.CooperationContractId = contract.CooperationContractId 35 dto.CooperationContractId = contract.CooperationContractId
  36 + dto.CooperationContractNumber = contract.CooperationContractNumber
  37 + dto.CooperationContractName = contract.CooperationContractName
  38 + dto.CooperationModeName = contract.CooperationMode.CooperationModeName
  39 + dto.Department = contract.Department
  40 + dto.CooperationContractSponsorName = contract.CooperationContractSponsor.UserName
  41 + dto.CreatedAt = contract.CreatedAt
  42 + dto.StageAndUndertaker = &StageAndUndertaker{
  43 + Stage: 0,
  44 + Undertakers: []*domain.Undertaker{},
  45 + }
34 return nil 46 return nil
35 } 47 }
@@ -120,10 +120,37 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentivesEst @@ -120,10 +120,37 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentivesEst
120 defer func() { 120 defer func() {
121 _ = transactionContext.RollbackTransaction() 121 _ = transactionContext.RollbackTransaction()
122 }() 122 }()
123 - if err := transactionContext.CommitTransaction(); err != nil {  
124 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 123 + // 共创合约仓储初始化
  124 + var cooperationContractRepository domain.CooperationContractRepository
  125 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  126 + "transactionContext": transactionContext,
  127 + }); err != nil {
  128 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  129 + } else {
  130 + cooperationContractRepository = value
  131 + }
  132 + // 查找共创合约
  133 + if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(listMoneyIncentivesEstimateQuery)); err != nil {
  134 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  135 + } else {
  136 + var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
  137 + for _, cooperationContract := range cooperationContracts {
  138 + moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
  139 + if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract); err != nil {
  140 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  141 + }
  142 + moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
  143 + }
  144 + if err := transactionContext.CommitTransaction(); err != nil {
  145 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  146 + }
  147 + return map[string]interface{}{
  148 + "grid": map[string]interface{}{
  149 + "total": count,
  150 + "list": moneyIncentivesEstimateDtos,
  151 + },
  152 + }, nil
125 } 153 }
126 - return nil, nil  
127 } 154 }
128 155
129 // CancelDividendsEstimate 取消分红预算单 156 // CancelDividendsEstimate 取消分红预算单
@@ -834,6 +834,12 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in @@ -834,6 +834,12 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
834 if cooperationContractIds, ok := queryOptions["cooperationContractIds"]; ok && len(cooperationContractIds.([]int64)) != 0 { 834 if cooperationContractIds, ok := queryOptions["cooperationContractIds"]; ok && len(cooperationContractIds.([]int64)) != 0 {
835 query.Where("cooperation_contract_id in (?)", pg.In(cooperationContractIds)) 835 query.Where("cooperation_contract_id in (?)", pg.In(cooperationContractIds))
836 } 836 }
  837 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  838 + query.Where("company->>'companyId' = '?'", companyId)
  839 + }
  840 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  841 + query.Where("org->>'orgId' = '?'", orgId)
  842 + }
837 offsetLimitFlag := true 843 offsetLimitFlag := true
838 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 844 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
839 offsetLimitFlag = offsetLimit.(bool) 845 offsetLimitFlag = offsetLimit.(bool)