| | |
| | | package com.dsh.course.service.impl; |
| | | |
| | | import com.dsh.course.entity.TCoursePackagePayment; |
| | | import com.dsh.course.mapper.TCoursePackagePaymentMapper; |
| | | import com.dsh.course.service.TCoursePackagePaymentService; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.dsh.course.entity.*; |
| | | import com.dsh.course.feignclient.account.CoachClient; |
| | | import com.dsh.course.feignclient.account.model.Coach; |
| | | import com.dsh.course.feignclient.activity.BenefitVideoClient; |
| | | import com.dsh.course.feignclient.activity.model.BenefitsVideos; |
| | | import com.dsh.course.feignclient.other.StoreClient; |
| | | import com.dsh.course.feignclient.other.model.Store; |
| | | import com.dsh.course.mapper.*; |
| | | 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.TCoursePackagePaymentService; |
| | | import com.dsh.course.util.ResultUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class TCoursePackagePaymentServiceImpl extends ServiceImpl<TCoursePackagePaymentMapper, TCoursePackagePayment> implements TCoursePackagePaymentService { |
| | | |
| | | |
| | | @Autowired |
| | | private BenefitVideoClient bfvoClient; |
| | | |
| | | |
| | | @Autowired |
| | | private UserVideoDetailsMapper uvdmapper; |
| | | |
| | | @Autowired |
| | | private PostCourseVideoMapper pcvMapper; |
| | | |
| | | @Autowired |
| | | private TCoursePackageMapper tcpmapper; |
| | | |
| | | @Autowired |
| | | private StoreClient stoClient; |
| | | |
| | | @Autowired |
| | | private CoachClient coachClient; |
| | | |
| | | @Autowired |
| | | private CoursePackageStudentMapper cpsMapper; |
| | | |
| | | @Autowired |
| | | private CancelledClassesMapper cacMapper; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<TCoursePackagePayment> queryAllCoursePackage(Integer stuId,Integer appUserId) { |
| | | return this.baseMapper.queryAllCoursePackage(stuId,appUserId); |
| | | public List<TCoursePackagePayment> queryAllCoursePackage(Date startTime, Date endTime , Integer coursePackId, Integer stuId, Integer appUserId) { |
| | | return this.baseMapper.queryAllCoursePackage(startTime,endTime,coursePackId,stuId,appUserId); |
| | | } |
| | | |
| | | /** |
| | | * 获取课包购买人数 |
| | | * @param coursePackageId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Integer queryCountNumber(Integer coursePackageId) { |
| | | return this.baseMapper.queryCountNumber(coursePackageId); |
| | | } |
| | | |
| | | @Override |
| | | public List<AppUserVideoResponse> queryAfterVideo(CourseOfAfterRequest search,List<Integer> courseIds) { |
| | | List<AppUserVideoResponse> responses = new ArrayList<>(); |
| | | List<PostCourseVideo> videoList = pcvMapper.queryPostCourseVideolist(courseIds); |
| | | if (videoList.size() > 0){ |
| | | List<Integer> videoIds = videoList.stream().map(PostCourseVideo::getCourseId).collect(Collectors.toList()); |
| | | List<UserVideoDetails> userVideoDetails = uvdmapper.queryAppUserWatchVideo(videoIds); |
| | | if (userVideoDetails.size() > 0){ |
| | | for (UserVideoDetails userVideoDetail : userVideoDetails) { |
| | | AppUserVideoResponse response = new AppUserVideoResponse(); |
| | | TCoursePackage coursePackage = tcpmapper.selectById(userVideoDetail.getCoursePackageId()); |
| | | response.setPackageName(coursePackage.getName()); |
| | | response.setCoursePackageId(userVideoDetail.getCoursePackageId()); |
| | | BenefitsVideos videosWithIds = bfvoClient.getVideosWithIds(userVideoDetail.getCourseId()); |
| | | response.setVideoId(userVideoDetail.getCourseId()); |
| | | response.setCoverImage(videosWithIds.getCover()); |
| | | if (null != search.getSearch()){ |
| | | // 根据正则模糊匹配 |
| | | String pattern = ".*" + search.getSearch() + ".*"; |
| | | Pattern regex = Pattern.compile(pattern); |
| | | Matcher matcher = regex.matcher(videosWithIds.getName()); |
| | | if (matcher.matches()) { |
| | | response.setVideoName(videosWithIds.getName()); |
| | | } |
| | | }else { |
| | | response.setVideoName(videosWithIds.getName()); |
| | | } |
| | | response.setSynopsis(videosWithIds.getIntroduction()); |
| | | response.setIntegral(videosWithIds.getIntegral()); |
| | | response.setStudyStatus(userVideoDetail.getState()); |
| | | responses.add(response); |
| | | } |
| | | Collections.sort(responses, Comparator.comparing(AppUserVideoResponse::getStudyStatus)); |
| | | } |
| | | } |
| | | return responses; |
| | | } |
| | | |
| | | @Override |
| | | public CourseOfVideoResponse queryVideoDetails(CourseWithDetailsRequest detailsRequest,Integer appUserId) { |
| | | CourseOfVideoResponse response = new CourseOfVideoResponse(); |
| | | BenefitsVideos videosWithIds = bfvoClient.getVideosWithIds(detailsRequest.getVideoId()); |
| | | TCoursePackage coursePackage = tcpmapper.selectById(detailsRequest.getCoursePackageId()); |
| | | if (null != videosWithIds && null != coursePackage){ |
| | | response.setCoursePackageId(coursePackage.getId()); |
| | | response.setVideoId(videosWithIds.getId()); |
| | | response.setVideoURL(videosWithIds.getVideos()); |
| | | response.setVideoName(videosWithIds.getName()); |
| | | response.setIntegral(videosWithIds.getIntegral()); |
| | | UserVideoDetails userVideoDetails = uvdmapper.selectOne(new QueryWrapper<UserVideoDetails>() |
| | | .eq("appUserId",appUserId ) |
| | | .eq("coursePackageId",coursePackage.getId()) |
| | | .eq("courseId",videosWithIds.getId())); |
| | | |
| | | response.setStudyStatus(userVideoDetails.getState()); |
| | | response.setPackageName(coursePackage.getName()); |
| | | response.setSynopsis(videosWithIds.getIntroduction()); |
| | | response.setDetailedDiagram(coursePackage.getIntroduceDrawing()); |
| | | } |
| | | |
| | | return response; |
| | | } |
| | | |
| | | @Override |
| | | public String updateVideoStatus(UpdateCourseVideoStatusRequest detailsRequest, Integer appUserId) { |
| | | UserVideoDetails userVideoDetails = uvdmapper.selectOne(new QueryWrapper<UserVideoDetails>() |
| | | .eq("appUserId",appUserId ) |
| | | .eq("coursePackageId",detailsRequest.getCoursePackageId()) |
| | | .eq("courseId",detailsRequest.getVideoId()) |
| | | ); |
| | | if (null != userVideoDetails && userVideoDetails.getState() ==1 && detailsRequest.getIsOver() == 1){ |
| | | userVideoDetails.setState(2); |
| | | userVideoDetails.setUpdateTime(new Date()); |
| | | uvdmapper.updateById(userVideoDetails); |
| | | return "SUCCESS"; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public List<RegisterCourseVo> queryRegisteredCourseList(CourseOfAfterRequest courseTypeId, Integer appUserId) { |
| | | List<RegisterCourseVo> courseVos = new ArrayList<>(); |
| | | List<TCoursePackagePayment> tCoursePackagePayments = this.queryAllCoursePackage(null,null,null,null,appUserId); |
| | | if (tCoursePackagePayments.size() > 0){ |
| | | for (TCoursePackagePayment tCoursePackagePayment : tCoursePackagePayments) { |
| | | TCoursePackage coursePackage = tcpmapper.selectById(tCoursePackagePayment.getCoursePackageId()); |
| | | Store store = stoClient.queryStoreById(coursePackage.getStoreId()); |
| | | RegisterCourseVo registerCourseVo = new RegisterCourseVo(); |
| | | registerCourseVo.setCoursePackageId(tCoursePackagePayment.getCoursePackageId()); |
| | | registerCourseVo.setPackageImg(coursePackage.getCoverDrawing()); |
| | | String storeAndCourse = coursePackage.getName()+"("+ store.getName() +")"; |
| | | registerCourseVo.setCourseNameStore(storeAndCourse); |
| | | registerCourseVo.setCourseTime(coursePackage.getClassStartTime()+"-"+coursePackage.getClassEndTime()); |
| | | Coach coach = coachClient.queryCoachById(coursePackage.getCoachId()); |
| | | registerCourseVo.setCourseTeacher(coach.getName()); |
| | | List<CoursePackageStudent> coursePackageStudents = |
| | | cpsMapper.queryStuDeduClassHourNums(coursePackage.getId(),null,appUserId); |
| | | registerCourseVo.setCourseNums(coursePackageStudents.size() * 2); |
| | | registerCourseVo.setPayStatus(tCoursePackagePayment.getPayStatus()); |
| | | courseVos.add(registerCourseVo); |
| | | } |
| | | } |
| | | return courseVos; |
| | | } |
| | | |
| | | @Override |
| | | public CourseDetailsResponse queryRegisteredCourseDetails(Integer coursePackageId, Integer appUserId) { |
| | | // TODO: 2023/7/6 已报名课程详情 |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public ResultUtil ContinuationOrpaymentCourse(Integer userIdFormRedis, ClasspaymentRequest request) { |
| | | // TODO: 2023/7/5 报名课程支付 |
| | | switch (request.getPayType()){ |
| | | case 1: |
| | | WeChatPayment(); |
| | | break; |
| | | case 2: |
| | | AlipayPayment(); |
| | | break; |
| | | case 3: |
| | | PlaypaiGoldPayment(); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | public void WeChatPayment(){ |
| | | |
| | | } |
| | | |
| | | public void AlipayPayment(){ |
| | | |
| | | } |
| | | |
| | | public void PlaypaiGoldPayment(){ |
| | | |
| | | } |
| | | |
| | | } |