作者 陈志颖

feat:增加金额激励信息阶段和承接人

... ... @@ -1364,9 +1364,22 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
cooperationContractRepository = value
}
// TODO 阶段承接人列表
// 分红预算仓储初始化
var dividendsEstimateRepository domain.DividendsEstimateRepository
if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsEstimateRepository = value
}
// 阶段承接人列表
stageAndUndertaker := make([]*dto.StageAndUndertaker, 0)
// 阶段承接人map
stageUndertakerMap := make(map[int32][]*domain.Undertaker)
// 查找共创合约
searchMoneyIncentivesEstimateQuery.IncentivesType = 2
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchMoneyIncentivesEstimateQuery)); err != nil {
... ... @@ -1374,10 +1387,39 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
} else {
var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
for _, cooperationContract := range cooperationContracts {
// TODO 判断承接人是否已分红
//for _, undertaker := range cooperationContract.Undertakers {
//
//}
for _, rule := range cooperationContract.MoneyIncentivesRules {
stageUndertakerMap[rule.MoneyIncentivesStage] = make([]*domain.Undertaker, 0)
}
for _, undertaker := range cooperationContract.Undertakers {
// 查询承接人分红预算单
if countDividendsEstimates, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
"cooperationContractNumber": cooperationContract.CooperationContractNumber,
"companyId": cooperationContract.Company.CompanyId,
"orgId": cooperationContract.Org.OrgId,
"dividendsUserId": undertaker.UserId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if countDividendsEstimates > 0 {
for _, dividendsEstimate := range dividendsEstimates {
if dividendsEstimate.DividendsAccountStatus == 1 || dividendsEstimate.IsCanceled { // 分红预算单状态为待结算或已取消
stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage], undertaker)
}
}
} else if countDividendsEstimates == 0 { // 未分红,可以加入任意阶段进行金额激励
for i, _ := range stageUndertakerMap {
stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker)
}
}
}
}
for k, v := range stageUndertakerMap {
stageAndUndertaker = append(stageAndUndertaker, &dto.StageAndUndertaker{
Stage: k,
Undertakers: v,
})
}
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil {
... ...
... ... @@ -308,6 +308,9 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
query.Where("cooperation_contract_number in (?)", pg.In(v))
}
if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 {
query.Where(`dividends_user @> '{"uid":"?"}'`, dividendsUserId)
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
... ...