Commit fd10edb8b1ca7a3ee09c1e8c024cd5bf4df8b710

Authored by liquanyu
1 parent 972aae24de

孕妇学校

Showing 1 changed file with 35 additions and 0 deletions

platform-operate-api/src/main/java/com/lyms/platform/operate/web/facade/PatientCourseFacade.java View file @ fd10edb
... ... @@ -251,6 +251,29 @@
251 251 }
252 252 }
253 253  
  254 + PatientCourseQuery patientCourseQuery = new PatientCourseQuery();
  255 + patientCourseQuery.setCourseId(courseId);
  256 + patientCourseQuery.setYn(YnEnums.YES.getId());
  257 + patientCourseQuery.setPatientId(patientId);
  258 + List<PatientCourseModel> patientCourseModels = patientCourseService.queryPatientCourseList(patientCourseQuery);
  259 +
  260 + if (CollectionUtils.isNotEmpty(patientCourseModels))
  261 + {
  262 + PatientCourseModel model = patientCourseModels.get(0);
  263 + if (model.getStatus() != null && model.getStatus() == 1)
  264 + {
  265 + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXPIRE);
  266 + objectResponse.setErrormsg("您已经预约该课程了!");
  267 + return objectResponse;
  268 + }
  269 + else if (model.getStatus() != null && model.getStatus() == 2)
  270 + {
  271 + objectResponse.setErrorcode(ErrorCodeConstants.DATA_EXPIRE);
  272 + objectResponse.setErrormsg("您已经签到该课程了!");
  273 + return objectResponse;
  274 + }
  275 + }
  276 +
254 277 Patients patients = patientsService.findOnePatientById(patientId);
255 278 if (patients != null)
256 279 {
... ... @@ -521,6 +544,18 @@
521 544 {
522 545 String id = patientCourseModels.get(0).getId();
523 546 patientCourseService.deletePatientCourse(id);
  547 +
  548 + CourseQuery query = new CourseQuery();
  549 + query.setYn(YnEnums.YES.getId());
  550 + query.setId(courseId);
  551 + List<CourseModel> courseModels = courseService.queryCourseList(query);
  552 + if (CollectionUtils.isNotEmpty(courseModels))
  553 + {
  554 + CourseModel courseModel = new CourseModel();
  555 + courseModel.setId(courseId);
  556 + courseModel.setEnrolmentNum(courseModels.get(0).getEnrolmentNum() == null ? 0 : courseModels.get(0).getEnrolmentNum() - 1);
  557 + courseService.updateCourse(courseModel);
  558 + }
524 559 }
525 560 BaseResponse objectResponse = new BaseResponse();
526 561 objectResponse.setErrorcode(ErrorCodeConstants.SUCCESS);