From ddbb38c54db9c3670e5ff53f4bf713525de1099d Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期二, 14 十一月 2023 09:12:10 +0800
Subject: [PATCH] 后台bug修改

---
 cloud-server-course/src/main/java/com/dsh/course/controller/CancelledClassesController.java |   87 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 84 insertions(+), 3 deletions(-)

diff --git a/cloud-server-course/src/main/java/com/dsh/course/controller/CancelledClassesController.java b/cloud-server-course/src/main/java/com/dsh/course/controller/CancelledClassesController.java
index 50fdbb4..e8bae42 100644
--- a/cloud-server-course/src/main/java/com/dsh/course/controller/CancelledClassesController.java
+++ b/cloud-server-course/src/main/java/com/dsh/course/controller/CancelledClassesController.java
@@ -1,17 +1,30 @@
 package com.dsh.course.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.dsh.course.entity.CancelledClasses;
+import com.dsh.course.entity.CoursePackageScheduling;
+import com.dsh.course.entity.TCoursePackage;
+import com.dsh.course.entity.TCoursePackagePayment;
 import com.dsh.course.feignclient.account.AppUserClient;
 import com.dsh.course.feignclient.account.CoachClient;
+import com.dsh.course.feignclient.account.StudentClient;
+import com.dsh.course.feignclient.account.model.Coach;
+import com.dsh.course.feignclient.account.model.Student;
 import com.dsh.course.feignclient.other.StoreClient;
 import com.dsh.course.model.CancelClassesQuery;
 import com.dsh.course.model.CancelClassesVO;
-import com.dsh.course.service.CancelledClassesService;
+import com.dsh.course.service.*;
 import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.text.SimpleDateFormat;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author zhibing.pu
@@ -29,17 +42,85 @@
     private AppUserClient appUserClient;
     @Autowired
     private CoachClient coachClient;
+    @Autowired
+    private StudentClient studentClient;
+    @Autowired
+    private TCoursePackageService coursePackageService;
+    @Autowired
+    private TCoursePackagePaymentService coursePackagePaymentService;
+    @Autowired
+    private ICoursePackageSchedulingService coursePackageSchedulingService;
+
     /**
      * 获取消课记录
      */
     @ResponseBody
     @PostMapping("/cancelledClasses/listAll")
     public List<CancelClassesVO> listAll(@RequestBody CancelClassesQuery query){
-        List<CancelClassesVO> result = cancelledClassesService.listAll(query);
+        List<CancelClassesVO> res = new ArrayList<>();
+        if (query.getStudentName()!=null){
+            if (!query.getStudentName().equals("")){
+                List<Integer> s = new ArrayList<>();
+                List<Student> students = studentClient.queryStudentListByName(query.getStudentName());
+                if (students.size()==0){
+                    return new ArrayList<>();
+                }
+                for (Student coach : students) {
+                    s.add(coach.getId());
+                }
+                query.setStudentIds(s);
+            }
+        }
+        if (query.getCoachName()!=null){
+            if (!query.getCoachName().equals("")){
+                List<Integer> c = new ArrayList<>();
+                List<Coach> coaches = coachClient.queryCoachListByName(query.getCoachName());
+                if (coaches.size()==0){
+                    return new ArrayList<>();
+                }
+                for (Coach coach : coaches) {
+                    c.add(coach.getId());
+                }
+                query.setCoachIds(c);
+            }
+        }
+        List<Integer> collect =new ArrayList<>();
+        if(query.getStoreId()!=null){
+            List<TCoursePackage> list = coursePackageService.list(new LambdaQueryWrapper<TCoursePackage>().eq(TCoursePackage::getStoreId, query.getStoreId()));
+             collect = list.stream().map(TCoursePackage::getId).collect(Collectors.toList());
+            if(collect.size()==0){
+                collect.add(-1);
+            }
+        }
+        if(query.getStoreIds()!=null && query.getStoreIds().size()!=0){
+            List<TCoursePackage> list = coursePackageService
+                    .list(new LambdaQueryWrapper<TCoursePackage>()
+                            .in(TCoursePackage::getStoreId, query.getStoreIds()));
+            collect = list.stream().map(TCoursePackage::getId).collect(Collectors.toList());
+            if(collect.size()==0){
+                collect.add(-1);
+            }
+        }
+        List<CancelClassesVO> result = cancelledClassesService.listAll(query,collect);
         for (CancelClassesVO cancelClassesVO : result) {
+            CoursePackageScheduling byId1 = coursePackageSchedulingService.getById(cancelClassesVO.getCoursePackageSchedulingId());
+            if (byId1==null){
+                continue;
+            }
+            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            String string = format.format(byId1.getClassDate());
+            String string1 = format.format(byId1.getEndDate());
+            String hour = string1.substring(11, 13);
+            String minute = string1.substring(14, 16);
+            // 去除后三位
+            String s = string.substring(0, string.length() - 3);
+            String temp = s+"-"+hour+":"+ minute;
+            cancelClassesVO.setStartAndEnd(temp);
+            TCoursePackagePayment byId = coursePackagePaymentService.getById(cancelClassesVO.getCoursePackagePaymentId());
             cancelClassesVO.setStoreName(storeClient.queryStoreById(cancelClassesVO.getStoreId()).getName());
-            cancelClassesVO.setStudentName(appUserClient.queryAppUser(cancelClassesVO.getStudentId()).getName());
+            cancelClassesVO.setStudentName(studentClient.queryStudentById(byId.getStudentId()).getName());
             cancelClassesVO.setCoachName(coachClient.queryCoachById(cancelClassesVO.getCoachId()).getName());
+
         }
         return result;
     }

--
Gitblit v1.7.1