lisy
2023-06-16 28b988ca5dc4b51de34c6ebf996579723b2db414
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
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.TCoursePackageService;
import com.dsh.course.servs.CoursePackagePaymentRepository;
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.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.ArrayList;
import java.util.List;
 
@Api
@CrossOrigin
@RestController
@RequestMapping("")
public class CoursePackagePaymentController {
 
    private Logger logger = LoggerFactory.getLogger("business-log");
 
    @Autowired
    private CoursePackagePaymentRepository coursePackagePaymentRepository;
 
    @Autowired
    private TCoursePackageService tcpService;
 
    /**
     * 获取 没有学员信息的图片配置
     * @param stuId 学员id
     * @return  课包列表
     */
    @PostMapping("/coursePack/queryPayment")
    public List<StuCourseResp> getStuCoursePackagePayment(Integer stuId){
        List<StuCourseResp> resps = new ArrayList<>();
        List<TCoursePackagePayment> byUserId = coursePackagePaymentRepository.findByUserId(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());
            }
        }
        return resps;
    }
 
    /**
     *
     * 获取发布的 课包列表
     */
    @PostMapping("/coursePack/storeOfCourse")
    public List<CourseOfStoreVo> getStuCourseWithStores(){
        return tcpService.queryStoreOfCourse();
    }
 
}