作者 陈志颖

fix:承接对象判断

@@ -123,11 +123,12 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -123,11 +123,12 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
123 123
124 // 校验:判断用户类型是否属于承接对象 124 // 校验:判断用户类型是否属于承接对象
125 if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, 3) { // 非公开类型校验 125 if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, 3) { // 非公开类型校验
126 - userType := applicant.UserType ^ 1024  
127 - if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, userType) { 126 + for _, userType := range cooperationProject.CooperationProjectUndertakerTypes {
  127 + if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType&userType) {
128 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象") 128 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
129 } 129 }
130 } 130 }
  131 + }
131 132
132 newCooperationApplication = &domain.CooperationApplication{ 133 newCooperationApplication = &domain.CooperationApplication{
133 CooperationApplicationApplicant: applicant, 134 CooperationApplicationApplicant: applicant,
@@ -160,11 +160,12 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -160,11 +160,12 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
160 160
161 // 校验承接人是否属于承接对象,1员工,2共创用户,4公开 161 // 校验承接人是否属于承接对象,1员工,2共创用户,4公开
162 if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, 3) { 162 if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, 3) {
163 - userType := undertakerDomain.UserType ^ 1024  
164 - if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, userType) { 163 + 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 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象")
166 } 166 }
167 } 167 }
  168 + }
168 169
169 // 获取推荐人 170 // 获取推荐人
170 var referrerDomain *domain.Referrer 171 var referrerDomain *domain.Referrer
@@ -1024,9 +1025,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1024,9 +1025,10 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1024 1025
1025 // 校验:判断用户类型是否属于承接对象 1026 // 校验:判断用户类型是否属于承接对象
1026 if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, 3) { // 非公开类型校验 1027 if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, 3) { // 非公开类型校验
1027 - userType := undertakerDomain.UserType ^ 1024  
1028 - if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, userType) {  
1029 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象") 1028 + for _, userType := range cooperationContract.CooperationContractUndertakerTypes {
  1029 + if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, undertakerDomain.UserType&userType) {
  1030 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象")
  1031 + }
1030 } 1032 }
1031 } 1033 }
1032 1034