| | |
| | | package com.dsh.course.controller; |
| | | |
| | | import com.dsh.course.entity.CancelledClasses; |
| | | import com.dsh.course.service.CancelledClassesService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.dsh.course.entity.*; |
| | | 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.*; |
| | | 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 |
| | |
| | | |
| | | @Autowired |
| | | private CancelledClassesService cancelledClassesService; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private StoreClient storeClient; |
| | | @Autowired |
| | | 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> 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()); |
| | | if(null != byId){ |
| | | cancelClassesVO.setStudentName(studentClient.queryStudentById(byId.getStudentId()).getName()); |
| | | } |
| | | cancelClassesVO.setCoachName(coachClient.queryCoachById(cancelClassesVO.getCoachId()).getName()); |
| | | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | | @Autowired |
| | | private CourseCounsumService courseCounsumService; |
| | | |
| | | |
| | | @Autowired |
| | | private ICoursePackageOrderStudentService orderStudentService; |
| | | /** |
| | | * 添加数据 |
| | | * |
| | | * @param cancelledClasses |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/cancelledClasses/addCancelledClasses") |
| | | public void addCancelledClasses(@RequestBody CancelledClasses cancelledClasses){ |
| | | public void addCancelledClasses(@RequestBody CancelledClasses cancelledClasses) { |
| | | cancelledClassesService.save(cancelledClasses); |
| | | |
| | | // TCoursePackagePayment byId = coursePackagePaymentService.getById(cancelledClasses.getCoursePackagePaymentId()); |
| | | orderStudentService.getById(cancelledClasses.getCoursePackagePaymentId()); |
| | | CourseCounsum courseCounsum = new CourseCounsum(); |
| | | courseCounsum.setPaymentId(cancelledClasses.getCoursePackagePaymentId()); |
| | | courseCounsum.setChangeType(0); |
| | | courseCounsum.setNum(cancelledClasses.getCancelledClassesNumber()); |
| | | courseCounsum.setInsertTime(new Date()); |
| | | courseCounsum.setReason("消课"); |
| | | courseCounsumService.save(courseCounsum); |
| | | } |
| | | |
| | | } |