作者 陈志颖

fix:阶段承接人数据重复问题

... ... @@ -1372,12 +1372,6 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
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 {
... ... @@ -1385,9 +1379,18 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
} else {
var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
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 {
// 查询承接人分红预算单
if countDividendsEstimates, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
... ... @@ -1398,7 +1401,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if countDividendsEstimates > 0 {
if countDividendsEstimates > 0 { // 已有分红
for _, dividendsEstimate := range dividendsEstimates {
if dividendsEstimate.DividendsAccountStatus == 1 || dividendsEstimate.IsCanceled { // 分红预算单状态为待结算或已取消
stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage], undertaker)
... ... @@ -1411,7 +1414,9 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
}
}
}
log.Logger.Info("阶段承接人map", map[string]interface{}{
"stageUndertakerMap": stageUndertakerMap,
})
for k, v := range stageUndertakerMap {
stageAndUndertaker = append(stageAndUndertaker, &dto.StageAndUndertaker{
Stage: k,
... ... @@ -1425,6 +1430,7 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
}
moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ...
... ... @@ -89,7 +89,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
"cooperationProjectNumber": cooperationContract.CooperationProjectNumber,
"companyId": cooperationContract.Company.CompanyId,
"orgId": cooperationContract.Org.OrgId,
"notPause": true,
//"notPause": true,
})
if err != nil {
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
... ...