From ab17f44cc4aa2b15c36d6f523fa3844a338101ce Mon Sep 17 00:00:00 2001 From: 44323 <443237572@qq.com> Date: 星期二, 24 十月 2023 21:31:52 +0800 Subject: [PATCH] Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/PlayPai --- cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java | 445 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 410 insertions(+), 35 deletions(-) diff --git a/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java b/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java index 7a7b39a..1dd80f7 100644 --- a/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java +++ b/cloud-server-course/src/main/java/com/dsh/course/controller/CoursePackagePaymentController.java @@ -54,8 +54,11 @@ import java.math.BigDecimal; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.Instant; import java.time.LocalDateTime; import java.time.LocalTime; +import java.time.ZoneId; +import java.time.temporal.ChronoUnit; import java.util.*; import java.util.stream.Collectors; @@ -142,7 +145,7 @@ Integer studentId = packagePayment.getStudentId(); // 添加学员上课记录 CoursePackageStudent coursePackageStudent = new CoursePackageStudent(); - TCoursePackagePayment one = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", packagePayment) + TCoursePackagePayment one = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>().eq("studentId", packagePayment.getStudentId()) .orderByDesc("insertTime") .last("LIMIT 1")); @@ -433,8 +436,10 @@ resp.setTotalCourseNums(tCoursePackagePayment.getTotalClassHours()); resp.setResidueNums(tCoursePackagePayment.getLaveClassHours()); resp.setDeductionNums(tCoursePackagePayment.getTotalClassHours()-tCoursePackagePayment.getLaveClassHours()); + if (tCoursePackage.getValidDays()!=null){ String afterDayDate = DateUtil.getAfterDayDate2(tCoursePackage.getInsertTime(),tCoursePackage.getValidDays() + ""); resp.setPeriodOfValidity(afterDayDate); + } resps.add(resp); } } @@ -755,17 +760,43 @@ if(null == appUserId){ return ResultUtil.tokenErr(); } - List<Integer> courseIds = new ArrayList<>(); - QueryWrapper<TCoursePackagePayment> queryWrapper = new QueryWrapper<TCoursePackagePayment>().eq("appUserId", appUserId) - .groupBy("coursePackageId"); +// +// List<Integer> courseIds = new ArrayList<>(); +// QueryWrapper<TCoursePackagePayment> queryWrapper = new QueryWrapper<TCoursePackagePayment>().eq("appUserId", appUserId) +// .groupBy("coursePackageId"); +// if (ToolUtil.isNotEmpty(search.getCourseTypeId())){ +// queryWrapper.eq("coursePackageId",search.getCourseTypeId()); +// } +// List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.list(queryWrapper); +// if (tCoursePackagePayments.size() > 0 ){ +// courseIds = tCoursePackagePayments.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList()); +// } + + + QueryWrapper<CoursePackageStudent> queryWrapper1 = new QueryWrapper<CoursePackageStudent>().eq("appUserId", appUserId); if (ToolUtil.isNotEmpty(search.getCourseTypeId())){ - queryWrapper.eq("coursePackageId",search.getCourseTypeId()); + queryWrapper1.eq("coursePackageId",search.getCourseTypeId()); } - List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.list(queryWrapper); - if (tCoursePackagePayments.size() > 0 ){ - courseIds = tCoursePackagePayments.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList()); + + List<CoursePackageStudent> list = coursePackageStudentService.list(queryWrapper1); + List<Long> longs = new ArrayList<>(); + for (CoursePackageStudent coursePackageStudent : list) { + longs.add(coursePackageStudent.getCoursePackageSchedulingId()); } - return ResultUtil.success(packagePaymentService.queryAfterVideo(search,courseIds)); + + System.out.println("======longs========"+longs); + List<CoursePackageScheduling> coursePackageSchedulings = coursePackageSchedulingService.list(new QueryWrapper<CoursePackageScheduling>().in("id",longs).isNotNull("courseId")); + List<AppUserVideoResponse> coursePackageSchedulings1 = coursePackageSchedulingService.queryAll(longs); + + + + + return ResultUtil.success(coursePackageSchedulings1); + + + + + }catch (Exception e){ return ResultUtil.runErr(); } @@ -1645,7 +1676,7 @@ if(ToolUtil.isEmpty(coursePackage.getNeedNum())){ coursePackageStudent.setNeedNum(0); }else { - coursePackageStudent.setNeedNum(coursePackageStudent.getNeedNum()); + coursePackageStudent.setNeedNum(coursePackage.getNeedNum()); } } } @@ -1661,7 +1692,7 @@ ArrayList<Integer> years = new ArrayList<>(); for (Object o : collect) { String s = o.toString(); - List<CoursePackageStudent> collect1 = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).collect(Collectors.toList()); + List<CoursePackageStudent> collect1 = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList()); int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); years.add(sum2); } @@ -1682,47 +1713,391 @@ m="0"+i; } String s = year + "-" + m; - List<CoursePackageStudent> collect1 = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).collect(Collectors.toList()); + List<CoursePackageStudent> collect1 = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList()); int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); months.add(sum2); } map.put("monthData",months); - - // 周 // 获取最近四周 LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN); LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX); // 周度数据 - String s1 = minNow.minusDays(6).toString(); - String s2 = maxNow.toString(); + LocalDateTime s1 = minNow.minusDays(6); + LocalDateTime s2 = maxNow; - String s3 = minNow.minusDays(13).toString(); - String s4 = maxNow.minusDays(6).toString(); + LocalDateTime s3 = minNow.minusDays(13); + LocalDateTime s4 = maxNow.minusDays(6); - String s5 = minNow.minusDays(20).toString(); - String s6 = maxNow.minusDays(13).toString(); + LocalDateTime s5 = minNow.minusDays(20); + LocalDateTime s6 = maxNow.minusDays(13); - String s7 = minNow.minusDays(27).toString(); - String s8 = maxNow.minusDays(20).toString(); + LocalDateTime s7 = minNow.minusDays(27); + LocalDateTime s8 = maxNow.minusDays(20); + ArrayList<Object> weekData = new ArrayList<>(); -// -// int count = studentService.count(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1).between(TStudent::getInsertTime, s7, s8)); -// -// int count1 = studentService.count(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1).between(TStudent::getInsertTime,s5,s6)); -// -// int count2 = studentService.count(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1).between(TStudent::getInsertTime,s3,s4)); -// -// int count3 = studentService.count(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1).between(TStudent::getInsertTime,s1,s2)); + int count = 0; -// map.put("count",count); -// map.put("count1",count1); -// map.put("count2",count2); -// map.put("count3",count3); - return null; + int count1 = 0; + + int count2 = 0; + + int count3 = 0; + for (CoursePackageStudent coursePackageStudent : list) { + if (coursePackageStudent.getNeedNum()==null){ + continue; + } + // 如果到课状态为否 则不计算 + if (coursePackageStudent.getSignInOrNot() != 0) { + Date insertTime = coursePackageStudent.getInsertTime(); + Instant instant = insertTime.toInstant(); + ZoneId zoneId = ZoneId.systemDefault(); + LocalDateTime dateTime = instant.atZone(zoneId).toLocalDateTime(); + if (dateTime.isAfter(s1) && dateTime.isBefore(s2)){ + + count+=coursePackageStudent.getNeedNum(); + }else if(dateTime.isAfter(s3) && dateTime.isBefore(s4)){ + count1+=coursePackageStudent.getNeedNum(); + }else if(dateTime.isAfter(s5) && dateTime.isBefore(s6)){ + count2+=coursePackageStudent.getNeedNum(); + }else if(dateTime.isAfter(s7) && dateTime.isBefore(s8)){ + count3+=coursePackageStudent.getNeedNum(); + } + + } + } + weekData.add(count3); + weekData.add(count2); + weekData.add(count1); + weekData.add(count); + + map.put("weekData",weekData); + + + LocalDateTime currentDateTime = LocalDateTime.now(); + List<Integer> amountByDay = new ArrayList<>(Collections.nCopies(7,0)); + for (CoursePackageStudent coursePackageStudent : list) { + Date insertTime = coursePackageStudent.getInsertTime(); + // 将 Date 转换为 LocalDateTime + LocalDateTime insertDateTime = LocalDateTime.ofInstant(insertTime.toInstant(), ZoneId.systemDefault()); + // 计算日期与当前日期的差距 + long daysDifference = ChronoUnit.DAYS.between(insertDateTime.toLocalDate(), currentDateTime.toLocalDate()); + // 如果日期在七天内,累加金额 + if (daysDifference >= 0 && daysDifference < 7) { + int index = (int) (6 - daysDifference); // 计算对应的索引位置 + Integer needNum = coursePackageStudent.getNeedNum(); + if (needNum!=null){ + int i = amountByDay.get(index) + needNum; + amountByDay.set(index, i); + } + + } + } + map.put("dayData", amountByDay); + + return map; } + @ResponseBody + @PostMapping("/coursePackagePayment/courseYys") + HashMap<String, Object> courseYys(@RequestBody List<Integer> userPt){ + if(userPt.size()==0){ + userPt.add(-1); + } + HashMap<String, Object> map = new HashMap<>(); + List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.listOne(userPt); + int sum = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getTotalClassHours).sum(); + int sum1 = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getLaveClassHours).sum(); + map.put("allCourse",sum-sum1); + //所有课包 + List<TCoursePackage> coursePackages = tcpService.list(); + + + // 年 + List<CoursePackageStudent> list = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>().in(CoursePackageStudent::getAppUserId, userPt)); + + + for (CoursePackageStudent coursePackageStudent : list) { + for (TCoursePackage coursePackage : coursePackages) { + if(coursePackageStudent.getCoursePackageId().equals(coursePackage.getId())){ + if(ToolUtil.isEmpty(coursePackage.getNeedNum())){ + coursePackageStudent.setNeedNum(0); + }else { + coursePackageStudent.setNeedNum(coursePackage.getNeedNum()); + } + } + } + } + + ArrayList<Object> integers = new ArrayList<>(); + int year = cn.hutool.core.date.DateUtil.year(new Date()); + for (int i = 0; i < 10; i++) { + integers.add(year-i); + } + List<Object> collect = integers.stream().sorted().collect(Collectors.toList()); + // 年 + ArrayList<Integer> years = new ArrayList<>(); + for (Object o : collect) { + String s = o.toString(); + List<CoursePackageStudent> collect1 = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList()); + int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); + years.add(sum2); + } + + map.put("yearData",years); + + + + ArrayList<Integer> months = new ArrayList<>(); + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + + // 月 + for (int i = 1; i <= 12; i++) { + String m=i+""; + if(i<10){ + m="0"+i; + } + String s = year + "-" + m; + List<CoursePackageStudent> collect1 = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList()); + int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); + months.add(sum2); + } + map.put("monthData",months); + + // 周 + // 获取最近四周 + LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN); + LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX); + // 周度数据 + LocalDateTime s1 = minNow.minusDays(6); + LocalDateTime s2 = maxNow; + + LocalDateTime s3 = minNow.minusDays(13); + LocalDateTime s4 = maxNow.minusDays(6); + + + LocalDateTime s5 = minNow.minusDays(20); + LocalDateTime s6 = maxNow.minusDays(13); + + LocalDateTime s7 = minNow.minusDays(27); + LocalDateTime s8 = maxNow.minusDays(20); + ArrayList<Object> weekData = new ArrayList<>(); + + int count = 0; + + int count1 = 0; + + int count2 = 0; + + int count3 = 0; + for (CoursePackageStudent coursePackageStudent : list) { + if (coursePackageStudent.getNeedNum()==null){ + continue; + } + // 如果到课状态为否 则不计算 + if (coursePackageStudent.getSignInOrNot() != 0) { + Date insertTime = coursePackageStudent.getInsertTime(); + Instant instant = insertTime.toInstant(); + ZoneId zoneId = ZoneId.systemDefault(); + LocalDateTime dateTime = instant.atZone(zoneId).toLocalDateTime(); + if (dateTime.isAfter(s1) && dateTime.isBefore(s2)){ + + count+=coursePackageStudent.getNeedNum(); + }else if(dateTime.isAfter(s3) && dateTime.isBefore(s4)){ + count1+=coursePackageStudent.getNeedNum(); + }else if(dateTime.isAfter(s5) && dateTime.isBefore(s6)){ + count2+=coursePackageStudent.getNeedNum(); + }else if(dateTime.isAfter(s7) && dateTime.isBefore(s8)){ + count3+=coursePackageStudent.getNeedNum(); + } + + } + } + weekData.add(count3); + weekData.add(count2); + weekData.add(count1); + weekData.add(count); + + map.put("weekData",weekData); + + + LocalDateTime currentDateTime = LocalDateTime.now(); + List<Integer> amountByDay = new ArrayList<>(Collections.nCopies(7,0)); + for (CoursePackageStudent coursePackageStudent : list) { + Date insertTime = coursePackageStudent.getInsertTime(); + // 将 Date 转换为 LocalDateTime + LocalDateTime insertDateTime = LocalDateTime.ofInstant(insertTime.toInstant(), ZoneId.systemDefault()); + // 计算日期与当前日期的差距 + long daysDifference = ChronoUnit.DAYS.between(insertDateTime.toLocalDate(), currentDateTime.toLocalDate()); + // 如果日期在七天内,累加金额 + if (daysDifference >= 0 && daysDifference < 7) { + int index = (int) (6 - daysDifference); // 计算对应的索引位置 + Integer needNum = coursePackageStudent.getNeedNum(); + if (needNum!=null){ + int i = amountByDay.get(index) + needNum; + amountByDay.set(index, i); + } + + } + } + map.put("dayData", amountByDay); + + return map; + + } + @ResponseBody + @PostMapping("/coursePackagePayment/courseStore") + HashMap<String, Object> courseStore(@RequestBody List<Integer> userPt){ + if(userPt.size()==0){ + userPt.add(-1); + } + HashMap<String, Object> map = new HashMap<>(); + List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.listOne(userPt); + int sum = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getTotalClassHours).sum(); + int sum1 = tCoursePackagePayments.stream().mapToInt(TCoursePackagePayment::getLaveClassHours).sum(); + map.put("allCourse",sum-sum1); + + //所有课包 + List<TCoursePackage> coursePackages = tcpService.list(); + + + // 年 + List<CoursePackageStudent> list = cspsService.list(new LambdaQueryWrapper<CoursePackageStudent>().in(CoursePackageStudent::getAppUserId, userPt)); + + + for (CoursePackageStudent coursePackageStudent : list) { + for (TCoursePackage coursePackage : coursePackages) { + if(coursePackageStudent.getCoursePackageId().equals(coursePackage.getId())){ + if(ToolUtil.isEmpty(coursePackage.getNeedNum())){ + coursePackageStudent.setNeedNum(0); + }else { + coursePackageStudent.setNeedNum(coursePackage.getNeedNum()); + } + } + } + } + + ArrayList<Object> integers = new ArrayList<>(); + int year = cn.hutool.core.date.DateUtil.year(new Date()); + for (int i = 0; i < 10; i++) { + integers.add(year-i); + } + List<Object> collect = integers.stream().sorted().collect(Collectors.toList()); + // 年 + ArrayList<Integer> years = new ArrayList<>(); + for (Object o : collect) { + String s = o.toString(); + List<CoursePackageStudent> collect1 = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList()); + int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); + years.add(sum2); + } + + map.put("yearData",years); + + + + ArrayList<Integer> months = new ArrayList<>(); + + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + + // 月 + for (int i = 1; i <= 12; i++) { + String m=i+""; + if(i<10){ + m="0"+i; + } + String s = year + "-" + m; + List<CoursePackageStudent> collect1 = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).filter(student -> student.getNeedNum() != null).collect(Collectors.toList()); + int sum2 = collect1.stream().mapToInt(CoursePackageStudent::getNeedNum).sum(); + months.add(sum2); + } + map.put("monthData",months); + + // 周 + // 获取最近四周 + LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN); + LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX); + // 周度数据 + LocalDateTime s1 = minNow.minusDays(6); + LocalDateTime s2 = maxNow; + + LocalDateTime s3 = minNow.minusDays(13); + LocalDateTime s4 = maxNow.minusDays(6); + + + LocalDateTime s5 = minNow.minusDays(20); + LocalDateTime s6 = maxNow.minusDays(13); + + LocalDateTime s7 = minNow.minusDays(27); + LocalDateTime s8 = maxNow.minusDays(20); + ArrayList<Object> weekData = new ArrayList<>(); + + int count = 0; + + int count1 = 0; + + int count2 = 0; + + int count3 = 0; + for (CoursePackageStudent coursePackageStudent : list) { + if (coursePackageStudent.getNeedNum()==null){ + continue; + } + // 如果到课状态为否 则不计算 + if (coursePackageStudent.getSignInOrNot() != 0) { + Date insertTime = coursePackageStudent.getInsertTime(); + Instant instant = insertTime.toInstant(); + ZoneId zoneId = ZoneId.systemDefault(); + LocalDateTime dateTime = instant.atZone(zoneId).toLocalDateTime(); + if (dateTime.isAfter(s1) && dateTime.isBefore(s2)){ + + count+=coursePackageStudent.getNeedNum(); + }else if(dateTime.isAfter(s3) && dateTime.isBefore(s4)){ + count1+=coursePackageStudent.getNeedNum(); + }else if(dateTime.isAfter(s5) && dateTime.isBefore(s6)){ + count2+=coursePackageStudent.getNeedNum(); + }else if(dateTime.isAfter(s7) && dateTime.isBefore(s8)){ + count3+=coursePackageStudent.getNeedNum(); + } + + } + } + weekData.add(count3); + weekData.add(count2); + weekData.add(count1); + weekData.add(count); + + map.put("weekData",weekData); + + + LocalDateTime currentDateTime = LocalDateTime.now(); + List<Integer> amountByDay = new ArrayList<>(Collections.nCopies(7,0)); + for (CoursePackageStudent coursePackageStudent : list) { + Date insertTime = coursePackageStudent.getInsertTime(); + // 将 Date 转换为 LocalDateTime + LocalDateTime insertDateTime = LocalDateTime.ofInstant(insertTime.toInstant(), ZoneId.systemDefault()); + // 计算日期与当前日期的差距 + long daysDifference = ChronoUnit.DAYS.between(insertDateTime.toLocalDate(), currentDateTime.toLocalDate()); + // 如果日期在七天内,累加金额 + if (daysDifference >= 0 && daysDifference < 7) { + int index = (int) (6 - daysDifference); // 计算对应的索引位置 + Integer needNum = coursePackageStudent.getNeedNum(); + if (needNum!=null){ + int i = amountByDay.get(index) + needNum; + amountByDay.set(index, i); + } + + } + } + map.put("dayData", amountByDay); + + return map; + + } } -- Gitblit v1.7.1