| | |
| | | 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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.course.entity.*; |
| | | import com.dsh.course.feignclient.account.AppUserClient; |
| | | import com.dsh.course.feignclient.account.model.AppUser; |
| | | 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.model.vo.RegisterCourseVo; |
| | | import com.dsh.course.model.vo.request.*; |
| | | 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.*; |
| | | 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.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Api |
| | | @CrossOrigin |
| | |
| | | @Autowired |
| | | private TCoursePackageService tcpService; |
| | | |
| | | @Autowired |
| | | private TCoursePackageDiscountService tcpdService; |
| | | |
| | | |
| | | @Autowired |
| | | private ICoursePackagePaymentConfigService icppcService; |
| | | |
| | | @Autowired |
| | | private UserVideoDetailsService uvdsService; |
| | | |
| | | @Autowired |
| | | private TCourseService tcService; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private TCoursePackageTypeService coursePackageTypeService; |
| | | |
| | | @Autowired |
| | | private TokenUtil tokenUtil; |
| | | |
| | | @Autowired |
| | | private CancelledClassesService cancelledClassesService; |
| | | |
| | | @Autowired |
| | | private PayMoneyUtil payMoneyUtil; |
| | | @Resource |
| | | private AppUserClient auClitn; |
| | | |
| | | private final SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm"); |
| | | |
| | | /** |
| | | * 获取 没有学员信息的图片配置 |
| | | * @param stuId 学员id |
| | | * @return 课包列表 |
| | | */ |
| | | @PostMapping("/coursePack/queryPayment") |
| | | public List<StuCourseResp> getStuCoursePackagePayment(@RequestBody Integer stuId){ |
| | | @PostMapping("/base/coursePack/queryPayment") |
| | | public List<StuCourseResp> getStuCoursePackagePayment(@RequestParam("stuId") Integer stuId,@RequestParam("appUserId") Integer appUserId){ |
| | | List<StuCourseResp> resps = new ArrayList<>(); |
| | | List<TCoursePackagePayment> byUserId = packagePaymentService.queryAllCoursePackage(stuId); |
| | | List<TCoursePackagePayment> byUserId = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("appUserId",appUserId) |
| | | .eq("studentId",stuId)); |
| | | |
| | | if (byUserId.size() > 0 ){ |
| | | for (TCoursePackagePayment tCoursePackagePayment : byUserId) { |
| | | TCoursePackage tCoursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId()); |
| | |
| | | * |
| | | * 获取发布的 课包列表 |
| | | */ |
| | | @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); |
| | | @PostMapping("/base/coursePack/storeOfCourse") |
| | | public List<CourseOfStoreVo> getStuCourseWithStores(@RequestBody WeeksOfCourseRest courseRest){ |
| | | List<CourseOfStoreVo> course = new ArrayList<>(); |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
| | | try { |
| | | Date parse = simpleDateFormat.parse(courseRest.getTime()); |
| | | List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("appUserId",courseRest.getAppUserId() ) |
| | | .eq("studentId",courseRest.getStuId()) |
| | | .eq("payStatus",2) |
| | | .eq("status",1) |
| | | .eq("state",1) |
| | | .groupBy("coursePackageId")); |
| | | if (list.size() > 0){ |
| | | for (TCoursePackagePayment tCoursePackagePayment : list) { |
| | | TCoursePackage tCoursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId()); |
| | | // 获取课程有效结束时间,判断 查询的日期parse 是否在有效期范围内 |
| | | Date expirationDate = DateTimeHelper.getExpirationDate(tCoursePackagePayment.getInsertTime(),tCoursePackage.getValidDays()); |
| | | String classWeeks = tCoursePackage.getClassWeeks(); |
| | | if (expirationDate.after(parse) && StrUtils.dealStrToList(classWeeks).contains(DateTimeHelper.getDayOfWeek(parse))){ |
| | | CourseOfStoreVo storeVo = new CourseOfStoreVo(); |
| | | storeVo.setCourseId(tCoursePackage.getId()); |
| | | // TODO: 2023/7/20 查询课包对应门店信息 |
| | | // storeVo.setCourseName(); |
| | | // storeVo.setClassStartTime(); |
| | | // storeVo.setClassEndTime(); |
| | | // storeVo.setStoreId(); |
| | | // storeVo.setStoreName(); |
| | | // storeVo.setLat(); |
| | | // storeVo.setLon(); |
| | | course.add(storeVo); |
| | | } |
| | | } |
| | | courseOfStoreVo.setClassWeekList(integers); |
| | | } |
| | | return course; |
| | | } catch (ParseException e) { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | * 课程名称列表 |
| | | */ |
| | | @PostMapping("/base/coursePack/sessionNames") |
| | | public List<StuSessionDetailsVo> getStuSessionList(@RequestBody CourseDetailRequest request){ |
| | | List<StuSessionDetailsVo> detailsVos = new ArrayList<>(); |
| | | List<TCoursePackagePayment> byUserId = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .between("insertTime", request.getStartTime(),request.getEndTime()) |
| | | .eq("appUserId",request.getAppUserId()) |
| | | .eq("studentId",request.getStuId())); |
| | | 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; |
| | | } |
| | | |
| | | @PostMapping("/base/coursePack/paymentCourse") |
| | | public List<PurchaseRecordVo> queryCourseDetails(@RequestParam("startTime") Date startTime, @RequestParam("endTime") Date endTime,@RequestParam("stuId") Integer stuId, @RequestParam("appUserId") Integer appUserId) { |
| | | List<PurchaseRecordVo> purchaseRecordVos = new ArrayList<>(); |
| | | |
| | | List<TCoursePackagePayment> coursePackage = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .between("insertTime", startTime,endTime) |
| | | .eq("appUserId",appUserId) |
| | | .eq("studentId",stuId)); |
| | | if (coursePackage.size() > 0 ){ |
| | | coursePackage.forEach( cspackage -> { |
| | | PurchaseRecordVo recordVo = new PurchaseRecordVo(); |
| | | recordVo.setPurchaseAmount("+"+cspackage.getClassHours()); |
| | | recordVo.setPurchaseTime(format.format(cspackage.getInsertTime())); |
| | | recordVo.setPurchaseType("购买课包"); |
| | | purchaseRecordVos.add(recordVo); |
| | | }); |
| | | } |
| | | return purchaseRecordVos; |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/base/coursePack/stuOfCourses") |
| | | public StuWithCoursesListVo getStuOfCoursesDetails(@RequestBody GetStuOfCoursesDetails getStuOfCoursesDetails){ |
| | | StuWithCoursesListVo lisco = new StuWithCoursesListVo(); |
| | | Integer totalNu = 0; |
| | | Integer dedutNu = 0; |
| | | Integer remainNu = 0; |
| | | List<TCoursePackagePayment> byUserId = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("appUserId",getStuOfCoursesDetails.getAppUserId()) |
| | | .eq("studentId",getStuOfCoursesDetails.getStuId())); |
| | | if (byUserId.size() > 0 ){ |
| | | for (TCoursePackagePayment tCoursePackagePayment : byUserId) { |
| | | totalNu = totalNu + tCoursePackagePayment.getTotalClassHours(); |
| | | dedutNu = dedutNu + tCoursePackagePayment.getLaveClassHours(); |
| | | remainNu = remainNu + (tCoursePackagePayment.getTotalClassHours()-tCoursePackagePayment.getLaveClassHours()); |
| | | } |
| | | lisco.setTotalNums(totalNu); |
| | | lisco.setDeductedNums(remainNu); |
| | | lisco.setRemainingNums(dedutNu); |
| | | } |
| | | return lisco; |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/base/coursePack/continuingCourse") |
| | | public StudentOfCourseVo getStudentCourse(@RequestBody GetStudentCourse getStudentCourse){ |
| | | StudentOfCourseVo courseVo = new StudentOfCourseVo(); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("appUserId", getStudentCourse.getAppUserId()) |
| | | .eq("coursePackageId", getStudentCourse.getCourseId()) |
| | | .eq("studentId", getStudentCourse.getStuId())); |
| | | if (tCoursePackagePayments.size() > 0 ){ |
| | | |
| | | List<CourseHoursType> typeList = new ArrayList<>(); |
| | | tCoursePackagePayments.forEach(cou -> { |
| | | CourseHoursType hoursType = new CourseHoursType(); |
| | | hoursType.setCourseConfigId(cou.getId()); |
| | | hoursType.setCourseHourNums(cou.getClassHours()); |
| | | typeList.add(hoursType); |
| | | }); |
| | | TCoursePackagePayment tCoursePackagePayment = tCoursePackagePayments.get(0); |
| | | courseVo.setCoursePackageId(tCoursePackagePayment.getCoursePackageId()); |
| | | courseVo.setTypeList(typeList); |
| | | |
| | | TCoursePackage coursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId()); |
| | | courseVo.setPackageImg(coursePackage.getCoverDrawing()); |
| | | courseVo.setCourseName(coursePackage.getName()); |
| | | courseVo.setCoachId(coursePackage.getCoachId()); |
| | | String classWeeks = coursePackage.getClassWeeks(); |
| | | List<Integer> integers = StrUtils.dealStrToList(classWeeks); |
| | | if (integers.size() > 0){ |
| | | StringBuilder courWeeks = new StringBuilder("每"); |
| | | for (Integer integer : integers) { |
| | | switch (integer){ |
| | | case 1: |
| | | courWeeks.append("周一、"); |
| | | break; |
| | | case 2: |
| | | courWeeks.append("周二、"); |
| | | break; |
| | | case 3: |
| | | courWeeks.append("周三、"); |
| | | break; |
| | | case 4: |
| | | courWeeks.append("周四、"); |
| | | break; |
| | | case 5: |
| | | courWeeks.append("周五、"); |
| | | break; |
| | | case 6: |
| | | courWeeks.append("周六、"); |
| | | break; |
| | | case 7: |
| | | courWeeks.append("周末、"); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | if (courWeeks.length() > 0 && courWeeks.charAt(courWeeks.length() - 1) == ','){ |
| | | courWeeks.deleteCharAt(courWeeks.length() - 1); |
| | | } |
| | | courseVo.setCourseWeek(courWeeks.toString()); |
| | | } |
| | | |
| | | courseVo.setCourseTime(coursePackage.getClassStartTime()+"-"+coursePackage.getClassEndTime()); |
| | | Integer payType = tCoursePackagePayment.getPayType(); |
| | | BigDecimal cashPayment = tCoursePackagePayment.getCashPayment(); |
| | | double cashPaymentValue = cashPayment.doubleValue(); |
| | | Integer playPaiCoin = tCoursePackagePayment.getPlayPaiCoin(); |
| | | TCoursePackageDiscount coursePackageDiscount = tcpdService.getOne(new QueryWrapper<TCoursePackageDiscount>() |
| | | .eq("coursePackageId",coursePackage.getId() ) |
| | | .eq("type",1) |
| | | .eq("auditStatus",2)); |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | String content = coursePackageDiscount.getContent(); |
| | | double discountMember = 0.0; |
| | | DiscountJsonDto discountJsonDto = null; |
| | | try { |
| | | discountJsonDto = objectMapper.readValue(content, DiscountJsonDto.class); |
| | | discountMember = discountJsonDto.getDiscountMember(); |
| | | } catch (JsonProcessingException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | switch (payType) { |
| | | case 1: |
| | | case 2: |
| | | courseVo.setAmount(cashPaymentValue); |
| | | courseVo.setVipAmount(discountMember); |
| | | break; |
| | | case 3: |
| | | courseVo.setWpGold(playPaiCoin); |
| | | break; |
| | | } |
| | | courseVo.setStoreId(coursePackage.getStoreId()); |
| | | } |
| | | |
| | | return courseVo; |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/coursePack/afterCourseTwos") |
| | | public List<AfterVideoVo> getAfterCourseTwos(@RequestParam("appUserId") Integer appUserId){ |
| | | List<AfterVideoVo> videoVos = new ArrayList<>(); |
| | | List<UserVideoDetails> list = uvdsService.list(new QueryWrapper<UserVideoDetails>() |
| | | .eq("appUserId",appUserId) |
| | | .eq("state",1)); |
| | | if (list.size() > 0 ){ |
| | | List<Integer> courseIds = list.stream().map(UserVideoDetails::getCourseId).collect(Collectors.toList()); |
| | | List<TCourse> courseList = tcService.list(new QueryWrapper<TCourse>() |
| | | .in("id",courseIds) |
| | | .eq("type",1) |
| | | .eq("state",1) |
| | | .last("ORDER BY insertTime desc LIMIT 2")); |
| | | for (TCourse tCourse : courseList) { |
| | | AfterVideoVo videoVo = new AfterVideoVo(); |
| | | videoVo.setCourseId(tCourse.getId()); |
| | | videoVo.setCourseUrl(tCourse.getCourseVideo()); |
| | | videoVos.add(videoVo); |
| | | } |
| | | } |
| | | return tcpService.queryStoreOfCourse(); |
| | | return videoVos; |
| | | } |
| | | |
| | | @PostMapping("/base/coursePack/allPaymentCourseList") |
| | | public List<TCoursePackagePayment> getAppuserCourseList(@RequestBody Integer appUserId){ |
| | | return packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("appUserId",appUserId) |
| | | .eq("payType",3) |
| | | .eq("payStatus",2) |
| | | .eq("state",1)); |
| | | } |
| | | |
| | | @PostMapping("/base/coursePack/allAmountPayRecordOfUser") |
| | | public List<TCoursePackagePayment> getAmountPayRecord(@RequestBody Integer appUserId){ |
| | | return packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("appUserId",appUserId) |
| | | .notIn("payType",3) |
| | | .eq("payStatus",2) |
| | | .eq("state",1)); |
| | | } |
| | | |
| | | |
| | | @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.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("appUserId",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( CourseOfAfterRequest search){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<Integer> courseIds = new ArrayList<>(); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("coursePackageId",search.getCourseTypeId()) |
| | | .eq("appUserId",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( 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( 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( 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/RegisteredData") |
| | | @ApiOperation(value = "已报名课程详情", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(name = "coursePayId" ,value = "课包记录id",dataType = "long"), |
| | | }) |
| | | public ResultUtil<CourseDetailsResponse> getRegisteredData( Integer coursePayId){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return ResultUtil.success(packagePaymentService.queryRegisteredCourseDetails(coursePayId,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(ClasspaymentRequest request){ |
| | | try { |
| | | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); |
| | | if(null == userIdFormRedis){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | return packagePaymentService.ContinuationOrpaymentCourse(userIdFormRedis,request); |
| | | }catch (Exception e){ |
| | | return ResultUtil.runErr(); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 课包续课支付宝支付回调接口 |
| | | */ |
| | | @PostMapping("/base/coursePackage/alipayRegisteredCoursesCallback") |
| | | public void alipayCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | try { |
| | | Map<String, String> map = payMoneyUtil.alipayCallback(request); |
| | | if(null != map){ |
| | | String out_trade_no = map.get("out_trade_no"); |
| | | String transaction_id = map.get("transaction_id"); |
| | | ResultUtil resultUtil = packagePaymentService.insertVipPaymentCallback(out_trade_no, transaction_id); |
| | | if(resultUtil.getCode() == 200){ |
| | | PrintWriter out = response.getWriter(); |
| | | out.write("success"); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课包续课微信支付回调接口 |
| | | */ |
| | | @PostMapping("/base/coursePackage/wechatRegisteredCoursesCallback") |
| | | public void weChatCallback(HttpServletRequest request, HttpServletResponse response){ |
| | | try { |
| | | Map<String, String> map = payMoneyUtil.weixinpayCallback(request); |
| | | if(null != map){ |
| | | String out_trade_no = map.get("out_trade_no"); |
| | | String transaction_id = map.get("transaction_id"); |
| | | String result = map.get("result"); |
| | | ResultUtil resultUtil = packagePaymentService.insertVipPaymentCallback(out_trade_no, transaction_id); |
| | | if(resultUtil.getCode() == 200){ |
| | | PrintWriter out = response.getWriter(); |
| | | out.write(result); |
| | | out.flush(); |
| | | out.close(); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取学员剩余课时 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/coursePackagePayment/queryResidueClassHour") |
| | | public Integer queryResidueClassHour(@RequestBody Integer id){ |
| | | try { |
| | | List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("studentId", id).eq("payStatus", 2) |
| | | .eq("status", 1).eq("state", 1).gt("laveClassHours", 0)); |
| | | Integer total = 0; |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | total += coursePackagePayment.getLaveClassHours(); |
| | | } |
| | | return total; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课程用于支付进行扣减 |
| | | * @param paymentDeductionClassHour |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/coursePackagePayment/paymentDeductionClassHour") |
| | | public void paymentDeductionClassHour(@RequestBody PaymentDeductionClassHour paymentDeductionClassHour){ |
| | | try { |
| | | List<TCoursePackagePayment> list = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>().eq("studentId", paymentDeductionClassHour.getId()).eq("payStatus", 2) |
| | | .eq("status", 1).eq("state", 1).gt("laveClassHours", 0)); |
| | | Integer classHour = paymentDeductionClassHour.getClassHour(); |
| | | for (TCoursePackagePayment coursePackagePayment : list) { |
| | | if(coursePackagePayment.getLaveClassHours().compareTo(classHour) >= 0){ |
| | | coursePackagePayment.setLaveClassHours(coursePackagePayment.getLaveClassHours() - classHour); |
| | | packagePaymentService.updateById(coursePackagePayment); |
| | | |
| | | CancelledClasses cancelledClasses = new CancelledClasses(); |
| | | cancelledClasses.setType(2); |
| | | cancelledClasses.setVoucher(paymentDeductionClassHour.getCode()); |
| | | cancelledClasses.setCoursePackageId(coursePackagePayment.getCoursePackageId()); |
| | | cancelledClasses.setCoursePackagePaymentId(coursePackagePayment.getId()); |
| | | cancelledClasses.setCancelledClassesNumber(classHour); |
| | | cancelledClasses.setInsertTime(new Date()); |
| | | cancelledClassesService.save(cancelledClasses); |
| | | break; |
| | | }else{ |
| | | CancelledClasses cancelledClasses = new CancelledClasses(); |
| | | cancelledClasses.setType(2); |
| | | cancelledClasses.setVoucher(paymentDeductionClassHour.getCode()); |
| | | cancelledClasses.setCoursePackageId(coursePackagePayment.getCoursePackageId()); |
| | | cancelledClasses.setCoursePackagePaymentId(coursePackagePayment.getId()); |
| | | cancelledClasses.setCancelledClassesNumber(coursePackagePayment.getLaveClassHours()); |
| | | cancelledClasses.setInsertTime(new Date()); |
| | | cancelledClassesService.save(cancelledClasses); |
| | | |
| | | coursePackagePayment.setLaveClassHours(0); |
| | | packagePaymentService.updateById(coursePackagePayment); |
| | | |
| | | classHour -= cancelledClasses.getCancelledClassesNumber(); |
| | | } |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 取消赛事回退支付课时 |
| | | * @param paymentDeductionClassHour |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/coursePackagePayment/rollbackPaymentDeductionClassHour") |
| | | public void rollbackPaymentDeductionClassHour(@RequestBody PaymentDeductionClassHour paymentDeductionClassHour){ |
| | | try { |
| | | List<CancelledClasses> voucher = cancelledClassesService.list(new QueryWrapper<CancelledClasses>().eq("voucher", paymentDeductionClassHour.getCode())); |
| | | for (CancelledClasses cancelledClasses : voucher) { |
| | | TCoursePackagePayment coursePackagePayment = packagePaymentService.getById(cancelledClasses.getCoursePackagePaymentId()); |
| | | coursePackagePayment.setLaveClassHours(coursePackagePayment.getLaveClassHours() + cancelledClasses.getCancelledClassesNumber()); |
| | | packagePaymentService.updateById(coursePackagePayment); |
| | | |
| | | cancelledClassesService.removeById(cancelledClasses.getId()); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 课包续费玩湃币支付 |
| | | * @param |
| | | */ |
| | | @PostMapping("/coursePackagePayment/courseRenewPlayPaiPay") |
| | | public int paymentWanpaiRenewCourse(@RequestBody PlayPaiGoldCoursePackage coursePackage){ |
| | | try { |
| | | Integer userIdFormRedis = tokenUtil.getUserIdFormRedis(); |
| | | if (null == userIdFormRedis){ |
| | | return 2; |
| | | } |
| | | CoursePackagePaymentConfig paymentConfig = icppcService.getById(coursePackage.getCoursePayConfigId()); |
| | | AppUser appUser = auClitn.queryAppUser(userIdFormRedis); |
| | | if (appUser.getPlayPaiCoins() < paymentConfig.getPlayPaiCoin()){ |
| | | return 3; |
| | | } |
| | | TCoursePackagePayment packagePayment = packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("code",coursePackage.getCode() )); |
| | | packagePayment.setPayStatus(2); |
| | | packagePayment.setPayUserId(userIdFormRedis); |
| | | packagePayment.setClassHours(paymentConfig.getClassHours()); |
| | | packagePayment.setPlayPaiCoin(paymentConfig.getPlayPaiCoin()); |
| | | packagePayment.setTotalClassHours(paymentConfig.getClassHours()); |
| | | packagePayment.setLaveClassHours(paymentConfig.getClassHours()); |
| | | packagePaymentService.updateById(packagePayment); |
| | | |
| | | appUser.setPlayPaiCoins(appUser.getPlayPaiCoins()-paymentConfig.getPlayPaiCoin()); |
| | | auClitn.updateAppUser(appUser); |
| | | } catch (Exception e) { |
| | | return 4; |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | @PostMapping("/base/coursePack/getPaymentCoursePackage") |
| | | public TCoursePackagePayment getCoursePackagePaymentByCode(@RequestBody String code){ |
| | | return packagePaymentService.getOne(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("code",code)); |
| | | } |
| | | |
| | | @PostMapping("/base/coursePack/delPaymentCoursePackage") |
| | | public boolean delPaymentCoursePackage(@RequestBody Integer payId){ |
| | | return packagePaymentService.removeById(payId); |
| | | } |
| | | @PostMapping("/base/coursePack/updatePaymentCoursePackage") |
| | | public boolean updatePaymentCoursePackage(@RequestBody TCoursePackagePayment packagePayment){ |
| | | return packagePaymentService.update(packagePayment,new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("id",packagePayment.getId())); |
| | | } |
| | | |
| | | @PostMapping("/base/coursePack/savePaymentCoursePackage") |
| | | public boolean savePaymentCoursePackage(@RequestBody TCoursePackagePayment packagePayment){ |
| | | return packagePaymentService.save(packagePayment); |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/coursePack/obtainStudentClassDetails") |
| | | public List<RecordAppoint> obtainStudentClassDetailsData(@RequestBody Integer stuId){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | return packagePaymentService.obtainStuClassDetails(stuId,appUserId); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | throw new RuntimeException(); |
| | | } |
| | | } |
| | | |
| | | |
| | | @PostMapping("/base/coursePack/getCoursePackageConfig") |
| | | public List<CoursePackagePaymentConfig> getCourseConfigList(@RequestBody Integer coursePackageId){ |
| | | return icppcService.list(new QueryWrapper<CoursePackagePaymentConfig>() |
| | | .eq("coursePackageId",coursePackageId)); |
| | | } |
| | | |
| | | |
| | | |
| | | @PostMapping("/base/coursePack/getCoursePackagePaymentOfCode") |
| | | public List<TCoursePackagePayment> getCoursePackagePaymentOfCode(@RequestBody String code){ |
| | | return packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("code",code)); |
| | | } |
| | | |
| | | } |