puzhibing
2024-03-15 b3e0d0ea6c1e311566bab861b79cc9b9c6d25287
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
package com.dsh.course.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.course.entity.CoursePackageOrder;
import com.dsh.course.entity.CoursePackageOrderStudent;
import com.dsh.course.model.DeductionClassHourList;
import com.dsh.course.service.ICoursePackageOrderService;
import com.dsh.course.service.ICoursePackageOrderStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
 
/**
 * @author zhibing.pu
 * @Date 2024/2/22 15:27
 */
@RestController
@RequestMapping("/coursePackageOrderStudent")
public class CoursePackageOrderStudentController {
 
    @Autowired
    private ICoursePackageOrderStudentService coursePackageOrderStudentService;
 
    @Autowired
    private ICoursePackageOrderService coursePackageOrderService;
 
 
 
 
 
    /**
     * 根据学员id获取剩余有效课时数据
     * @param studentId
     * @return
     */
    @ResponseBody
    @PostMapping("/getCoursePackageOrderStudent")
    public List<CoursePackageOrderStudent> getCoursePackageOrderStudent(@RequestBody Integer studentId){
        return coursePackageOrderStudentService.list(new QueryWrapper<CoursePackageOrderStudent>()
                .eq("studentId", studentId).eq("status", 1).eq("state", 1)
                .gt("laveClassHours", 0).last(" and useTime > now()"));
    }
 
 
 
    /**
     * 根据用户id获取剩余有效课时数据
     * @param appUserId
     * @return
     */
    @ResponseBody
    @PostMapping("/getCoursePackageOrderUser")
    public List<CoursePackageOrderStudent> getCoursePackageOrderUser(@RequestBody Integer appUserId){
        return coursePackageOrderStudentService.list(new QueryWrapper<CoursePackageOrderStudent>()
                .eq("appUserId", appUserId).eq("status", 1).eq("state", 1)
                .gt("laveClassHours", 0).last(" and useTime > now() order by insertTime"));
    }
 
 
    /**
     * 扣减学员课时
     * @param deductionClassHourList
     * @return
     */
    @ResponseBody
    @PostMapping("/deductionClassHour")
    public DeductionClassHourList deductionClassHour(@RequestBody DeductionClassHourList deductionClassHourList){
        return coursePackageOrderStudentService.deductionClassHour(deductionClassHourList);
    }
 
 
    /**
     * 回退课时和回退排课数据
     * @param deductionClassHourList
     */
    @ResponseBody
    @PostMapping("/backspaceClassHour")
    public void backspaceClassHour(@RequestBody DeductionClassHourList deductionClassHourList){
        coursePackageOrderStudentService.backspaceClassHour(deductionClassHourList);
    }
}