...
|
...
|
@@ -1380,6 +1380,8 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE |
|
|
|
|
|
// 查找共创合约
|
|
|
searchMoneyIncentivesEstimateQuery.IncentivesType = 2
|
|
|
searchMoneyIncentivesEstimateQuery.Status = 1
|
|
|
searchMoneyIncentivesEstimateQuery.OffsetLimit = false
|
|
|
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchMoneyIncentivesEstimateQuery)); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
@@ -1387,15 +1389,19 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE |
|
|
for _, cooperationContract := range cooperationContracts {
|
|
|
// 阶段承接人map
|
|
|
stageUndertakerMap := make(map[int32][]*domain.Undertaker)
|
|
|
|
|
|
// 阶段承接人列表
|
|
|
stageAndUndertaker := make([]*dto.StageAndUndertaker, 0)
|
|
|
|
|
|
// 初始化阶段承接人map
|
|
|
for _, rule := range cooperationContract.MoneyIncentivesRules {
|
|
|
stageUndertakerMap[rule.MoneyIncentivesStage] = make([]*domain.Undertaker, 0)
|
|
|
}
|
|
|
|
|
|
log.Logger.Info("阶段承接人map初始化", map[string]interface{}{
|
|
|
"stageUndertakerMap": stageUndertakerMap,
|
|
|
})
|
|
|
|
|
|
// 获取承接人
|
|
|
for _, undertaker := range cooperationContract.Undertakers {
|
|
|
// 查询承接人分红预算单
|
...
|
...
|
@@ -1404,6 +1410,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE |
|
|
"companyId": cooperationContract.Company.CompanyId,
|
|
|
"orgId": cooperationContract.Org.OrgId,
|
|
|
"dividendsUserId": undertaker.UserId,
|
|
|
"offsetLimit": false,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
...
|
...
|
@@ -1413,16 +1420,20 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE |
|
|
stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage], undertaker)
|
|
|
}
|
|
|
}
|
|
|
break
|
|
|
} else if countDividendsEstimates == 0 { // 未分红,可以加入任意阶段进行金额激励
|
|
|
for i, _ := range stageUndertakerMap {
|
|
|
stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker)
|
|
|
}
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
log.Logger.Info("阶段承接人map", map[string]interface{}{
|
|
|
"stageUndertakerMap": stageUndertakerMap,
|
|
|
})
|
|
|
|
|
|
for k, v := range stageUndertakerMap {
|
|
|
stageAndUndertaker = append(stageAndUndertaker, &dto.StageAndUndertaker{
|
|
|
Stage: k,
|
...
|
...
|
@@ -1431,10 +1442,22 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE |
|
|
}
|
|
|
|
|
|
moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
|
|
|
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
|
|
|
// 判断当前合约的承接人是否全部分红
|
|
|
allEstimate := true
|
|
|
for i, _ := range stageUndertakerMap {
|
|
|
if len(stageUndertakerMap[i]) > 0 {
|
|
|
allEstimate = false
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if !allEstimate {
|
|
|
if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract, stageAndUndertaker); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
}
|
|
|
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
|
|
|
}
|
|
|
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
...
|
...
|
|