| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | 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.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.CourseOfAfterRequest; |
| | | import com.dsh.course.model.vo.request.CourseWithDetailsRequest; |
| | | import com.dsh.course.model.vo.request.UpdateCourseVideoStatusRequest; |
| | | 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.DateUtil; |
| | | import com.dsh.course.util.ResultUtil; |
| | | import com.dsh.course.util.StrUtils; |
| | | import com.dsh.course.util.TokenUtil; |
| | | import com.dsh.course.util.*; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import io.swagger.annotations.Api; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | 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.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Api |
| | |
| | | @Autowired |
| | | private TCoursePackageDiscountService tcpdService; |
| | | |
| | | @Autowired |
| | | private PostCourseVideoService pcvService; |
| | | |
| | | @Autowired |
| | | private CoursePackageStudentService cpsService; |
| | | private ICoursePackagePaymentConfigService icppcService; |
| | | |
| | | @Autowired |
| | | private CancelledClassesService cacService; |
| | | 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"); |
| | | |
| | |
| | | @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(null,null,null,stuId,appUserId); |
| | | 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("/base/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); |
| | | 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; |
| | | } |
| | | return tcpService.queryStoreOfCourse(); |
| | | } |
| | | |
| | | |
| | |
| | | @PostMapping("/base/coursePack/sessionNames") |
| | | public List<StuSessionDetailsVo> getStuSessionList(@RequestBody CourseDetailRequest request){ |
| | | List<StuSessionDetailsVo> detailsVos = new ArrayList<>(); |
| | | List<TCoursePackagePayment> byUserId = packagePaymentService.queryAllCoursePackage(request.getStartTime(),request.getEndTime(),null,request.getStuId(),request.getAppUserId()); |
| | | 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>() |
| | |
| | | @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.queryAllCoursePackage(startTime,endTime,null,stuId, appUserId); |
| | | |
| | | 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(); |
| | |
| | | Integer totalNu = 0; |
| | | Integer dedutNu = 0; |
| | | Integer remainNu = 0; |
| | | List<TCoursePackagePayment> byUserId = packagePaymentService.queryAllCoursePackage(null,null,null,getStuOfCoursesDetails.getStuId(),getStuOfCoursesDetails.getAppUserId()); |
| | | 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(); |
| | |
| | | @PostMapping("/base/coursePack/continuingCourse") |
| | | public StudentOfCourseVo getStudentCourse(@RequestBody GetStudentCourse getStudentCourse){ |
| | | StudentOfCourseVo courseVo = new StudentOfCourseVo(); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.queryAllCoursePackage(null,null,getStudentCourse.getCourseId(),getStudentCourse.getStuId(),getStudentCourse.getAppUserId()); |
| | | 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<>(); |
| | |
| | | @PostMapping("/base/coursePack/afterCourseTwos") |
| | | public List<AfterVideoVo> getAfterCourseTwos(@RequestParam("appUserId") Integer appUserId){ |
| | | List<AfterVideoVo> videoVos = new ArrayList<>(); |
| | | 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 两个课后视频 |
| | | 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 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-课程列表"}) |
| | | @ApiOperation(value = "课后练习-获取布置课程列表", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil<List<BaseVo>> queryArrangePackageType(){ |
| | |
| | | if(null == appUserId){ |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.queryAllCoursePackage(null,null,null,null,appUserId); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.list(new QueryWrapper<TCoursePackagePayment>() |
| | | .eq("appUserId",appUserId)); |
| | | List<BaseVo> list = new ArrayList<>(); |
| | | tCoursePackagePayments.forEach(c -> { |
| | | BaseVo baseVo = new BaseVo(); |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/afterSourceList") |
| | | @ApiOperation(value = "课后视频课表", tags = {"APP-开始上课"}) |
| | | @ApiOperation(value = "课后练习-课后视频列表", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(name = "search",value = "视频名称", required = true, dataType = "int"), |
| | | }) |
| | | public ResultUtil<List<AppUserVideoResponse>> queryAfterSourceList(@RequestBody CourseOfAfterRequest search){ |
| | | public ResultUtil<List<AppUserVideoResponse>> queryAfterSourceList( CourseOfAfterRequest search){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | |
| | |
| | | return ResultUtil.tokenErr(); |
| | | } |
| | | List<Integer> courseIds = new ArrayList<>(); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.queryAllCoursePackage(null,null,search.getCourseTypeId(),null,appUserId); |
| | | 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()); |
| | | } |
| | |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/api/startCource/afterSourceDetail") |
| | | @ApiOperation(value = "课后视频详情", tags = {"APP-开始上课"}) |
| | | @ApiOperation(value = "课后练习-课后视频详情", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(name = "search",value = "视频名称", required = true, dataType = "int"), |
| | | }) |
| | | public ResultUtil<CourseOfVideoResponse> queryAfterSourceDetails(@RequestBody CourseWithDetailsRequest detailsRequest){ |
| | | public ResultUtil<CourseOfVideoResponse> queryAfterSourceDetails( CourseWithDetailsRequest detailsRequest){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | |
| | | @ApiOperation(value = "更新课后视频学习状态", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | @ApiImplicitParam(name = "search",value = "视频名称", required = true, dataType = "int"), |
| | | }) |
| | | public ResultUtil updateVideoStatus(@RequestBody UpdateCourseVideoStatusRequest detailsRequest){ |
| | | public ResultUtil updateVideoStatus( UpdateCourseVideoStatusRequest detailsRequest){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | |
| | | } |
| | | } |
| | | |
| | | // |
| | | // @PostMapping("/base/coursePack/courseOfPurchased") |
| | | // public List<PurchaseVo> getAppUsersCourseData(@RequestBody Integer appUserId){ |
| | | // List<PurchaseVo> voList = new ArrayList<>(); |
| | | //// 查询够课包记录 |
| | | // List<TCoursePackagePayment> tCoursePackagePayments = packagePaymentService.queryAllCoursePackage(null,null,null,null,appUserId); |
| | | // //查询上课记录 |
| | | // List<Integer> coursePackageIds = tCoursePackagePayments.stream().map(TCoursePackagePayment::getCoursePackageId).collect(Collectors.toList()); |
| | | // List<CoursePackageStudent> packageStudents = cpsService.queryAppUserOfStuAttendClass(appUserId,coursePackageIds); |
| | | // Map<Integer, Long> collect = packageStudents.stream() |
| | | // .collect(Collectors.groupingBy(CoursePackageStudent::getCoursePackageId, Collectors.counting())); |
| | | // |
| | | // if (tCoursePackagePayments.size() > 0){ |
| | | // for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | | // TCoursePackage coursePackage = tcpService.getById(tCoursePackagePayment.getCoursePackageId()); |
| | | // PurchaseVo purchaseVo = new PurchaseVo(); |
| | | // purchaseVo.setCourseId(tCoursePackagePayment.getCoursePackageId()); |
| | | // purchaseVo.setCourseName(coursePackage.getName()); |
| | | // purchaseVo.setCourseTime(coursePackage.getClassStartTime()+"-"+coursePackage.getClassEndTime()); |
| | | // purchaseVo.setStoreId(coursePackage.getStoreId()); |
| | | // purchaseVo.setTeacherId(coursePackage.getCoachId()); |
| | | // purchaseVo.setPackageImg(coursePackage.getCoverDrawing()); |
| | | // purchaseVo.setCourseStatus(tCoursePackagePayment.getPayStatus()); |
| | | // purchaseVo.setCourseTypeId(coursePackage.getCoursePackageTypeId()); |
| | | // for (Map.Entry<Integer, Long> entry : collect.entrySet()) { |
| | | // int coursePackageId = entry.getKey(); |
| | | // if (tCoursePackagePayment.getCoursePackageId() == coursePackageId) { |
| | | // purchaseVo.setCourseNums((int) (entry.getValue()*2)); |
| | | // } |
| | | // } |
| | | // voList.add(purchaseVo); |
| | | // } |
| | | // } |
| | | // return voList; |
| | | // } |
| | | |
| | | |
| | | /** |
| | | * 已报名课程列表 |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |
| | | }) |
| | | public ResultUtil<List<RegisterCourseVo>> queryRegisteredCoursesDetails(@RequestBody CourseOfAfterRequest courseTypeId){ |
| | | public ResultUtil<List<RegisterCourseVo>> queryRegisteredCoursesDetails( CourseOfAfterRequest courseTypeId){ |
| | | try { |
| | | Integer appUserId = tokenUtil.getUserIdFormRedis(); |
| | | if(null == appUserId){ |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 已报名课程详情 |
| | | */ |
| | | @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)); |
| | | } |
| | | |
| | | } |