java
2023-06-28 2b93646be2a3537342d802f1d9fafe22415fe62e
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
package com.dsh.course.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dsh.course.entity.TCoursePackage;
import com.dsh.course.entity.TCoursePackagePayment;
import com.dsh.course.feignclient.model.CourseOfStoreVo;
import com.dsh.course.feignclient.model.StuCourseResp;
import com.dsh.course.feignclient.model.StuSessionDetailsVo;
import com.dsh.course.service.TCoursePackagePaymentService;
import com.dsh.course.service.TCoursePackageService;
import com.dsh.course.util.DateUtil;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
 
@Api
@CrossOrigin
@RestController
@RequestMapping("")
public class CoursePackagePaymentController {
 
    private Logger logger = LoggerFactory.getLogger("business-log");
 
 
    @Autowired
    private TCoursePackagePaymentService packagePaymentService;
 
    @Autowired
    private TCoursePackageService tcpService;
 
    /**
     * 获取 没有学员信息的图片配置
     * @param stuId 学员id
     * @return  课包列表
     */
    @PostMapping("/coursePack/queryPayment")
    public List<StuCourseResp> getStuCoursePackagePayment(@RequestBody Integer stuId,@RequestBody Integer appUserId){
        List<StuCourseResp> resps = new ArrayList<>();
        List<TCoursePackagePayment> byUserId = packagePaymentService.queryAllCoursePackage(stuId,appUserId);
        if (byUserId.size() > 0 ){
            for (TCoursePackagePayment tCoursePackagePayment : byUserId) {
                TCoursePackage tCoursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId());
                StuCourseResp resp = new StuCourseResp();
                resp.setCourseId(tCoursePackage.getId());
                resp.setCourseName(tCoursePackage.getName());
                resp.setTotalCourseNums(tCoursePackagePayment.getTotalClassHours());
                resp.setResidueNums(tCoursePackagePayment.getLaveClassHours());
                resp.setDeductionNums(tCoursePackagePayment.getTotalClassHours()-tCoursePackagePayment.getLaveClassHours());
                resps.add(resp);
            }
        }
        return resps;
    }
 
    /**
     *
     * 获取发布的 课包列表
     */
    @PostMapping("/coursePack/storeOfCourse")
    public List<CourseOfStoreVo> getStuCourseWithStores(){
        List<CourseOfStoreVo> courseOfStoreVos = tcpService.queryStoreOfCourse();
        if (courseOfStoreVos.size() > 0){
            for (CourseOfStoreVo courseOfStoreVo : courseOfStoreVos) {
                String[] split = courseOfStoreVo.getClassWeeks().split(";");
                List<Integer> integers = new ArrayList<>();
                for (String s : split) {
                    int num = Integer.parseInt(s);
                    integers.add(num);
                }
                courseOfStoreVo.setClassWeekList(integers);
            }
        }
        return tcpService.queryStoreOfCourse();
    }
 
 
    /**
     *
     * 课程名称列表
     */
    @PostMapping("/coursePack/sessionNames")
    public List<StuSessionDetailsVo> getStuSessionList(@RequestParam("stuId") Integer stuId,@RequestParam("appUserId") Integer appUserId){
        List<StuSessionDetailsVo> detailsVos = new ArrayList<>();
        List<TCoursePackagePayment> byUserId = packagePaymentService.queryAllCoursePackage(stuId,appUserId);
        if (byUserId.size() > 0){
            List<Integer> collect = byUserId.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList());
            List<TCoursePackage> list = tcpService.list(new QueryWrapper<TCoursePackage>()
                    .in("id", collect));
            list.forEach(vo -> {
                StuSessionDetailsVo detVo = new StuSessionDetailsVo();
                detVo.setSessionid(vo.getId());
                detVo.setSessionName(vo.getName());
                String afterDayDate = DateUtil.getAfterDayDate2(vo.getInsertTime(),vo.getValidDays() + "");
                detVo.setPeriodOfValidity(afterDayDate);
                detailsVos.add(detVo);
            });
        }
        return detailsVos;
    }
}