nickchange
2023-10-24 fc076febec4f1e4b46beeca343f78010d8f8924d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package com.dsh.course.controller;
 
import com.dsh.course.entity.CancelledClasses;
import com.dsh.course.entity.CoursePackageScheduling;
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.*;
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;
 
/**
 * @author zhibing.pu
 * @Date 2023/8/12 3:47
 */
@RestController
@RequestMapping("")
public class CancelledClassesController {
 
    @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<CancelClassesVO> result = cancelledClassesService.listAll(query);
        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(studentClient.queryStudentById(byId.getStudentId()).getName());
            cancelClassesVO.setCoachName(coachClient.queryCoachById(cancelClassesVO.getCoachId()).getName());
 
        }
        return result;
    }
 
    /**
     * 添加数据
     * @param cancelledClasses
     */
    @ResponseBody
    @PostMapping("/cancelledClasses/addCancelledClasses")
    public void addCancelledClasses(@RequestBody CancelledClasses cancelledClasses){
        cancelledClassesService.save(cancelledClasses);
    }
 
}