cloud-server-account/src/main/java/com/dsh/account/controller/ClassDetailsController.java
@@ -409,14 +409,17 @@ @ApiImplicitParams({ @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), @ApiImplicitParam(value = "学员id", name = "stuId", required = true, dataType = "int"), @ApiImplicitParam(value = "预约状态 0=全部 1=待上课 2=已完成 3=已取消", name = "appointStatus", required = false, dataType = "int"), @ApiImplicitParam(value = "时间类型 0=全部 1=近一周 2=近一个月 3=近一年", name = "appointStatus", required = false, dataType = "int"), @ApiImplicitParam(value = "课程名称", name = "appointStatus", required = false, dataType = "string"), }) public ResultUtil<AppointmentRecordVo> cgeClassAppointmentRecordList(Integer stuId){ public ResultUtil<AppointmentRecordVo> cgeClassAppointmentRecordList(Integer stuId,Integer appointStatus,Integer timeType,String search){ try { Integer appUserId = tokenUtil.getUserIdFormRedis(); if(null == appUserId){ return ResultUtil.tokenErr(); } return ResultUtil.success(istuService.getAppointmentRecords(stuId,appUserId)); return ResultUtil.success(istuService.getAppointmentRecords(stuId,appUserId,appointStatus,timeType,search)); }catch (Exception e){ return ResultUtil.runErr(); } cloud-server-account/src/main/java/com/dsh/account/model/vo/classDetails/AppointmentRecordVo.java
@@ -16,6 +16,9 @@ @ApiModelProperty(value = "当前学员姓名") private String stuName; @ApiModelProperty(value = "预约状态 0=全部 1=待上课 2=已完成 3=已取消") private Integer appointStatus; @ApiModelProperty(value = "记录列表") private List<RecordAppoint> appointList; cloud-server-account/src/main/java/com/dsh/account/service/TStudentService.java
@@ -83,7 +83,7 @@ * @param appUserId * @return */ AppointmentRecordVo getAppointmentRecords(Integer stuId, Integer appUserId); AppointmentRecordVo getAppointmentRecords(Integer stuId, Integer appUserId,Integer appointStatus,Integer timeType,String search); ResultUtil cancelReservationOfCourse( Integer courseStuRecordId); cloud-server-account/src/main/java/com/dsh/account/service/impl/TStudentServiceImpl.java
@@ -563,7 +563,7 @@ } @Override public AppointmentRecordVo getAppointmentRecords(Integer stuId, Integer appUserId) { public AppointmentRecordVo getAppointmentRecords(Integer stuId, Integer appUserId,Integer appointStatus,Integer timeType,String search) { AppointmentRecordVo recordVo = new AppointmentRecordVo(); TStudent tStudent = this.baseMapper.selectOne(new QueryWrapper<TStudent>() .eq("id",stuId ) @@ -571,7 +571,72 @@ if (ToolUtil.isNotEmpty(tStudent)){ recordVo.setStuId(tStudent.getId()); recordVo.setStuName(tStudent.getName()); recordVo.setAppointList(couPayClient.obtainStudentClassDetailsData(stuId)); List<RecordAppoint> recordAppoints = couPayClient.obtainStudentClassDetailsData(stuId); if (ToolUtil.isEmpty(appointStatus)){ recordVo.setAppointStatus(0); }else { recordVo.setAppointStatus(appointStatus); recordAppoints = recordAppoints.stream() .filter(record -> record.getStatus().equals(appointStatus)) .collect(Collectors.toList()); } if (ToolUtil.isNotEmpty(search)){ recordVo.setAppointStatus(appointStatus); recordAppoints = recordAppoints.stream() .filter(record -> record.getCoursePackageName().contains(search)) .collect(Collectors.toList()); } if (ToolUtil.isNotEmpty(timeType)){ Date lastOfDate = DateUtil.getLastOfDate(); switch (timeType){ case 1: Date lastWeekStartDate = DateUtil.getLastWeekStartDate(); recordAppoints = recordAppoints.stream() .filter(record -> { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date time = sdf.parse(record.getTimeFrame().substring(11)); return !time.before(lastWeekStartDate) && !time.after(lastOfDate); } catch (ParseException e) { return false; } }) .collect(Collectors.toList()); break; case 2: Date lastMonthStartDate = DateUtil.getLastMonthStartDate(); recordAppoints = recordAppoints.stream() .filter(record -> { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Date time = sdf.parse(record.getTimeFrame().substring(11)); return !time.before(lastMonthStartDate) && !time.after(lastOfDate); } catch (ParseException e) { return false; } }) .collect(Collectors.toList()); break; case 3: Date lastYearStartDate = DateUtil.getLastYearStartDate(); recordAppoints = recordAppoints.stream() .filter(record -> { try { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); Date time = sdf.parse(record.getTimeFrame().substring(11)); return !time.before(lastYearStartDate) && !time.after(lastOfDate); } catch (ParseException e) { return false; } }) .collect(Collectors.toList()); break; default: break; } } recordVo.setAppointList(recordAppoints); } return recordVo; } cloud-server-account/src/main/java/com/dsh/account/util/DateUtil.java
@@ -368,4 +368,43 @@ return age; } // 获取近一周的开始时间 public static Date getLastWeekStartDate() { Calendar calendar = Calendar.getInstance(); // 设置为当前日期的前一周 calendar.add(Calendar.DAY_OF_YEAR, -7); // 获取近一周的开始时间 return calendar.getTime(); } // 获取近一个月的开始时间 public static Date getLastMonthStartDate() { Calendar calendar = Calendar.getInstance(); // 设置为当前日期的前一个月 calendar.add(Calendar.MONTH, -1); // 获取近一个月的开始时间 return calendar.getTime(); } // 获取近一年的开始时间 public static Date getLastYearStartDate() { Calendar calendar = Calendar.getInstance(); // 设置为当前日期的前一年 calendar.add(Calendar.YEAR, -1); // 获取近一年的开始时间 return calendar.getTime(); } // 获取昨天的时间 public static Date getLastOfDate() { Calendar calendar = Calendar.getInstance(); // 设置为当前日期的前一个月 calendar.add(Calendar.DAY_OF_YEAR, -1); // 获取近一个月的开始时间 return calendar.getTime(); } }