puzhibing
2023-07-04 75b60332f174363cfe67f61dea87832be708ac15
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
package com.dsh.course.controller;
 
 
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.service.TCoursePackagePaymentService;
import com.dsh.course.service.TCoursePackageService;
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;
 
@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){
        List<StuCourseResp> resps = new ArrayList<>();
        List<TCoursePackagePayment> byUserId = packagePaymentService.queryAllCoursePackage(stuId);
        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();
    }
 
}