From ae9bfd2d66f68a553786ac78b12f4390e65e4e09 Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期五, 24 十一月 2023 18:30:18 +0800
Subject: [PATCH] 后台bug修改

---
 cloud-server-account/src/main/java/com/dsh/account/controller/StudentController.java |  288 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 271 insertions(+), 17 deletions(-)

diff --git a/cloud-server-account/src/main/java/com/dsh/account/controller/StudentController.java b/cloud-server-account/src/main/java/com/dsh/account/controller/StudentController.java
index b7be969..9160687 100644
--- a/cloud-server-account/src/main/java/com/dsh/account/controller/StudentController.java
+++ b/cloud-server-account/src/main/java/com/dsh/account/controller/StudentController.java
@@ -8,11 +8,9 @@
 import com.dsh.account.feignclient.course.CoursePaymentClient;
 import com.dsh.account.feignclient.course.model.TCoursePackagePayment;
 import com.dsh.account.model.QueryDataFee;
+import com.dsh.account.model.Student;
 import com.dsh.account.model.StudentVo;
-import com.dsh.account.service.IVipPaymentService;
-import com.dsh.account.service.RechargeRecordsService;
-import com.dsh.account.service.TAppUserService;
-import com.dsh.account.service.TStudentService;
+import com.dsh.account.service.*;
 import com.dsh.account.util.ResultUtil;
 import com.dsh.account.util.TokenUtil;
 import com.dsh.account.util.ToolUtil;
@@ -65,6 +63,15 @@
        return studentService.save(student);
     }
     /**
+     * 获取有学员的用户ids
+     * @return
+     */
+    @ResponseBody
+    @PostMapping("/student/getHasStudentUser")
+    public List<Integer> getHasStudentUser(){
+       return studentService.list(new QueryWrapper<TStudent>()).stream().map(TStudent::getAppUserId).distinct().collect(Collectors.toList());
+    }
+    /**
      * 获取用户学员列表
      * @param appUserId
      * @return
@@ -81,12 +88,33 @@
         }
     }
 
+
+    @ResponseBody
+    @PostMapping("/student/queryListByIds")
+    public List<TStudent> queryListByIds(@RequestBody List<Integer> collect){
+        try {
+            List<TStudent> list = studentService.list(new QueryWrapper<TStudent>().in("id",collect).eq("state", 1));
+            return list;
+        }catch (Exception e){
+            e.printStackTrace();
+            return new ArrayList<>();
+        }
+    }
+
+
     @ResponseBody
     @PostMapping("/student/queryStudentCom")
     public  List<Map<String, Object>> queryStudentCom(@RequestBody Integer id){
 
         List<Map<String, Object>> list = studentService.queryCom(id);
             return list;
+
+    }
+
+    @ResponseBody
+    @PostMapping("/student/frozen")
+    public  void frozen(@RequestBody TStudent student){
+            studentService.updateById(student);
 
     }
 
@@ -154,6 +182,22 @@
         }
     }
 
+
+    @ResponseBody
+    @PostMapping("/student/queryById")
+    public TStudent queryById(@RequestBody Integer id) {
+            return studentService.getById(id);
+    }
+
+    @ResponseBody
+    @PostMapping("/base/appUser/updateTStudent")
+    public void updateTStudent(@RequestBody TStudent student){
+        try {
+            studentService.updateById(student);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
 
     /**
      * 根据id获取数据
@@ -237,16 +281,14 @@
     @PostMapping("/student/giftSelect")
     public  List<SelectDto> giftSelect(@RequestBody GiftSearchDto giftSearchDto){
         System.out.println("======giftSelect=========giftSearchDto===="+giftSearchDto);
-
+        TAppUser one = appUserService.getOne(new QueryWrapper<TAppUser>().eq("name", giftSearchDto.getName())
+                .eq("phone", giftSearchDto.getPhone()));
 //       Integer appId = studentService.getGiftSelect(giftSearchDto);
         TCoursePackagePayment1 coursePackagePaymentById = paymentClient.getCoursePackagePaymentById1(giftSearchDto.getId());
 //        System.out.println("=======giftSelect======appId====>"+appId);
         List<TStudent> selectDtos =  studentService.list(new QueryWrapper<TStudent>()
-                .select("name, id")
                 .eq("state", 1)
-                .eq("name", giftSearchDto.getName()).eq("phone",giftSearchDto.getPhone()).ne("appUserId",coursePackagePaymentById.getAppUserId()));
-
-
+                .eq("appUserId",one.getId()));
         List<SelectDto> list = new ArrayList<>();
         for (TStudent student : selectDtos) {
             SelectDto selectDto = new SelectDto();
@@ -254,6 +296,8 @@
             selectDto.setId(student.getId());
             list.add(selectDto);
         }
+        // 只筛选当前用户已经购买了这个课程的学员
+
         System.out.println("=======giftSelect======selectDtos====>"+list);
         return list;
     }
@@ -274,6 +318,18 @@
         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());
     }
+    @PostMapping("/student/getUserStore")
+    @ResponseBody
+    public  List<Integer> getUserStore(@RequestBody Integer id){
+        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id));
+        return list.stream().map(TAppUser::getId).collect(Collectors.toList());
+    }
+    @PostMapping("/student/getUserYys")
+    @ResponseBody
+    public  List<Integer> getUserYys(@RequestBody Integer id){
+        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(){
@@ -281,12 +337,7 @@
         return list.stream().map(TAppUser::getId).collect(Collectors.toList());
     }
 
-    @PostMapping("/student/getUserStore")
-    @ResponseBody
-   public  List<Integer> getUserStore(@RequestBody Integer id){
-        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getInsertType, 3).eq(TAppUser::getAddUserId,id));
-        return list.stream().map(TAppUser::getId).collect(Collectors.toList());
-    }
+
 
 
     @ResponseBody
@@ -488,13 +539,216 @@
 
         return map;
 
+
+    }
+    @ResponseBody
+    @PostMapping("/student/stuYys")
+    public HashMap<String, Object>  stuYys(@RequestBody Integer id){
+
+        HashMap<String, Object> map = new HashMap<>();
+        // 所有的
+        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getAddUserId, id));
+        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/comdel")
+    public void  comdel(@RequestBody Integer id) {
+        evaluateStudentService.removeById(id);
+
+    }
+
+
+    @ResponseBody
+    @PostMapping("/student/stuStores")
+    public HashMap<String, Object>  stuStores(@RequestBody Integer id){
+        HashMap<String, Object> map = new HashMap<>();
+        // 所有的
+        List<TAppUser> list = appUserService.list(new LambdaQueryWrapper<TAppUser>().eq(TAppUser::getAddUserId, id));
+        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;
+
     }
 
 
 
 
+    @Autowired
+    private EvaluateStudentService evaluateStudentService;
+    @ResponseBody
+    @PostMapping("/student/save")
+    public void   save(@RequestBody EvaluateStudent evaluateStudent) {
+            evaluateStudent.setInsertTime(new Date());
+        evaluateStudentService.saveOrUpdate(evaluateStudent);
 
-
+    }
 
 
 
@@ -882,7 +1136,7 @@
 
     }
     @PostMapping("/student/queryUserAgeYys")
-    public HashMap<String, Object> queryUserAgeYys(Integer id){
+    public HashMap<String, Object> queryUserAgeYys(@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));
         List<Integer> collect = list.stream().map(TAppUser::getId).collect(Collectors.toList());

--
Gitblit v1.7.1