| | |
| | | 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; |
| | | |
| | | @Autowired |
| | | private CancelledClassesService cacService; |
| | | |
| | | @Autowired |
| | | private ICoursePackagePaymentConfigService icppcService; |
| | |
| | | private CancelledClassesService cancelledClassesService; |
| | | |
| | | @Autowired |
| | | private AppUserClient appuClient; |
| | | private PayMoneyUtil payMoneyUtil; |
| | | @Resource |
| | | private AppUserClient auClitn; |
| | | |
| | | private final SimpleDateFormat format = new SimpleDateFormat("MM-dd HH:mm"); |
| | | |
| | |
| | | * 获取发布的 课包列表 |
| | | */ |
| | | @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(); |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/api/course/queryArrangeCourseList") |
| | | @ApiOperation(value = "获取布置课程列表", tags = {"APP-课程列表"}) |
| | | @ApiOperation(value = "课后练习-获取布置课程列表", tags = {"APP-开始上课"}) |
| | | @ApiImplicitParams({ |
| | | }) |
| | | public ResultUtil<List<BaseVo>> queryArrangePackageType(){ |
| | |
| | | */ |
| | | @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....."), |
| | | }) |
| | |
| | | */ |
| | | @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....."), |
| | | }) |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 课包续课支付宝支付回调接口 |
| | | */ |
| | | @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 2; |
| | | } |
| | | CoursePackagePaymentConfig paymentConfig = icppcService.getById(coursePackage.getCoursePayConfigId()); |
| | | AppUser appUser = appuClient.queryAppUser(userIdFormRedis); |
| | | AppUser appUser = auClitn.queryAppUser(userIdFormRedis); |
| | | if (appUser.getPlayPaiCoins() < paymentConfig.getPlayPaiCoin()){ |
| | | return 3; |
| | | } |
| | |
| | | packagePaymentService.updateById(packagePayment); |
| | | |
| | | appUser.setPlayPaiCoins(appUser.getPlayPaiCoins()-paymentConfig.getPlayPaiCoin()); |
| | | appuClient.updateAppUser(appUser); |
| | | auClitn.updateAppUser(appUser); |
| | | } catch (Exception e) { |
| | | return 4; |
| | | } |
| | |
| | | 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)); |
| | | } |
| | | |
| | | } |