作者 陈志颖

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

... ... @@ -8,6 +8,8 @@ import (
type StageAndUndertaker struct {
// 分红阶段
Stage int32 `json:"stage"`
// 共创承接人
Undertakers []*domain.Undertaker `json:"undertakers"`
}
type MoneyIncentivesEstimateDto struct {
... ... @@ -18,11 +20,11 @@ type MoneyIncentivesEstimateDto struct {
// 共创合约名称
CooperationContractName string `json:"cooperationContractName"`
// 共创模式或者合伙模式
CooperationMode *domain.CooperationMode `json:"cooperationMode"`
CooperationModeName string `json:"cooperationMode"`
// 共创合约发起部门
Department *domain.Department `json:"department"`
// 共创合约发起人
CooperationContractSponsor *domain.User `json:"cooperationContractSponsor"`
CooperationContractSponsorName string `json:"cooperationContractSponsor"`
// 创建合约时间
CreatedAt time.Time `json:"createdAt"`
// 阶段和承接人
... ... @@ -31,5 +33,15 @@ type MoneyIncentivesEstimateDto struct {
func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContract) error {
dto.CooperationContractId = contract.CooperationContractId
dto.CooperationContractNumber = contract.CooperationContractNumber
dto.CooperationContractName = contract.CooperationContractName
dto.CooperationModeName = contract.CooperationMode.CooperationModeName
dto.Department = contract.Department
dto.CooperationContractSponsorName = contract.CooperationContractSponsor.UserName
dto.CreatedAt = contract.CreatedAt
dto.StageAndUndertaker = &StageAndUndertaker{
Stage: 0,
Undertakers: []*domain.Undertaker{},
}
return nil
}
... ...
... ... @@ -120,10 +120,37 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentivesEst
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 共创合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractRepository = value
}
// 查找共创合约
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(listMoneyIncentivesEstimateQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
for _, cooperationContract := range cooperationContracts {
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
return map[string]interface{}{
"grid": map[string]interface{}{
"total": count,
"list": moneyIncentivesEstimateDtos,
},
}, nil
}
}
// CancelDividendsEstimate 取消分红预算单
... ...
... ... @@ -834,6 +834,12 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
if cooperationContractIds, ok := queryOptions["cooperationContractIds"]; ok && len(cooperationContractIds.([]int64)) != 0 {
query.Where("cooperation_contract_id in (?)", pg.In(cooperationContractIds))
}
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)
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
... ...