| | |
| | | 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 |
| | |
| | | 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); |
| | | } |
| | | } |
| | | |
| | | List<CancelClassesVO> result = cancelledClassesService.listAll(query,collect); |
| | | for (CancelClassesVO cancelClassesVO : result) { |
| | | CoursePackageScheduling byId1 = coursePackageSchedulingService.getById(cancelClassesVO.getCoursePackageSchedulingId()); |
| | | 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; |
| | | } |