Merge branch 'test' of http://gitlab.fjmaimaimai.com/allied-creation/allied-crea…
…tion-cooperation into test
正在显示
4 个修改的文件
包含
51 行增加
和
16 行删除
| @@ -122,12 +122,17 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop | @@ -122,12 +122,17 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop | ||
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | // 校验:判断用户类型是否属于承接对象 | 124 | // 校验:判断用户类型是否属于承接对象 |
| 125 | + typeExist := false | ||
| 125 | if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, 3) { // 非公开类型校验 | 126 | if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, 3) { // 非公开类型校验 |
| 126 | for _, userType := range cooperationProject.CooperationProjectUndertakerTypes { | 127 | for _, userType := range cooperationProject.CooperationProjectUndertakerTypes { |
| 127 | - if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType&userType) { | ||
| 128 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象") | 128 | + if utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType&userType) { |
| 129 | + typeExist = true | ||
| 129 | } | 130 | } |
| 130 | } | 131 | } |
| 132 | + if !typeExist { | ||
| 133 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象") | ||
| 134 | + | ||
| 135 | + } | ||
| 131 | } | 136 | } |
| 132 | 137 | ||
| 133 | newCooperationApplication = &domain.CooperationApplication{ | 138 | newCooperationApplication = &domain.CooperationApplication{ |
| @@ -184,8 +189,16 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop | @@ -184,8 +189,16 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop | ||
| 184 | } | 189 | } |
| 185 | 190 | ||
| 186 | // 校验:判断用户类型是否属于承接对象 | 191 | // 校验:判断用户类型是否属于承接对象 |
| 187 | - if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType) { | ||
| 188 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象") | 192 | + typeExist := false |
| 193 | + if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, 3) { // 非公开类型校验 | ||
| 194 | + for _, userType := range cooperationProject.CooperationProjectUndertakerTypes { | ||
| 195 | + if utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType&userType) { | ||
| 196 | + typeExist = true | ||
| 197 | + } | ||
| 198 | + } | ||
| 199 | + if !typeExist { | ||
| 200 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象") | ||
| 201 | + } | ||
| 189 | } | 202 | } |
| 190 | 203 | ||
| 191 | newCooperationApplication = &domain.CooperationApplication{ | 204 | newCooperationApplication = &domain.CooperationApplication{ |
| @@ -159,12 +159,16 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | @@ -159,12 +159,16 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC | ||
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | // 校验承接人是否属于承接对象,1员工,2共创用户,4公开 | 161 | // 校验承接人是否属于承接对象,1员工,2共创用户,4公开 |
| 162 | + typeExist := false | ||
| 162 | if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, 3) { | 163 | if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, 3) { |
| 163 | for _, userType := range createCooperationContractCommand.CooperationContractUndertakerTypes { | 164 | for _, userType := range createCooperationContractCommand.CooperationContractUndertakerTypes { |
| 164 | - if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, undertakerDomain.UserType&userType) { | ||
| 165 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象") | 165 | + if utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, undertakerDomain.UserType&userType) { |
| 166 | + typeExist = true | ||
| 166 | } | 167 | } |
| 167 | } | 168 | } |
| 169 | + if !typeExist { | ||
| 170 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象") | ||
| 171 | + } | ||
| 168 | } | 172 | } |
| 169 | 173 | ||
| 170 | // 获取推荐人 | 174 | // 获取推荐人 |
| @@ -1027,12 +1031,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | @@ -1027,12 +1031,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC | ||
| 1027 | } | 1031 | } |
| 1028 | 1032 | ||
| 1029 | // 校验:判断用户类型是否属于承接对象 | 1033 | // 校验:判断用户类型是否属于承接对象 |
| 1034 | + typeExist := false | ||
| 1030 | if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, 3) { // 非公开类型校验 | 1035 | if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, 3) { // 非公开类型校验 |
| 1031 | for _, userType := range cooperationContract.CooperationContractUndertakerTypes { | 1036 | for _, userType := range cooperationContract.CooperationContractUndertakerTypes { |
| 1032 | - if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, undertakerDomain.UserType&userType) { | ||
| 1033 | - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象") | 1037 | + if utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, undertakerDomain.UserType&userType) { |
| 1038 | + typeExist = true | ||
| 1034 | } | 1039 | } |
| 1035 | } | 1040 | } |
| 1041 | + if !typeExist { | ||
| 1042 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象") | ||
| 1043 | + } | ||
| 1036 | } | 1044 | } |
| 1037 | 1045 | ||
| 1038 | // 获取推荐人 | 1046 | // 获取推荐人 |
| @@ -1420,6 +1420,10 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | @@ -1420,6 +1420,10 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | ||
| 1420 | 1420 | ||
| 1421 | // 获取承接人 | 1421 | // 获取承接人 |
| 1422 | for _, undertaker := range cooperationContract.Undertakers { | 1422 | for _, undertaker := range cooperationContract.Undertakers { |
| 1423 | + // 将承接人填入不同分红阶段 | ||
| 1424 | + for i, _ := range stageUndertakerMap { | ||
| 1425 | + stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker) | ||
| 1426 | + } | ||
| 1423 | // 查询承接人分红预算单 | 1427 | // 查询承接人分红预算单 |
| 1424 | if countDividendsEstimates, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{ | 1428 | if countDividendsEstimates, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{ |
| 1425 | "cooperationContractNumber": cooperationContract.CooperationContractNumber, | 1429 | "cooperationContractNumber": cooperationContract.CooperationContractNumber, |
| @@ -1430,17 +1434,27 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | @@ -1430,17 +1434,27 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE | ||
| 1430 | }); err != nil { | 1434 | }); err != nil { |
| 1431 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1435 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
| 1432 | } else { | 1436 | } else { |
| 1433 | - if countDividendsEstimates > 0 { // 已有分红 | 1437 | + log.Logger.Info("获取承接人相关的金额激励预算信息", map[string]interface{}{ |
| 1438 | + "dividendsEstimates": dividendsEstimates, | ||
| 1439 | + }) | ||
| 1440 | + if countDividendsEstimates > 0 { // 已有分红预算 | ||
| 1434 | for _, dividendsEstimate := range dividendsEstimates { | 1441 | for _, dividendsEstimate := range dividendsEstimates { |
| 1435 | - if dividendsEstimate.DividendsAccountStatus == 1 || dividendsEstimate.IsCanceled { // 分红预算单状态为待结算或已取消 | ||
| 1436 | - stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage], undertaker) | 1442 | + if !dividendsEstimate.IsCanceled { // 分红预算单状态为非取消状态 |
| 1443 | + //stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage], undertaker) | ||
| 1444 | + for i, undertakerAppended := range stageUndertakerMap[dividendsEstimate.DividendsStage] { | ||
| 1445 | + if undertakerAppended.UndertakerId == undertaker.UndertakerId { | ||
| 1446 | + // 将删除点前后的元素连接起来 | ||
| 1447 | + stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage][:i], stageUndertakerMap[dividendsEstimate.DividendsStage][i+1:]...) | ||
| 1448 | + } | ||
| 1449 | + } | ||
| 1437 | } | 1450 | } |
| 1438 | } | 1451 | } |
| 1439 | - } else if countDividendsEstimates == 0 { // 未分红,可以加入任意阶段进行金额激励 | ||
| 1440 | - for i, _ := range stageUndertakerMap { | ||
| 1441 | - stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker) | ||
| 1442 | - } | ||
| 1443 | } | 1452 | } |
| 1453 | + //else if countDividendsEstimates == 0 { // 未分红,可以加入任意阶段进行金额激励 | ||
| 1454 | + // for i, _ := range stageUndertakerMap { | ||
| 1455 | + // stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker) | ||
| 1456 | + // } | ||
| 1457 | + //} | ||
| 1444 | } | 1458 | } |
| 1445 | } | 1459 | } |
| 1446 | 1460 |
| @@ -312,7 +312,7 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | @@ -312,7 +312,7 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte | ||
| 312 | query.Where("cooperation_contract_number = ?", cooperationContractNumber) | 312 | query.Where("cooperation_contract_number = ?", cooperationContractNumber) |
| 313 | } | 313 | } |
| 314 | if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 { | 314 | if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 { |
| 315 | - query.Where(`dividends_user @> '{"uid":"?"}'`, dividendsUserId) | 315 | + query.Where(`dividends_user @> '{"userId":"?"}'`, dividendsUserId) |
| 316 | } | 316 | } |
| 317 | if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { | 317 | if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { |
| 318 | query.Where("company->>'companyId' = '?'", companyId) | 318 | query.Where("company->>'companyId' = '?'", companyId) |
-
请 注册 或 登录 后发表评论