作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !29
... ... @@ -122,12 +122,17 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
}
// 校验:判断用户类型是否属于承接对象
typeExist := false
if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, 3) { // 非公开类型校验
for _, userType := range cooperationProject.CooperationProjectUndertakerTypes {
if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType&userType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
if utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType&userType) {
typeExist = true
}
}
if !typeExist {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
}
}
newCooperationApplication = &domain.CooperationApplication{
... ... @@ -184,8 +189,16 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
}
// 校验:判断用户类型是否属于承接对象
if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
typeExist := false
if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, 3) { // 非公开类型校验
for _, userType := range cooperationProject.CooperationProjectUndertakerTypes {
if utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType&userType) {
typeExist = true
}
}
if !typeExist {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
}
}
newCooperationApplication = &domain.CooperationApplication{
... ...
... ... @@ -159,12 +159,16 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
}
// 校验承接人是否属于承接对象,1员工,2共创用户,4公开
typeExist := false
if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, 3) {
for _, userType := range createCooperationContractCommand.CooperationContractUndertakerTypes {
if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, undertakerDomain.UserType&userType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象")
if utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, undertakerDomain.UserType&userType) {
typeExist = true
}
}
if !typeExist {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象")
}
}
// 获取推荐人
... ... @@ -1027,12 +1031,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
}
// 校验:判断用户类型是否属于承接对象
typeExist := false
if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, 3) { // 非公开类型校验
for _, userType := range cooperationContract.CooperationContractUndertakerTypes {
if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, undertakerDomain.UserType&userType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象")
if utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, undertakerDomain.UserType&userType) {
typeExist = true
}
}
if !typeExist {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象")
}
}
// 获取推荐人
... ...
... ... @@ -1420,6 +1420,10 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
// 获取承接人
for _, undertaker := range cooperationContract.Undertakers {
// 将承接人填入不同分红阶段
for i, _ := range stageUndertakerMap {
stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker)
}
// 查询承接人分红预算单
if countDividendsEstimates, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
"cooperationContractNumber": cooperationContract.CooperationContractNumber,
... ... @@ -1430,17 +1434,27 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if countDividendsEstimates > 0 { // 已有分红
log.Logger.Info("获取承接人相关的金额激励预算信息", map[string]interface{}{
"dividendsEstimates": dividendsEstimates,
})
if countDividendsEstimates > 0 { // 已有分红预算
for _, dividendsEstimate := range dividendsEstimates {
if dividendsEstimate.DividendsAccountStatus == 1 || dividendsEstimate.IsCanceled { // 分红预算单状态为待结算或已取消
stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage], undertaker)
if !dividendsEstimate.IsCanceled { // 分红预算单状态为非取消状态
//stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage], undertaker)
for i, undertakerAppended := range stageUndertakerMap[dividendsEstimate.DividendsStage] {
if undertakerAppended.UndertakerId == undertaker.UndertakerId {
// 将删除点前后的元素连接起来
stageUndertakerMap[dividendsEstimate.DividendsStage] = append(stageUndertakerMap[dividendsEstimate.DividendsStage][:i], stageUndertakerMap[dividendsEstimate.DividendsStage][i+1:]...)
}
}
}
}
} else if countDividendsEstimates == 0 { // 未分红,可以加入任意阶段进行金额激励
for i, _ := range stageUndertakerMap {
stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker)
}
}
//else if countDividendsEstimates == 0 { // 未分红,可以加入任意阶段进行金额激励
// for i, _ := range stageUndertakerMap {
// stageUndertakerMap[i] = append(stageUndertakerMap[i], undertaker)
// }
//}
}
}
... ...
... ... @@ -312,7 +312,7 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
query.Where("cooperation_contract_number = ?", cooperationContractNumber)
}
if dividendsUserId, ok := queryOptions["dividendsUserId"]; ok && dividendsUserId.(int64) != 0 {
query.Where(`dividends_user @> '{"uid":"?"}'`, dividendsUserId)
query.Where(`dividends_user @> '{"userId":"?"}'`, dividendsUserId)
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
... ...