| | |
| | | import com.dsh.course.entity.TCoursePackage; |
| | | import com.dsh.course.entity.TCoursePackageDiscount; |
| | | import com.dsh.course.entity.TCoursePackagePayment; |
| | | import com.dsh.course.entity.TCoursePackageType; |
| | | import com.dsh.course.feignclient.model.*; |
| | | import com.dsh.course.model.BaseVo; |
| | | import com.dsh.course.model.dto.DiscountJsonDto; |
| | | import com.dsh.course.model.vo.CourseDetailRequest; |
| | | import com.dsh.course.service.PostCourseVideoService; |
| | | import com.dsh.course.service.TCoursePackageDiscountService; |
| | | import com.dsh.course.service.TCoursePackagePaymentService; |
| | | import com.dsh.course.service.TCoursePackageService; |
| | | import com.dsh.course.model.vo.RegisterCourseVo; |
| | | import com.dsh.course.model.vo.request.ClasspaymentRequest; |
| | | import com.dsh.course.model.vo.request.CourseOfAfterRequest; |
| | | import com.dsh.course.model.vo.request.CourseWithDetailsRequest; |
| | | import com.dsh.course.model.vo.request.UpdateCourseVideoStatusRequest; |
| | | import com.dsh.course.model.vo.response.AppUserVideoResponse; |
| | | import com.dsh.course.model.vo.response.CourseDetailsResponse; |
| | | import com.dsh.course.model.vo.response.CourseOfVideoResponse; |
| | | import com.dsh.course.service.*; |
| | | import com.dsh.course.util.DateUtil; |
| | | import com.dsh.course.util.ResultUtil; |
| | | import com.dsh.course.util.StrUtils; |
| | | import com.dsh.course.util.TokenUtil; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private PostCourseVideoService pcvService; |
| | | |
| | | @Autowired |
| | | private CoursePackageStudentService cpsService; |
| | | |
| | | @Autowired |
| | | private CancelledClassesService cacService; |
| | | |
| | | @Autowired |
| | | private TCoursePackageTypeService coursePackageTypeService; |
| | | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | | |
| | | private final SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm"); |
| | | |
| | |
| | | } |
| | | |
| | | courseVo.setCourseTime(coursePackage.getClassStartTime()+"-"+coursePackage.getClassEndTime()); |
| | | String payType = tCoursePackagePayment.getPayType(); |
| | | Integer payType = tCoursePackagePayment.getPayType(); |
| | | BigDecimal cashPayment = tCoursePackagePayment.getCashPayment(); |
| | | double cashPaymentValue = cashPayment.doubleValue(); |
| | | Integer playPaiCoin = tCoursePackagePayment.getPlayPaiCoin(); |
| | |
| | | throw new RuntimeException(e); |
| | | } |
| | | switch (payType) { |
| | | case "1;2": |
| | | courseVo.setAmount(cashPaymentValue); |
| | | courseVo.setVipAmount(discountMember); |
| | | courseVo.setWpGold(playPaiCoin); |
| | | break; |
| | | case "1": |
| | | case 1: |
| | | case 2: |
| | | courseVo.setAmount(cashPaymentValue); |
| | | courseVo.setVipAmount(discountMember); |
| | | break; |
| | | case "2": |
| | | case 3: |
| | | courseVo.setWpGold(playPaiCoin); |
| | | break; |
| | | } |
| | |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.queryAllCoursePackage(null,null,null,null,appUserId); |
| | | List<Integer> coursePackageIds = tCoursePackagePayments.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList()); |
| | | // List<PostCourseVideo> videoList = pcvService.queryAllVideoNoneShow(coursePackageIds); |
| | | // TODO: 2023/7/6 两个课后视频 |
| | | return videoVos; |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/course/queryArrangeCourseList") |
| | | @ApiOperation(value = "获取布置课程列表", tags = {"APP-课程列表"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil<List<BaseVo>> queryArrangePackageType(){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.queryAllCoursePackage(null,null,null,null,appUserId); |
| | | List<BaseVo> list = new ArrayList<>(); |
| | | tCoursePackagePayments.forEach(c -> { |
| | | BaseVo baseVo = new BaseVo(); |
| | | baseVo.setId(c.getCoursePackageId()); |
| | | TCoursePackage coursePackage = tcpService.getById(c.getCoursePackageId()); |
| | | baseVo.setName(coursePackage.getName()); |
| | | list.add(baseVo); |
| | | }); |
| | | return ResultUtil.success(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课后视频课表 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/afterSourceList") |
| | | @ApiOperation(value = "课后视频课表", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil<List<AppUserVideoResponse>> queryAfterSourceList(@RequestBody CourseOfAfterRequest search){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<Integer> courseIds = new ArrayList<>(); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.queryAllCoursePackage(null,null,search.getCourseTypeId(),null,appUserId); |
| | | if (tCoursePackagePayments.size() > 0 ){ |
| | | courseIds = tCoursePackagePayments.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList()); |
| | | } |
| | | return ResultUtil.success(packagePaymentService.queryAfterVideo(search,courseIds)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 课后视频详情 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/afterSourceDetail") |
| | | @ApiOperation(value = "课后视频详情", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil<CourseOfVideoResponse> queryAfterSourceDetails(@RequestBody CourseWithDetailsRequest detailsRequest){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(packagePaymentService.queryVideoDetails(detailsRequest,appUserId)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新课后视频学习状态 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/updateVideoStatus") |
| | | @ApiOperation(value = "更新课后视频学习状态", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil updateVideoStatus(@RequestBody UpdateCourseVideoStatusRequest detailsRequest){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(packagePaymentService.updateVideoStatus(detailsRequest,appUserId)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/course/getCourseAppUserDetails") |
| | | @ApiOperation(value = "已报名课程-获取课程类型列表", tags = {"APP-课程列表"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil<List<BaseVo>> queryCoursePackageType(){ |
| | | try { |
| | | List<TCoursePackageType> coursePackageTypes = coursePackageTypeService.list(new QueryWrapper<TCoursePackageType>().eq("state", 1)); |
| | | List<BaseVo> list = new ArrayList<>(); |
| | | coursePackageTypes.forEach(c -> { |
| | | BaseVo baseVo = new BaseVo(); |
| | | BeanUtils.copyProperties(c, baseVo); |
| | | list.add(baseVo); |
| | | }); |
| | | return ResultUtil.success(list); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 已报名课程列表 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/registeredCourses") |
| | | @ApiOperation(value = "已报名课程-课程列表", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil<List<RegisterCourseVo>> queryRegisteredCoursesDetails(@RequestBody CourseOfAfterRequest courseTypeId){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(packagePaymentService.queryRegisteredCourseList(courseTypeId,appUserId)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 已报名课程详情 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/afterSourceDetail") |
| | | @ApiOperation(value = "已报名课程详情", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil<CourseDetailsResponse> getRegisteredData(@RequestBody Integer coursePackageId){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(packagePaymentService.queryRegisteredCourseDetails(coursePackageId,appUserId)); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 已报名课程-支付 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/payment") |
| | | @ApiOperation(value = "已报名课程-支付", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil continuationOperation(@RequestBody ClasspaymentRequest request){ |
| | | try { |
| | | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); |
| | | if(null == userIdFormRedis){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return packagePaymentService.ContinuationOrpaymentCourse(userIdFormRedis,request); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |