作者 陈志颖

fix:修复同一个用户多次申请同一个项目

@@ -113,7 +113,9 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -113,7 +113,9 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
113 // 校验:同一个用户,不能多次申请同一个项目 113 // 校验:同一个用户,不能多次申请同一个项目
114 applicationExist, _ := cooperationApplicationDao.CheckApplicationExist(map[string]interface{}{ 114 applicationExist, _ := cooperationApplicationDao.CheckApplicationExist(map[string]interface{}{
115 "visitorUserBaseId": applicant.UserBaseId, 115 "visitorUserBaseId": applicant.UserBaseId,
116 - "cooperationApplicationId": cooperationProject.CooperationProjectId, 116 + "companyId": cooperationProject.Company.CompanyId,
  117 + "orgId": cooperationProject.Org.OrgId,
  118 + "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
117 }) 119 })
118 if applicationExist { 120 if applicationExist {
119 return nil, application.ThrowError(application.TRANSACTION_ERROR, "抱歉,您已经申请过该项目") 121 return nil, application.ThrowError(application.TRANSACTION_ERROR, "抱歉,您已经申请过该项目")
@@ -173,7 +175,7 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -173,7 +175,7 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
173 "companyId": applyForCooperationCommand.CompanyId, 175 "companyId": applyForCooperationCommand.CompanyId,
174 "orgId": applyForCooperationCommand.OrgId, 176 "orgId": applyForCooperationCommand.OrgId,
175 "applicantId": applicant.UserId, 177 "applicantId": applicant.UserId,
176 - "cooperationApplicationId": cooperationProject.CooperationProjectId, 178 + "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
177 }) 179 })
178 if applicationExist { 180 if applicationExist {
179 return nil, application.ThrowError(application.TRANSACTION_ERROR, "抱歉,您已经申请过该项目") 181 return nil, application.ThrowError(application.TRANSACTION_ERROR, "抱歉,您已经申请过该项目")
@@ -15,8 +15,8 @@ func (dao *CooperationApplicationDao) CheckApplicationExist(queryOptions map[str @@ -15,8 +15,8 @@ func (dao *CooperationApplicationDao) CheckApplicationExist(queryOptions map[str
15 tx := dao.transactionContext.PgTx 15 tx := dao.transactionContext.PgTx
16 var cooperationApplicationModels []*models.CooperationApplication 16 var cooperationApplicationModels []*models.CooperationApplication
17 query := tx.Model(&cooperationApplicationModels) 17 query := tx.Model(&cooperationApplicationModels)
18 - if cooperationApplicationId, ok := queryOptions["cooperationApplicationId"]; ok && cooperationApplicationId != "" {  
19 - query = query.Where("cooperation_application_id = ?", cooperationApplicationId) 18 + if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
  19 + query = query.Where("cooperation_project_number = ?", cooperationProjectNumber)
20 } 20 }
21 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { 21 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
22 query = query.Where(`cooperation_application.company @> '{"companyId":"?"}'`, companyId) 22 query = query.Where(`cooperation_application.company @> '{"companyId":"?"}'`, companyId)
@@ -239,7 +239,7 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string @@ -239,7 +239,7 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
239 if applicantName, ok := queryOptions["applicantName"]; ok && applicantName != "" { 239 if applicantName, ok := queryOptions["applicantName"]; ok && applicantName != "" {
240 query.Where(`(cooperation_application.cooperation_application_applicant->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", applicantName)) 240 query.Where(`(cooperation_application.cooperation_application_applicant->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", applicantName))
241 } 241 }
242 - if cooperationApplicationStatus, ok := queryOptions["cooperationApplicationStatus"]; ok && cooperationApplicationStatus.(int32) != 0 { 242 + if cooperationApplicationStatus, ok := queryOptions["cooperationApplicationStatus"]; ok && cooperationApplicationStatus.(int) != 0 {
243 query.Where("cooperation_application_status = ?", cooperationApplicationStatus) 243 query.Where("cooperation_application_status = ?", cooperationApplicationStatus)
244 } 244 }
245 if cooperationApplicationIds, ok := queryOptions["cooperationApplicationIds"]; ok && len(cooperationApplicationIds.([]int64)) > 0 { 245 if cooperationApplicationIds, ok := queryOptions["cooperationApplicationIds"]; ok && len(cooperationApplicationIds.([]int64)) > 0 {