| | |
| | | import com.xinquan.common.core.utils.page.PageDTO; |
| | | import com.xinquan.common.core.web.page.PageInfo; |
| | | import com.xinquan.common.security.service.TokenService; |
| | | import com.xinquan.common.security.utils.SecurityUtils; |
| | | import com.xinquan.course.api.domain.Course; |
| | | import com.xinquan.meditation.api.domain.Meditation; |
| | | import com.xinquan.meditation.domain.*; |
| | | import com.xinquan.meditation.domain.vo.ClientMeditationAndCateVO; |
| | |
| | | import com.xinquan.order.api.domain.Order; |
| | | import com.xinquan.order.api.feign.RemoteOrderService; |
| | | import com.xinquan.system.api.domain.AppUser; |
| | | import com.xinquan.system.api.domain.MeditationQuestion; |
| | | import com.xinquan.meditation.api.domain.MeditationQuestion; |
| | | import com.xinquan.system.api.domain.AppUserViewingHistory; |
| | | import com.xinquan.system.api.domain.vo.AppUserVO; |
| | | import com.xinquan.system.api.model.LoginUser; |
| | | import com.xinquan.user.api.domain.dto.AppUserDTO; |
| | |
| | | private final MeditationQuestionLikeService meditationQuestionLikeService; |
| | | private final MeditationUserFavoriteService meditationUserFavoriteService; |
| | | private final RemoteOrderService remoteOrderService; |
| | | private final MeditationMapper meditationMapper; |
| | | /** |
| | | * 获取私人订制 |
| | | * |
| | |
| | | Integer sanskritFlag = appUser.getSanskritFlag(); |
| | | if (StringUtils.hasLength(appUser.getTagId())) { |
| | | String tagId = appUser.getTagId(); |
| | | Set<Long> tagIdSet = Arrays.stream(tagId.split(",")).map(Long::parseLong) |
| | | .collect(Collectors.toSet()); |
| | | // 查询冥想列表 |
| | | voList = baseMapper.getMeditationListByTagId(tagIdSet, sanskritFlag); |
| | | if (StringUtils.hasLength(tagId)){ |
| | | Set<Long> tagIdSet = Arrays.stream(tagId.split(",")).map(Long::parseLong) |
| | | .collect(Collectors.toSet()); |
| | | // 查询冥想列表 |
| | | voList = baseMapper.getMeditationListByTagId(tagIdSet, sanskritFlag); |
| | | } |
| | | }else{ |
| | | Set<Long> longs = new HashSet<>(); |
| | | voList = baseMapper.getMeditationListByTagId(longs, sanskritFlag); |
| | |
| | | }else{ |
| | | voList = baseMapper.getMeditationListByTagId(null, null); |
| | | } |
| | | voList = handlePaidMeditation(voList); |
| | | if(voList.isEmpty()){ |
| | | voList = baseMapper.getMeditationListByTagId(null, null); |
| | | voList = voList.stream().limit(1).collect(Collectors.toList()); |
| | | } |
| | | return voList; |
| | | }else{ |
| | | voList = baseMapper.getMeditationListByTagId(null, null); |
| | | voList = voList.stream().limit(1).collect(Collectors.toList()); |
| | | return voList; |
| | | } |
| | | } |
| | |
| | | if (loginUser==null){ |
| | | return new ArrayList<>(); |
| | | } |
| | | Long userId = loginUser.getUserid(); |
| | | List<Order> orderList = remoteOrderService.getOrderListByType(userId, |
| | | OrderFromEnum.MEDITATION.getCode(), |
| | | SecurityConstants.INNER).getData(); |
| | | List<Long> meditationIdList = orderList.stream().map(Order::getBusinessId) |
| | | .collect(Collectors.toList()); |
| | | Long userId = loginUser.getUserid(); |
| | | List<Order> data1 = remoteOrderService.getMeditationIsBuyAll(userId).getData(); |
| | | List<Long> meditationIdList = data1.stream().map(Order::getBusinessId).collect(Collectors.toList()); |
| | | if (CollUtils.isNotEmpty(meditationIdList)) { |
| | | Set<Long> meditationIdSet = new HashSet<>(meditationIdList); |
| | | voList = voList.stream() |
| | | .filter(meditationVO -> meditationIdList.contains(meditationVO.getId())) |
| | | .peek(meditationVO -> meditationVO.setPaidStatus(1)) |
| | | .filter(meditationVO -> meditationIdSet.contains(meditationVO.getId())) |
| | | .peek(meditationVO -> meditationVO.setIsBuy(1)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | return voList; |
| | |
| | | // 获取当前登录用户id |
| | | AppUser appUser = getCurrentUser(); |
| | | LambdaQueryWrapper<Meditation> meditationLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | System.err.println("上下架"); |
| | | meditationLambdaQueryWrapper.eq(Meditation::getListingStatus, 1); |
| | | meditationLambdaQueryWrapper.eq(Meditation::getCateId, cateId); |
| | | if (appUser!=null){ |
| | | meditationLambdaQueryWrapper.eq(Meditation::getSanskrit, appUser.getSanskritFlag()); |
| | | if (appUser.getSanskritFlag() == 2){ |
| | | meditationLambdaQueryWrapper.eq(Meditation::getSanskrit, 2); |
| | | } |
| | | meditationLambdaQueryWrapper.orderByDesc(Meditation::getSortNum).last("limit 8"); |
| | | } |
| | | List<Meditation> list =this.list(meditationLambdaQueryWrapper); |
| | |
| | | */ |
| | | @Override |
| | | public List<ClientMeditationAndCateVO> getMeditationAndCateList() { |
| | | |
| | | // 获取当前登录用户 |
| | | List<ClientMeditationAndCateVO> voList = CollUtils.newArrayList(); |
| | | // 查询分类列表 |
| | |
| | | ClientMeditationAndCateVO vo = new ClientMeditationAndCateVO(); |
| | | vo.setClientMeditationCategoryVO( |
| | | BeanUtils.copyBean(cate, ClientMeditationCategoryVO.class)); |
| | | vo.setClientMeditationVOList(getMeditationListByCateId(cate.getId())); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | List<ClientMeditationVO> meditationListByCateId = getMeditationListByCateId(cate.getId()); |
| | | if (loginUser!=null){ |
| | | List<Order> data1 = remoteOrderService.getMeditationIsBuyAll(loginUser.getUserid()).getData(); |
| | | for (ClientMeditationVO clientMeditationVO : meditationListByCateId) { |
| | | Order order = data1.stream().filter(e -> e.getBusinessId().equals(clientMeditationVO.getId())).findFirst().orElse(null); |
| | | if (order==null){ |
| | | clientMeditationVO.setIsBuy(2); |
| | | }else{ |
| | | clientMeditationVO.setIsBuy(1); |
| | | } |
| | | clientMeditationVO.setRealLearnedNum(clientMeditationVO.getVirtualLearnedNum()+clientMeditationVO.getRealLearnedNum()); |
| | | } |
| | | }else{ |
| | | for (ClientMeditationVO clientMeditationVO : meditationListByCateId) { |
| | | clientMeditationVO.setIsBuy(2); |
| | | clientMeditationVO.setRealLearnedNum(clientMeditationVO.getVirtualLearnedNum()+clientMeditationVO.getRealLearnedNum()); |
| | | } |
| | | } |
| | | vo.setClientMeditationVOList(meditationListByCateId); |
| | | voList.add(vo); |
| | | } |
| | | return voList; |
| | | } |
| | | |
| | | // @Override |
| | | // public List<ClientMeditationAndCateVO> getMeditationAndCateList() { |
| | | // List<ClientMeditationAndCateVO> voList = CollUtils.newArrayList(); |
| | | // |
| | | // // 查询分类列表 |
| | | // List<MeditationCategory> cateList = meditationCategoryMapper.selectList( |
| | | // Wrappers.lambdaQuery(MeditationCategory.class) |
| | | // .orderByDesc(MeditationCategory::getSortNum)); |
| | | // |
| | | // LoginUser loginUser = tokenService.getLoginUser(); |
| | | // Long userId = loginUser != null ? loginUser.getUserid() : null; |
| | | // |
| | | // for (MeditationCategory cate : cateList) { |
| | | // ClientMeditationAndCateVO vo = new ClientMeditationAndCateVO(); |
| | | // vo.setClientMeditationCategoryVO(BeanUtils.copyBean(cate, ClientMeditationCategoryVO.class)); |
| | | // |
| | | // List<ClientMeditationVO> meditationListByCateId = getMeditationListByCateId(cate.getId()); |
| | | // |
| | | // for (ClientMeditationVO record : meditationListByCateId) { |
| | | // setMeditationDetails(record, userId); |
| | | // } |
| | | // |
| | | // vo.setClientMeditationVOList(meditationListByCateId); |
| | | // voList.add(vo); |
| | | // } |
| | | // |
| | | // return voList; |
| | | // } |
| | | // |
| | | // private void setMeditationDetails(ClientMeditationVO record, Long userId) { |
| | | // Long historyCount = remoteAppUserService.getMeditationHistoryCount(record.getId()).getData(); |
| | | // record.setRealLearnedNum(Integer.valueOf(historyCount.toString())); |
| | | // record.setRealLearnedNum(record.getVirtualLearnedNum() + record.getRealLearnedNum()); |
| | | // |
| | | // Integer isBuy = userId != null ? remoteOrderService.getMeditationIsBuy(userId, record.getId()).getData() : 2; |
| | | // record.setIsBuy(isBuy); |
| | | // |
| | | // Meditation meditation = this.getById(record.getId()); |
| | | // meditation.setRealLearnedNum(Integer.valueOf(historyCount.toString())); |
| | | // this.updateById(meditation); |
| | | // } |
| | | /** |
| | | * 根据分类id获取冥想列表-分页 |
| | | * |
| | |
| | | LambdaQueryWrapper<Meditation> meditationLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | meditationLambdaQueryWrapper.eq(Meditation::getCateId, cateId); |
| | | if (appUser!=null){ |
| | | meditationLambdaQueryWrapper.eq(Meditation::getSanskrit, appUser.getSanskritFlag()); |
| | | if (appUser.getSanskritFlag() == 2){ |
| | | meditationLambdaQueryWrapper.eq(Meditation::getSanskrit, 2); |
| | | } |
| | | } |
| | | meditationLambdaQueryWrapper.eq(Meditation::getListingStatus,1); |
| | | meditationLambdaQueryWrapper.orderByDesc(Meditation::getSortNum); |
| | | Page<Meditation> page = this.page(new Page<>(pageCurr, pageSize), meditationLambdaQueryWrapper); |
| | | // 如果没有查到数据直接返回 |
| | | if (page.getRecords().isEmpty()) { |
| | | return pageDTO; |
| | | } |
| | | List<Order> data1 = new ArrayList<Order>(); |
| | | |
| | | if (tokenService.getLoginUser()!=null){ |
| | | data1 = remoteOrderService.getMeditationIsBuyAll(tokenService.getLoginUser().getUserid()).getData(); |
| | | } |
| | | List<AppUserViewingHistory> data2 = remoteAppUserService.getMeditationHistoryCountAll().getData(); |
| | | boolean temp = tokenService.getLoginUser()!=null; |
| | | for (Meditation record : page.getRecords()) { |
| | | List<AppUserViewingHistory> collect = data2.stream().filter(e -> e.getBizId().equals(record.getId())).collect(Collectors.toList()); |
| | | record.setRealLearnedNum(collect.size()); |
| | | record.setRealLearnedNum(record.getVirtualLearnedNum()+record.getRealLearnedNum()); |
| | | if (temp){ |
| | | Order order = data1.stream().filter(e -> e.getBusinessId().equals(record.getId())).findFirst().orElse(null); |
| | | if (order==null){ |
| | | record.setIsBuy(2); |
| | | }else{ |
| | | record.setIsBuy(1); |
| | | } |
| | | }else{ |
| | | record.setIsBuy(2); |
| | | } |
| | | } |
| | | this.updateBatchById(page.getRecords()); |
| | | // 将实体类转换为VO |
| | | pageDTO = PageDTO.of(page, ClientMeditationVO.class); |
| | | return pageDTO; |
| | |
| | | Long userid = loginUser.getUserid(); |
| | | } |
| | | LambdaQueryWrapper<Meditation> meditationLambdaQueryWrapper = new LambdaQueryWrapper<>(); |
| | | meditationLambdaQueryWrapper.eq(Meditation::getListingStatus,1); |
| | | meditationLambdaQueryWrapper.like(Meditation::getMeditationTitle, condition); |
| | | if (loginUser!=null){ |
| | | Long userid = loginUser.getUserid(); |
| | | AppUser appUser = remoteAppUserService.getAppUserById(userid + "").getData(); |
| | | if (appUser.getSanskritFlag()==2) |
| | | meditationLambdaQueryWrapper.eq(Meditation::getSanskrit, appUser.getSanskritFlag()); |
| | | } |
| | | meditationLambdaQueryWrapper.like(Meditation::getMeditationTitle, condition); |
| | |
| | | * @return 客户端冥想详情视图对象 |
| | | */ |
| | | @Override |
| | | public ClientMeditationDetailsVO getMeditationDetails(Long id) { |
| | | AppUserVO data1 = remoteAppUserService.getCurrentUser().getData(); |
| | | |
| | | |
| | | public R<ClientMeditationDetailsVO> getMeditationDetails(Long id) { |
| | | // 查询冥想音频 |
| | | Meditation meditation = this.getById(id); |
| | | ClientMeditationDetailsVO vo = BeanUtils.copyBean(meditation, |
| | | ClientMeditationDetailsVO.class); |
| | | if (data1.getVipExpireTime()!=null && data1.getVipExpireTime().isAfter(LocalDateTime.now())){ |
| | | vo.setIsVip(1); |
| | | }else{ |
| | | vo.setIsVip(0); |
| | | if (meditation.getChargeType() != 1){ |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (loginUser==null){ |
| | | return R.tokenError("登录失效"); |
| | | } |
| | | Long userid = loginUser.getUserid(); |
| | | AppUser data1 = remoteAppUserService.getAppUserById(userid + "").getData(); |
| | | |
| | | if (data1.getVipExpireTime()!=null && data1.getVipExpireTime().isAfter(LocalDateTime.now())){ |
| | | vo.setIsVip(1); |
| | | }else{ |
| | | vo.setIsVip(2); |
| | | } |
| | | Integer data = remoteOrderService.getMeditationIsBuy(data1.getId(), id).getData(); |
| | | vo.setIsBuy(data); |
| | | List<MeditationUserFavorite> list = meditationUserFavoriteService.lambdaQuery() |
| | | .eq(MeditationUserFavorite::getMeditationId, id) |
| | | .eq(MeditationUserFavorite::getAppUserId, userid).list(); |
| | | if (list.isEmpty()){ |
| | | vo.setFavorite(2); |
| | | }else{ |
| | | vo.setFavorite(1); |
| | | } |
| | | } |
| | | Integer data = remoteOrderService.getMeditationIsBuy(data1.getId(), id).getData(); |
| | | vo.setIsBuy(data); |
| | | // 查询冥想音频 |
| | | List<MeditationMusic> meditationMusics = meditationMusicMapper.selectList( |
| | | Wrappers.lambdaQuery(MeditationMusic.class) |
| | |
| | | // 获取音频链接 |
| | | List<String> musicUrlList = meditationMusics.stream() |
| | | .map(MeditationMusic::getMusicUrl).collect(Collectors.toList()); |
| | | // 获取音频链接 |
| | | List<Integer> musicSencodList = meditationMusics.stream() |
| | | .map(MeditationMusic::getMusicSecond).collect(Collectors.toList()); |
| | | vo.setMeditationMusicList(musicUrlList); |
| | | vo.setMeditationSecondList(musicSencodList); |
| | | } |
| | | // 获取提问数 |
| | | vo.setQuestionCount(meditationQuestionMapper.selectCount( |
| | | Wrappers.lambdaQuery(MeditationQuestion.class) |
| | | .eq(MeditationQuestion::getMeditationId, id))); |
| | | return vo; |
| | | if (tokenService.getLoginUser()!=null){ |
| | | List<Long> data = remoteAppUserService.getUserBlackList(tokenService.getLoginUser().getUserid()).getData(); |
| | | // 获取提问数 |
| | | vo.setQuestionCount(meditationQuestionMapper.selectCount( |
| | | Wrappers.lambdaQuery(MeditationQuestion.class) |
| | | .notIn(!data.isEmpty(),MeditationQuestion::getAppUserId, data) |
| | | .eq(MeditationQuestion::getMeditationId, id) |
| | | .eq(MeditationQuestion::getShowFlag,1))); |
| | | }else{ |
| | | // 获取提问数 |
| | | vo.setQuestionCount(meditationQuestionMapper.selectCount( |
| | | Wrappers.lambdaQuery(MeditationQuestion.class) |
| | | .eq(MeditationQuestion::getMeditationId, id) |
| | | .eq(MeditationQuestion::getShowFlag,1))); |
| | | } |
| | | |
| | | if (tokenService.getLoginUser()!=null){ |
| | | Integer data2 = remoteOrderService.getMeditationIsBuy(tokenService.getLoginUser().getUserid(), id).getData(); |
| | | vo.setIsBuy(data2); |
| | | List<MeditationUserFavorite> list = meditationUserFavoriteService.lambdaQuery() |
| | | .eq(MeditationUserFavorite::getMeditationId, id) |
| | | .eq(MeditationUserFavorite::getAppUserId, tokenService.getLoginUser().getUserid()).list(); |
| | | |
| | | if (list.isEmpty()){ |
| | | vo.setFavorite(2); |
| | | }else{ |
| | | vo.setFavorite(1); |
| | | } |
| | | } |
| | | |
| | | this.updateById(meditation); |
| | | return R.ok(vo); |
| | | } |
| | | @Override |
| | | public ClientMeditationDetailsVO getMeditationDetails1(Long id) { |
| | |
| | | // 获取提问数 |
| | | vo.setQuestionCount(meditationQuestionMapper.selectCount( |
| | | Wrappers.lambdaQuery(MeditationQuestion.class) |
| | | .eq(MeditationQuestion::getMeditationId, id))); |
| | | .eq(MeditationQuestion::getMeditationId, id) |
| | | .eq(MeditationQuestion::getShowFlag,1))); |
| | | return vo; |
| | | } |
| | | |
| | |
| | | @Override |
| | | public PageDTO<ClientMeditationQuestionVO> getMeditationQuestionPage(Long id, |
| | | Integer pageCurr, Integer pageSize) { |
| | | Long userid = tokenService.getLoginUser().getUserid(); |
| | | List<Long> data = remoteAppUserService.getUserBlackList(userid).getData(); |
| | | // 查询冥想提问列表 |
| | | Page<MeditationQuestion> questionPage = meditationQuestionMapper.selectPage( |
| | | new Page<>(pageCurr, pageSize), |
| | | Wrappers.lambdaQuery(MeditationQuestion.class) |
| | | .eq(MeditationQuestion::getMeditationId, id) |
| | | .notIn(!data.isEmpty(),MeditationQuestion::getAppUserId, data) |
| | | .eq(MeditationQuestion::getShowFlag, DisabledEnum.YES.getCode()) |
| | | .orderByDesc(MeditationQuestion::getPublishTime)); |
| | | if (CollUtils.isEmpty(questionPage.getRecords())) { |
| | |
| | | @Override |
| | | public PageDTO<ClientMeditationQuestionVO> getMeditationQuestionPageShare(Long id, |
| | | Integer pageCurr, Integer pageSize) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | List<Long> longs = new ArrayList<>(); |
| | | |
| | | if (loginUser!=null){ |
| | | longs = remoteAppUserService.getUserBlackList(loginUser.getAppUserId()).getData(); |
| | | |
| | | } |
| | | // 查询冥想提问列表 |
| | | Page<MeditationQuestion> questionPage = meditationQuestionMapper.selectPage( |
| | | new Page<>(pageCurr, pageSize), |
| | | Wrappers.lambdaQuery(MeditationQuestion.class) |
| | | .eq(MeditationQuestion::getMeditationId, id) |
| | | .notIn(!longs.isEmpty(),MeditationQuestion::getAppUserId, longs) |
| | | .eq(MeditationQuestion::getShowFlag, DisabledEnum.YES.getCode()) |
| | | .orderByDesc(MeditationQuestion::getPublishTime)); |
| | | if (CollUtils.isEmpty(questionPage.getRecords())) { |