44323
2023-10-11 232d3efb20f87f9c60faeda7bae4bc96e5687bd3
cloud-server-account/src/main/java/com/dsh/account/controller/StudentController.java
@@ -26,6 +26,8 @@
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
import java.util.stream.Collectors;
@@ -262,6 +264,13 @@
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id));
        return list.stream().map(TAppUser::getId).collect(Collectors.toList());
    }
    @ResponseBody
    @PostMapping("/student/getUserPtVip")
    public List<Integer> getUserPtVip(){
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1));
        return list.stream().map(TAppUser::getId).collect(Collectors.toList());
    }
    @PostMapping("/student/getUserStore")
    @ResponseBody
   public  List<Integer> getUserStore(@RequestBody Integer id){
@@ -270,6 +279,436 @@
    }
    @ResponseBody
    @PostMapping("/student/userAndVipPt")
    public HashMap<String, Object>  userAndVipPt(@RequestBody Integer type){
        HashMap<String, Object> map = new HashMap<>();
        // 所有的
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1));
        map.put("allUser",list.size());
        List<TAppUser> list1 = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1));
        map.put("allVip",list1.size());
        ArrayList<Object> integers = new ArrayList<>();
        int year = 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<Long> years = new ArrayList<>();
        ArrayList<Long> yearsVip = new ArrayList<>();
        for (Object o : collect) {
            String s = o.toString();
            long count = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).count();
            long count1 = list1.stream().filter(e -> e.getInsertTime().toString().contains(s)).count();
            years.add(count);
            yearsVip.add(count1);
        }
        map.put("yearData",years);
        map.put("yearsVip",yearsVip);
        ArrayList<Long> months = new ArrayList<>();
        ArrayList<Long> monthsVip = 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;
            long count = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).count();
            long count1 = list1.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).count();
            months.add(count);
            monthsVip.add(count1);
        }
        map.put("monthData",months);
        map.put("monthsVip",monthsVip);
        // 周
        // 获取最近四周
        LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX);
        // 周度数据
        String s1 = minNow.minusDays(6).toString();
        String s2 = maxNow.toString();
        String s3 = minNow.minusDays(13).toString();
        String s4 = maxNow.minusDays(6).toString();
        String s5 = minNow.minusDays(20).toString();
        String s6 = maxNow.minusDays(13).toString();
        String s7 = minNow.minusDays(27).toString();
        String s8 = maxNow.minusDays(20).toString();
        int count = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).between(TAppUser::getInsertTime, s7, s8));
        int countVip = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s7, s8));
        int count1 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).between(TAppUser::getInsertTime,s5,s6));
        int countVip1 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s5,s6));
        int count2 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).between(TAppUser::getInsertTime,s3,s4));
        int countVip2 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s3,s4));
        int count3 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).between(TAppUser::getInsertTime,s1,s2));
        int countVip3 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s1,s2));
        map.put("count",count);
        map.put("count1",count1);
        map.put("count2",count2);
        map.put("count3",count3);
        map.put("countVip",countVip);
        map.put("countVip1",countVip1);
        map.put("countVip2",countVip2);
        map.put("countVip3",countVip3);
        // 日
        ArrayList<Integer> days = new ArrayList<>();
        ArrayList<Integer> daysVip = new ArrayList<>();
        for (int i = 6; i >= 0; i--) {
            String s = minNow.minusDays(i).toString();
            String s9 = maxNow.minusDays(i).toString();
            int count4 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).between(TAppUser::getInsertTime,s,s9));
            int countVip5 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s,s9));
            days.add(count4);
            daysVip.add(countVip5);
        }
        map.put("dayData",days);
        map.put("daysVip",daysVip);
        return map;
    }
    @ResponseBody
    @PostMapping("/student/stuPt")
    public HashMap<String, Object>  stuPt(){
        HashMap<String, Object> map = new HashMap<>();
        // 所有的
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 1));
        List<Integer> collect1 = list.stream().map(TAppUser::getId).collect(Collectors.toList());
        if(collect1.size()==0){
            collect1.add(-1);
        }
        List<TStudent> students = studentService.list(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1));
        map.put("allUser",students.size());
        ArrayList<Object> integers = new ArrayList<>();
        int year = 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<Long> years = new ArrayList<>();
        for (Object o : collect) {
            String s = o.toString();
            long count = students.stream().filter(e -> e.getInsertTime().toString().contains(s)).count();
            years.add(count);
        }
        map.put("yearData",years);
        ArrayList<Long> 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;
            long count = students.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).count();
            months.add(count);
        }
        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();
        String s3 = minNow.minusDays(13).toString();
        String s4 = maxNow.minusDays(6).toString();
        String s5 = minNow.minusDays(20).toString();
        String s6 = maxNow.minusDays(13).toString();
        String s7 = minNow.minusDays(27).toString();
        String s8 = maxNow.minusDays(20).toString();
        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));
        map.put("count",count);
        map.put("count1",count1);
        map.put("count2",count2);
        map.put("count3",count3);
        // 日
        ArrayList<Integer> days = new ArrayList<>();
        for (int i = 6; i >= 0; i--) {
            String s = minNow.minusDays(i).toString();
            String s9 = maxNow.minusDays(i).toString();
            int count4 = studentService.count(new LambdaQueryWrapper<TStudent>().in(TStudent::getAppUserId, collect1).between(TStudent::getInsertTime,s,s9));
            days.add(count4);
        }
        map.put("dayData",days);
        return map;
    }
    @ResponseBody
    @PostMapping("/student/userAndVipYys")
    public HashMap<String, Object>  userAndVipYys(@RequestBody Integer id){
        HashMap<String, Object> map = new HashMap<>();
        // 所有的
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id));
        map.put("allUser",list.size());
        List<TAppUser> list1 = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id).eq(TAppUser::getIsVip,1));
        map.put("allVip",list1.size());
        ArrayList<Object> integers = new ArrayList<>();
        int year = 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<Long> years = new ArrayList<>();
        ArrayList<Long> yearsVip = new ArrayList<>();
        for (Object o : collect) {
            String s = o.toString();
            long count = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).count();
            long count1 = list1.stream().filter(e -> e.getInsertTime().toString().contains(s)).count();
            years.add(count);
            yearsVip.add(count1);
        }
        map.put("yearData",years);
        map.put("yearsVip",yearsVip);
        ArrayList<Long> months = new ArrayList<>();
        ArrayList<Long> monthsVip = 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;
            long count = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).count();
            long count1 = list1.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).count();
            months.add(count);
            monthsVip.add(count1);
        }
        map.put("monthData",months);
        map.put("monthsVip",monthsVip);
        // 周
        // 获取最近四周
        LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX);
        // 周度数据
        String s1 = minNow.minusDays(6).toString();
        String s2 = maxNow.toString();
        String s3 = minNow.minusDays(13).toString();
        String s4 = maxNow.minusDays(6).toString();
        String s5 = minNow.minusDays(20).toString();
        String s6 = maxNow.minusDays(13).toString();
        String s7 = minNow.minusDays(27).toString();
        String s8 = maxNow.minusDays(20).toString();
        int count = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id).between(TAppUser::getInsertTime, s7, s8));
        int countVip = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s7, s8));
        int count1 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id).between(TAppUser::getInsertTime,s5,s6));
        int countVip1 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s5,s6));
        int count2 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id).between(TAppUser::getInsertTime,s3,s4));
        int countVip2 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s3,s4));
        int count3 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id).between(TAppUser::getInsertTime,s1,s2));
        int countVip3 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s1,s2));
        map.put("count",count);
        map.put("count1",count1);
        map.put("count2",count2);
        map.put("count3",count3);
        map.put("countVip",countVip);
        map.put("countVip1",countVip1);
        map.put("countVip2",countVip2);
        map.put("countVip3",countVip3);
        // 日
        ArrayList<Integer> days = new ArrayList<>();
        ArrayList<Integer> daysVip = new ArrayList<>();
        for (int i = 6; i >= 0; i--) {
            String s = minNow.minusDays(i).toString();
            String s9 = maxNow.minusDays(i).toString();
            int count4 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id).between(TAppUser::getInsertTime,s,s9));
            int countVip5 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 2).eq(TAppUser::getAddUserId,id).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s,s9));
            days.add(count4);
            daysVip.add(countVip5);
        }
        map.put("dayData",days);
        map.put("daysVip",daysVip);
        return map;
    }
    @ResponseBody
    @PostMapping("/student/userAndVipStore")
    public HashMap<String, Object>  userAndVipStore(@RequestBody Integer id){
        HashMap<String, Object> map = new HashMap<>();
        // 所有的
        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id));
        map.put("allUser",list.size());
        List<TAppUser> list1 = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id).eq(TAppUser::getIsVip,1));
        map.put("allVip",list1.size());
        ArrayList<Object> integers = new ArrayList<>();
        int year = 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<Long> years = new ArrayList<>();
        ArrayList<Long> yearsVip = new ArrayList<>();
        for (Object o : collect) {
            String s = o.toString();
            long count = list.stream().filter(e -> e.getInsertTime().toString().contains(s)).count();
            long count1 = list1.stream().filter(e -> e.getInsertTime().toString().contains(s)).count();
            years.add(count);
            yearsVip.add(count1);
        }
        map.put("yearData",years);
        map.put("yearsVip",yearsVip);
        ArrayList<Long> months = new ArrayList<>();
        ArrayList<Long> monthsVip = 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;
            long count = list.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).count();
            long count1 = list1.stream().filter(e -> format.format(e.getInsertTime()).contains(s)).count();
            months.add(count);
            monthsVip.add(count1);
        }
        map.put("monthData",months);
        map.put("monthsVip",monthsVip);
        // 周
        // 获取最近四周
        LocalDateTime minNow = LocalDateTime.now().with(LocalTime.MIN);
        LocalDateTime maxNow = LocalDateTime.now().with(LocalTime.MAX);
        // 周度数据
        String s1 = minNow.minusDays(6).toString();
        String s2 = maxNow.toString();
        String s3 = minNow.minusDays(13).toString();
        String s4 = maxNow.minusDays(6).toString();
        String s5 = minNow.minusDays(20).toString();
        String s6 = maxNow.minusDays(13).toString();
        String s7 = minNow.minusDays(27).toString();
        String s8 = maxNow.minusDays(20).toString();
        int count = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id).between(TAppUser::getInsertTime, s7, s8));
        int countVip = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s7, s8));
        int count1 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id).between(TAppUser::getInsertTime,s5,s6));
        int countVip1 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s5,s6));
        int count2 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id).between(TAppUser::getInsertTime,s3,s4));
        int countVip2 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s3,s4));
        int count3 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id).between(TAppUser::getInsertTime,s1,s2));
        int countVip3 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s1,s2));
        map.put("count",count);
        map.put("count1",count1);
        map.put("count2",count2);
        map.put("count3",count3);
        map.put("countVip",countVip);
        map.put("countVip1",countVip1);
        map.put("countVip2",countVip2);
        map.put("countVip3",countVip3);
        // 日
        ArrayList<Integer> days = new ArrayList<>();
        ArrayList<Integer> daysVip = new ArrayList<>();
        for (int i = 6; i >= 0; i--) {
            String s = minNow.minusDays(i).toString();
            String s9 = maxNow.minusDays(i).toString();
            int count4 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id).between(TAppUser::getInsertTime,s,s9));
            int countVip5 = appUserService.count(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id).eq(TAppUser::getIsVip,1).between(TAppUser::getInsertTime, s,s9));
            days.add(count4);
            daysVip.add(countVip5);
        }
        map.put("dayData",days);
        map.put("daysVip",daysVip);
        return map;
    }
    @PostMapping("/student/queryFee")
    public HashMap<String, Object> queryFee(@RequestBody QueryDataFee queryDataFee){
        HashMap<String, Object> map = new HashMap<>();