From 185f5dc7c3c49f565da51cd9c2f7750f30990d4a Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期一, 11 十一月 2024 13:28:29 +0800 Subject: [PATCH] 代码提交 --- xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/feign/RemoteAppUserService.java | 2 xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/VersionController.java | 10 + xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientNoticeRecordController.java | 1 xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java | 5 xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/utils/TaskUtil.java | 4 xinquan-auth/src/main/java/com/xinquan/auth/controller/TokenController.java | 6 xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserViewingHistoryController.java | 20 ++ xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserTreeController.java | 342 ++++++++++++++++++++----------------- xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/factory/RemoteAppUserFallbackFactory.java | 5 xinquan-modules/xinquan-course/src/main/java/com/xinquan/course/service/impl/CourseServiceImpl.java | 4 xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserController.java | 48 +++++ xinquan-modules/xinquan-course/src/main/java/com/xinquan/course/controller/client/ClientCourseController.java | 33 +++ xinquan-modules/xinquan-meditation/src/main/java/com/xinquan/meditation/service/impl/MeditationEverydayServiceImpl.java | 18 + 13 files changed, 330 insertions(+), 168 deletions(-) diff --git a/xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/factory/RemoteAppUserFallbackFactory.java b/xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/factory/RemoteAppUserFallbackFactory.java index 44cfc24..dd470ad 100644 --- a/xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/factory/RemoteAppUserFallbackFactory.java +++ b/xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/factory/RemoteAppUserFallbackFactory.java @@ -33,6 +33,11 @@ public RemoteAppUserService create(Throwable cause) { return new RemoteAppUserService() { @Override + public R<Integer> getCourseChapterHistoryState(Long id, Long chapterId) { + return null; + } + + @Override public R addNotice(String id, String courseId, String userId, String price) { return null; } diff --git a/xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/feign/RemoteAppUserService.java b/xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/feign/RemoteAppUserService.java index 515bf8d..11ba9de 100644 --- a/xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/feign/RemoteAppUserService.java +++ b/xinquan-api/xinquan-api-user/src/main/java/com/xinquan/user/api/feign/RemoteAppUserService.java @@ -29,6 +29,8 @@ */ @FeignClient(contextId = "remoteAppUserService", value = ServiceNameConstants.APP_USER_SERVICE, fallbackFactory = RemoteAppUserFallbackFactory.class) public interface RemoteAppUserService { + @PostMapping("/user/app-user-viewing-history/getCourseChapterHistoryState/{id}/{chapterId}") + public R<Integer> getCourseChapterHistoryState(@PathVariable("id") Long id,@PathVariable("chapterId") Long chapterId); @GetMapping("/addNotice/{id}/{courseId}/{userId}/{price}") public R addNotice(@PathVariable("id")String id,@PathVariable("courseId")String courseId ,@PathVariable("userId")String userId,@PathVariable("price")String price); diff --git a/xinquan-auth/src/main/java/com/xinquan/auth/controller/TokenController.java b/xinquan-auth/src/main/java/com/xinquan/auth/controller/TokenController.java index 0654711..054a409 100644 --- a/xinquan-auth/src/main/java/com/xinquan/auth/controller/TokenController.java +++ b/xinquan-auth/src/main/java/com/xinquan/auth/controller/TokenController.java @@ -93,6 +93,12 @@ return R.fail("当前手机号已被绑定"); } } + if(type==4){ + AppUser data = remoteAppUserService.getUserByPhone(cellPhone).getData(); + if (data!=null && (data.getWxOpenId()!=null||data.getAppleId()!=null)){ + return R.fail("当前手机号已被绑定"); + } + } sysLoginService.sendCaptchaCode(cellPhone, type); return R.ok(); } diff --git a/xinquan-modules/xinquan-course/src/main/java/com/xinquan/course/controller/client/ClientCourseController.java b/xinquan-modules/xinquan-course/src/main/java/com/xinquan/course/controller/client/ClientCourseController.java index 6fd7df4..b3f2b0d 100644 --- a/xinquan-modules/xinquan-course/src/main/java/com/xinquan/course/controller/client/ClientCourseController.java +++ b/xinquan-modules/xinquan-course/src/main/java/com/xinquan/course/controller/client/ClientCourseController.java @@ -660,6 +660,17 @@ }else if (data!=null){ // 查询学习人数和头像列表 clientCourseVO.setCount(data.size()); + List<CourseChapter> list = courseChapterService.lambdaQuery().eq(CourseChapter::getCourseId, byId.getId()) + .list(); + // 累加实际学习人数 + int a = 0; + int b = 0; + for (CourseChapter courseChapter : list) { + Long data2 = remoteAppUserService.getCourseChapterHistoryCount(courseChapter.getId()).getData(); + a+=data2; + b+=courseChapter.getVirtualLearnedNum(); + } + clientCourseVO.setCount(a+b); if (data.size()>=5){ clientCourseVO.setHeaders(data.stream().limit(5).map(AppUser::getAvatar).collect(Collectors.toList())); }else{ @@ -671,6 +682,7 @@ clientCourseVO.setIsBuy(1); } } + } // 查询是否已收藏课程 clientCourseVO.setIsCollect(courseUserFavoriteService.lambdaQuery() @@ -686,15 +698,24 @@ .orderByDesc(CourseChapter::getSortNum) .list(); for (CourseChapter courseChapter : page) { - int size = courseLearningRecordService.lambdaQuery() - .eq(CourseLearningRecord::getChapterId, courseChapter.getId()) - .list().size(); - courseChapter.setRealLearnedNum(size+courseChapter.getVirtualLearnedNum()); + // 累加实际学习人数 + int a = 0; + int b = 0; + Long data2 = remoteAppUserService.getCourseChapterHistoryCount(courseChapter.getId()).getData(); + a+=data2; + b+=courseChapter.getVirtualLearnedNum(); + courseChapter.setRealLearnedNum(a+b); + courseChapter.setVirtualLearnedNum(0); + LoginUser loginUser = tokenService.getLoginUser(); + if (loginUser!=null){ + Integer data1 = remoteAppUserService.getCourseChapterHistoryState(loginUser.getUserid(), courseChapter.getId()).getData(); + courseChapter.setIsOver(data1); + }else{ + courseChapter.setIsOver(2); + } } clientCourseVO.setList(page); clientCourseVO.setIsBuy(2); - - // 查询推荐课程 List<Course> list = courseService.lambdaQuery().eq(Course::getCateId, byId.getCateId()) .eq(Course::getCourseType,1) diff --git a/xinquan-modules/xinquan-course/src/main/java/com/xinquan/course/service/impl/CourseServiceImpl.java b/xinquan-modules/xinquan-course/src/main/java/com/xinquan/course/service/impl/CourseServiceImpl.java index d76bf2b..4f99b11 100644 --- a/xinquan-modules/xinquan-course/src/main/java/com/xinquan/course/service/impl/CourseServiceImpl.java +++ b/xinquan-modules/xinquan-course/src/main/java/com/xinquan/course/service/impl/CourseServiceImpl.java @@ -49,7 +49,9 @@ }else if (cateId!=null){ courseLambdaQueryWrapper.eq(Course::getCateId, cateId); } - courseLambdaQueryWrapper.eq(Course::getRecommend,1); + if (cateId==null){ + courseLambdaQueryWrapper.eq(Course::getRecommend,1); + } courseLambdaQueryWrapper.eq(Course::getListingStatus,1); courseLambdaQueryWrapper.orderByDesc(Course::getSortNum); Page<Course> page = this.page(new Page<>(pageCurr, pageSize),courseLambdaQueryWrapper); diff --git a/xinquan-modules/xinquan-meditation/src/main/java/com/xinquan/meditation/service/impl/MeditationEverydayServiceImpl.java b/xinquan-modules/xinquan-meditation/src/main/java/com/xinquan/meditation/service/impl/MeditationEverydayServiceImpl.java index 37a4d42..2544863 100644 --- a/xinquan-modules/xinquan-meditation/src/main/java/com/xinquan/meditation/service/impl/MeditationEverydayServiceImpl.java +++ b/xinquan-modules/xinquan-meditation/src/main/java/com/xinquan/meditation/service/impl/MeditationEverydayServiceImpl.java @@ -1,14 +1,17 @@ package com.xinquan.meditation.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.xinquan.common.core.utils.DateUtils; import com.xinquan.common.core.utils.page.BeanUtils; import com.xinquan.meditation.api.domain.Meditation; import com.xinquan.meditation.domain.MeditationEveryday; +import com.xinquan.meditation.domain.MeditationMusic; import com.xinquan.meditation.domain.vo.ClientMeditationEverydayVO; import com.xinquan.meditation.domain.vo.ClientMeditationVO; import com.xinquan.meditation.mapper.MeditationEverydayMapper; import com.xinquan.meditation.mapper.MeditationMapper; +import com.xinquan.meditation.mapper.MeditationMusicMapper; import com.xinquan.meditation.service.MeditationEverydayService; import java.util.List; @@ -29,6 +32,8 @@ public class MeditationEverydayServiceImpl extends ServiceImpl<MeditationEverydayMapper, MeditationEveryday> implements MeditationEverydayService { private final MeditationMapper meditationMapper; + private final MeditationMusicMapper meditationMusicMapper; + /** * 查询每日冥想 @@ -57,6 +62,7 @@ if (meditationEverydayOpt.isPresent()) { // 查询冥想详情 MeditationEveryday meditationEveryday = meditationEverydayOpt.get(); + Long meditationId = meditationEveryday.getMeditationId(); Meditation meditation = meditationMapper.selectById(meditationId); Optional<Meditation> meditationOpt = Optional.ofNullable( @@ -68,12 +74,20 @@ ClientMeditationVO.class); vo = BeanUtils.copyBean(meditationEveryday, ClientMeditationEverydayVO.class); + clientMeditationVO.setBackgroundUrl(meditationOpt.get().getBackgroundUrl()); vo.setClientMeditationVO(clientMeditationVO); if (meditation!=null){ - vo.setImageUrl(meditation.getBackgroundUrl()); - vo.setTime(Integer.valueOf(meditation.getTutorAudioSecond())); + List<MeditationMusic> meditationId1 = meditationMusicMapper.selectList(new QueryWrapper<MeditationMusic>() + .eq("meditation_id", meditationId)); + int a= 0; + for (MeditationMusic meditationMusic : meditationId1) { + a += meditationMusic.getMusicSecond(); + } + vo.setTime(a); } } + vo.setImageUrl(meditationEveryday.getImageUrl()); + } return vo; } diff --git a/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java b/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java index cdd565a..1a32c50 100644 --- a/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java +++ b/xinquan-modules/xinquan-order/src/main/java/com/xinquan/order/controller/client/ClientOrderController.java @@ -406,6 +406,11 @@ order.setRealPayAmount(data.getIosPrice()); break; } + if (receiverId!=null){ + remoteAppUserService.addNotice(receiverId + "", data.getId() + "", + userId + "", order.getTotalAmount() + ""); + } + break; } diff --git a/xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/VersionController.java b/xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/VersionController.java index 7e853ea..3baeeac 100644 --- a/xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/VersionController.java +++ b/xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/VersionController.java @@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.xinquan.common.core.domain.R; import com.xinquan.common.core.utils.page.PageDTO; +import com.xinquan.common.core.web.domain.BaseModel; import com.xinquan.common.security.service.TokenService; import com.xinquan.common.security.utils.SecurityUtils; import com.xinquan.system.api.domain.AppUser; @@ -41,6 +42,15 @@ private TokenService tokenService; @Autowired private RemoteAppUserService remoteAppUserService; + @GetMapping("/detailVersionApp") + @ApiOperation(value = "查看详情版本管理", tags = "安卓版本管理") + public R<Version> detailVersionApp() { + List<Version> list = versionService.lambdaQuery().orderByDesc(BaseModel::getCreateTime).list(); + if (!list.isEmpty()){ + return R.ok(list.get(0)); + } + return R.ok(); + } @GetMapping("/versionList") @ApiOperation(value = "版本管理列表-分页", tags = {"管理后台-版本管理"}) @ApiImplicitParams({ diff --git a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserController.java b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserController.java index 5d5cc93..e5f804e 100644 --- a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserController.java +++ b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserController.java @@ -58,6 +58,7 @@ import java.time.LocalDateTime; import java.time.Month; import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAdjusters; import java.util.*; import java.util.stream.Collectors; @@ -119,6 +120,45 @@ private RemoteOrderService remoteOrderService; @Resource private RemoteUserService remoteUserService; + @Resource + private NoticeRecordService noticeRecordService; + @GetMapping("/testNotice") + @ApiOperation(value = "测试通知", tags = "测试通知") + public R testNotice() { + LocalDateTime now = LocalDateTime.now(); + List<AppUser> list = appUserService.lambdaQuery().ne(AppUser::getUserStatus, 3).list(); + for (AppUser appUser : list) { + if (appUser.getVipExpireTime()!=null && appUser.getVipExpireTime().isAfter(now)){ + // 计算两个now和time的天数差 + long between = Math.abs(ChronoUnit.DAYS.between(appUser.getVipExpireTime(), now)); + if (between<=7){ + NoticeRecord noticeRecord = new NoticeRecord(); + noticeRecord.setAppUserId(appUser.getId()); + noticeRecord.setReadStatus(1); + noticeRecord.setNoticeType(1); + noticeRecord.setTitle("【会员临期通知】"); + noticeRecord.setContent("尊敬的心泉疗愈会员你好,你的会员即将在" + +appUser.getVipExpireTime().toLocalDate()+"到期,到期后将不再享受会员权益,请及时续费"); + noticeRecordService.save(noticeRecord); + } + } + AppUserTree one = appUserTreeService.lambdaQuery().eq(AppUserTree::getAppUserId, appUser.getId()) + .eq(AppUserTree::getSowAgain, 2).one(); + if(one!=null && (one.getTaskOne()==2||one.getTaskTwo()==2)){ + NoticeRecord noticeRecord = new NoticeRecord(); + noticeRecord.setAppUserId(appUser.getId()); + noticeRecord.setReadStatus(1); + noticeRecord.setNoticeType(1); + noticeRecord.setTitle("【冥想通知】"); + noticeRecord.setContent("你今天的冥想任务还未完成,完成冥想后可获得能量值奖励,快去冥想吧!"); + noticeRecordService.save(noticeRecord); + } + } + return R.ok(); + } + + + @GetMapping("/getUserByPhone/{phone}") public R<AppUser> getUserByPhone(@PathVariable("phone")String phone) { AppUser one = appUserService.lambdaQuery().eq(AppUser::getCellPhone, phone).ne(AppUser::getUserStatus, 3) @@ -1438,10 +1478,16 @@ tem = a; total1 = Math.abs(total1-data3.get(x-1).getGrowthValue()); } + if (x==10){ + healingLevelVO.setDifferenceLevel(0); + healingLevelVO.setGrowthValue(tem); + }else{ + healingLevelVO.setDifferenceLevel(tem-total1); + healingLevelVO.setGrowthValue(total1); + } healingLevelVO.setNextLevel(tem); healingLevelVO.setLevel(x); // 将当前成长值更新 - healingLevelVO.setGrowthValue(total1); String data1 = remoteUserService.getCourseList(7).getData(); healingLevelVO.setContent(data1); return R.ok(healingLevelVO); diff --git a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserTreeController.java b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserTreeController.java index 3a32442..7d0f5c2 100644 --- a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserTreeController.java +++ b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserTreeController.java @@ -1,6 +1,7 @@ package com.xinquan.user.controller.client; +import cn.afterturn.easypoi.cache.manager.IFileLoader; import cn.hutool.core.util.RandomUtil; import com.alibaba.fastjson2.util.UUIDUtils; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -111,176 +112,194 @@ @PostMapping("/getUserTree") @ApiOperation(value = "获取用户树苗",tags = "树苗打卡站") public R<AppUserTree> getUserTree() { + LoginUser loginUser = tokenService.getLoginUser(); - if (loginUser==null){ - return R.tokenError("登录失效"); - } - Long userId = loginUser.getUserid(); - AppUser byId = appUserService.getById(userId); - byId.setIsFirst(2); - appUserService.updateById(byId); - // 查询用户今日观看疗愈多少秒 - LocalDateTime now = LocalDateTime.now(); - LocalDateTime startOfDay = now.toLocalDate().atStartOfDay(); - LocalDateTime endOfDay = now.toLocalDate().atTime(LocalTime.MAX); - List<AppUserViewingHistory> list = appUserViewingHistoryService - .lambdaQuery().eq(AppUserViewingHistory::getAppUserId, userId) - .eq(AppUserViewingHistory::getViewingType, 1) - .eq(BaseModel::getDelFlag,0) - .between(AppUserViewingHistory::getCreateTime, startOfDay,endOfDay).list(); - int temp = 0; - for (AppUserViewingHistory appUserViewingHistory : list) { - temp += appUserViewingHistory.getTimeLook(); - } - AppUserTree one = appUserTreeService.lambdaQuery().eq(AppUserTree::getAppUserId, userId) - .eq(AppUserTree::getSowAgain,2).one(); - if (one == null){ - AppUserTree appUserTree = new AppUserTree(); - appUserTree.setTime(LocalDateTime.now()); - appUserTree.setAppUserId(userId); - appUserTree.setTreeLevelType(1); - appUserTree.setGrowthValue(0); - appUserTree.setSowAgain(2); - appUserTree.setCreateTime(LocalDateTime.now()); - // 如果用户的签到时间是今天 那么修改为已签到 - if (byId.getSignTime()!=null && byId.getSignTime().toLocalDate().equals(LocalDateTime.now().toLocalDate())){ - appUserTree.setIsSign(1); - }else{ - appUserTree.setIsSign(2); + if (loginUser!=null) { + Long userId = loginUser.getUserid(); + AppUser byId = appUserService.getById(userId); + byId.setIsFirst(2); + appUserService.updateById(byId); + // 查询用户今日观看疗愈多少秒 + LocalDateTime now = LocalDateTime.now(); + LocalDateTime startOfDay = now.toLocalDate().atStartOfDay(); + LocalDateTime endOfDay = now.toLocalDate().atTime(LocalTime.MAX); + List<AppUserViewingHistory> list = appUserViewingHistoryService + .lambdaQuery().eq(AppUserViewingHistory::getAppUserId, userId) + .eq(AppUserViewingHistory::getViewingType, 1) + .eq(BaseModel::getDelFlag, 0) + .between(AppUserViewingHistory::getCreateTime, startOfDay, endOfDay).list(); + int temp = 0; + for (AppUserViewingHistory appUserViewingHistory : list) { + temp += appUserViewingHistory.getTimeLook(); } - if (temp>=120){ - if (appUserTree.getTaskOne()==2){ - AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); - appUserEnergyRecord.setAppUserId(userId); - appUserEnergyRecord.setChangeType(1); - appUserEnergyRecord.setEnergyValue(10); - appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务"); - appUserEnergyRecordService.save(appUserEnergyRecord); - byId.setTotalEnergyValue(byId.getTotalEnergyValue()+10); + AppUserTree one = appUserTreeService.lambdaQuery().eq(AppUserTree::getAppUserId, userId) + .eq(AppUserTree::getSowAgain, 2).one(); + if (one == null) { + AppUserTree appUserTree = new AppUserTree(); + appUserTree.setTime(LocalDateTime.now()); + appUserTree.setAppUserId(userId); + appUserTree.setTreeLevelType(1); + appUserTree.setGrowthValue(0); + appUserTree.setSowAgain(2); + appUserTree.setCreateTime(LocalDateTime.now()); + // 如果用户的签到时间是今天 那么修改为已签到 + if (byId.getSignTime() != null && byId.getSignTime().toLocalDate().equals(LocalDateTime.now().toLocalDate())) { + appUserTree.setIsSign(1); + } else { + appUserTree.setIsSign(2); } - if (appUserTree.getTaskTwo()==2){ - AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); - appUserEnergyRecord.setAppUserId(userId); - appUserEnergyRecord.setChangeType(1); - appUserEnergyRecord.setEnergyValue(20); - appUserEnergyRecord.setReason("完成【每日疗愈60分钟】任务"); - appUserEnergyRecordService.save(appUserEnergyRecord); - byId.setTotalEnergyValue(byId.getTotalEnergyValue()+20); + if (temp >= 120) { + if (appUserTree.getTaskOne() == 2) { + AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); + appUserEnergyRecord.setAppUserId(userId); + appUserEnergyRecord.setChangeType(1); + appUserEnergyRecord.setEnergyValue(10); + appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务"); + appUserEnergyRecordService.save(appUserEnergyRecord); + byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 10); + } + if (appUserTree.getTaskTwo() == 2) { + AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); + appUserEnergyRecord.setAppUserId(userId); + appUserEnergyRecord.setChangeType(1); + appUserEnergyRecord.setEnergyValue(20); + appUserEnergyRecord.setReason("完成【每日疗愈60分钟】任务"); + appUserEnergyRecordService.save(appUserEnergyRecord); + byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 20); + } + appUserTree.setTaskOne(1); + appUserTree.setTaskTwo(1); + } else if (temp >= 60) { + if (appUserTree.getTaskOne() == 2) { + AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); + appUserEnergyRecord.setAppUserId(userId); + appUserEnergyRecord.setChangeType(1); + appUserEnergyRecord.setEnergyValue(10); + appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务"); + appUserEnergyRecordService.save(appUserEnergyRecord); + byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 10); + } + appUserTree.setTaskOne(1); + appUserTree.setTaskTwo(2); + } else { + appUserTree.setTaskOne(2); + appUserTree.setTaskTwo(2); } - appUserTree.setTaskOne(1); - appUserTree.setTaskTwo(1); - } - else if (temp>=60){ - if (appUserTree.getTaskOne()==2){ - AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); - appUserEnergyRecord.setAppUserId(userId); - appUserEnergyRecord.setChangeType(1); - appUserEnergyRecord.setEnergyValue(10); - appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务"); - appUserEnergyRecordService.save(appUserEnergyRecord); - byId.setTotalEnergyValue(byId.getTotalEnergyValue()+10); - } - appUserTree.setTaskOne(1); - appUserTree.setTaskTwo(2); - }else{ - appUserTree.setTaskOne(2); - appUserTree.setTaskTwo(2); - } - appUserTree.setEnergyValue(byId.getEnergyValue()); - appUserTree.setNextLevel(1000); - appUserTreeService.save(appUserTree); - appUserTree.setTotalEnergyValue(byId.getTotalEnergyValue()); - return R.ok(appUserTree); - }else{ - if (temp>=120){ - if (one.getTaskOne()==2){ - AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); - appUserEnergyRecord.setAppUserId(userId); - appUserEnergyRecord.setChangeType(1); - appUserEnergyRecord.setEnergyValue(10); - appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务"); - appUserEnergyRecordService.save(appUserEnergyRecord); - byId.setTotalEnergyValue(byId.getTotalEnergyValue()+10); - } - if (one.getTaskTwo()==2){ - AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); - appUserEnergyRecord.setAppUserId(userId); - appUserEnergyRecord.setChangeType(1); - appUserEnergyRecord.setEnergyValue(20); - appUserEnergyRecord.setReason("完成【每日疗愈60分钟】任务"); - appUserEnergyRecordService.save(appUserEnergyRecord); - byId.setTotalEnergyValue(byId.getTotalEnergyValue()+20); + appUserTree.setEnergyValue(byId.getEnergyValue()); + appUserTree.setNextLevel(1000); + appUserTreeService.save(appUserTree); + appUserTree.setTotalEnergyValue(byId.getTotalEnergyValue()); + return R.ok(appUserTree); + } else { + if (temp >= 120) { + if (one.getTaskOne() == 2) { + AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); + appUserEnergyRecord.setAppUserId(userId); + appUserEnergyRecord.setChangeType(1); + appUserEnergyRecord.setEnergyValue(10); + appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务"); + appUserEnergyRecordService.save(appUserEnergyRecord); + byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 10); + } + if (one.getTaskTwo() == 2) { + AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); + appUserEnergyRecord.setAppUserId(userId); + appUserEnergyRecord.setChangeType(1); + appUserEnergyRecord.setEnergyValue(20); + appUserEnergyRecord.setReason("完成【每日疗愈60分钟】任务"); + appUserEnergyRecordService.save(appUserEnergyRecord); + byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 20); + } + one.setTaskOne(1); + one.setTaskTwo(1); + } else if (temp >= 60) { + if (one.getTaskOne() == 2) { + AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); + appUserEnergyRecord.setAppUserId(userId); + appUserEnergyRecord.setChangeType(1); + appUserEnergyRecord.setEnergyValue(10); + appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务"); + appUserEnergyRecordService.save(appUserEnergyRecord); + byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 10); + } + one.setTaskOne(1); + one.setTaskTwo(2); + } else { + one.setTaskOne(2); + one.setTaskTwo(2); } - one.setTaskOne(1); - one.setTaskTwo(1); - } - else if (temp>=60){ - if (one.getTaskOne()==2){ - AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); - appUserEnergyRecord.setAppUserId(userId); - appUserEnergyRecord.setChangeType(1); - appUserEnergyRecord.setEnergyValue(10); - appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务"); - appUserEnergyRecordService.save(appUserEnergyRecord); - byId.setTotalEnergyValue(byId.getTotalEnergyValue()+10); + // 如果用户的签到时间是今天 那么修改为已签到 + if (byId.getSignTime() != null && byId.getSignTime().toLocalDate().equals(LocalDateTime.now().toLocalDate())) { + one.setIsSign(1); + } else { + one.setIsSign(2); } - one.setTaskOne(1); - one.setTaskTwo(2); - }else{ - one.setTaskOne(2); - one.setTaskTwo(2); - } - // 如果用户的签到时间是今天 那么修改为已签到 - if (byId.getSignTime()!=null&&byId.getSignTime().toLocalDate().equals(LocalDateTime.now().toLocalDate())){ - one.setIsSign(1); - }else{ - one.setIsSign(2); - } - List<TreeLevelSetting> data = sysUserClient.getTreeGroup().getData(); + List<TreeLevelSetting> data = sysUserClient.getTreeGroup().getData(); - Integer total1 = one.getTotal(); - // 根据总能量值 确定他在哪一等级 - int x = 1; - int tem = 0; - for (TreeLevelSetting datum : data) { - if (total1 == 0){ - Integer growthValue = data.get(1).getGrowthValue(); - tem = growthValue; - break; - }else if (total1>=datum.getGrowthValue()){ - x = datum.getTreeLevelType(); - } - } - if (x == 10){ - // 如果等级为10那么成长阈值是10级减去9级 - int ten=0; - int nine = 0; + Integer total1 = one.getTotal(); + // 根据总能量值 确定他在哪一等级 + int x = 1; + int tem = 0; for (TreeLevelSetting datum : data) { - if (datum.getTreeLevelType()==10){ - ten = datum.getGrowthValue(); - } - if (datum.getTreeLevelType()==9){ - nine = datum.getGrowthValue(); + if (total1 == 0) { + Integer growthValue = data.get(1).getGrowthValue(); + tem = growthValue; + break; + } else if (total1 >= datum.getGrowthValue()) { + x = datum.getTreeLevelType(); } } - tem = ten-nine; - total1 = tem; - }else{ - // 根据当前所在等级查询成长值 - int a = data.get(x).getGrowthValue()-data.get(x-1).getGrowthValue(); - tem = a; - total1 = Math.abs(total1-data.get(x-1).getGrowthValue()); + if (x == 10) { + // 如果等级为10那么成长阈值是10级减去9级 + int ten = 0; + int nine = 0; + for (TreeLevelSetting datum : data) { + if (datum.getTreeLevelType() == 10) { + ten = datum.getGrowthValue(); + } + if (datum.getTreeLevelType() == 9) { + nine = datum.getGrowthValue(); + } + } + tem = ten - nine; + total1 = tem; + } else { + // 根据当前所在等级查询成长值 + int a = data.get(x).getGrowthValue() - data.get(x - 1).getGrowthValue(); + tem = a; + total1 = Math.abs(total1 - data.get(x - 1).getGrowthValue()); + } + one.setNextLevel(tem); + one.setTreeLevelType(x); + // 将当前成长值更新 + one.setGrowthValue(total1); + one.setEnergyValue(byId.getEnergyValue()); + appUserTreeService.updateById(one); + one.setTotalEnergyValue(byId.getTotalEnergyValue()); + return R.ok(one); } - one.setNextLevel(tem); - one.setTreeLevelType(x); - // 将当前成长值更新 - one.setGrowthValue(total1); - one.setEnergyValue(byId.getEnergyValue()); - appUserTreeService.updateById(one); - one.setTotalEnergyValue(byId.getTotalEnergyValue()); - return R.ok(one); + }else{ + List<TreeLevelSetting> data = sysUserClient.getTreeGroup().getData(); + + AppUserTree appUserTree = new AppUserTree(); + appUserTree.setTreeLevelType(1); + appUserTree.setTotal(0); + appUserTree.setGrowthValue(0); + for (TreeLevelSetting datum : data) { + if (datum.getTreeLevelType()==2){ + appUserTree.setNextLevel(datum.getGrowthValue()); + } + } + appUserTree.setSowAgain(2); + appUserTree.setStatus(2); + appUserTree.setTaskOne(2); + appUserTree.setEnergyValue(0); + appUserTree.setTaskTwo(2); + appUserTree.setIsSign(2); + appUserTree.setTotalEnergyValue(0); + return R.ok(appUserTree); } } @Autowired @@ -308,6 +327,8 @@ return R.ok(); } + @Resource + private NoticeRecordService noticeRecordService; @PostMapping("/watering") @ApiOperation(value = "浇水 返回值true证明升级了 false没升级",tags = "树苗打卡站") public R<WateringVO> watering() { @@ -380,6 +401,13 @@ wateringVO.setGrowthValue(total1); if (x>y){ wateringVO.setIsNext(true); + NoticeRecord noticeRecord = new NoticeRecord(); + noticeRecord.setAppUserId(userId); + noticeRecord.setReadStatus(1); + noticeRecord.setNoticeType(1); + noticeRecord.setTitle("树苗升级通知"); + noticeRecord.setContent("恭喜,您的树苗已升至"+y+"级,"+"继续加油哦"); + noticeRecordService.save(noticeRecord); } return R.ok(wateringVO); } diff --git a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserViewingHistoryController.java b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserViewingHistoryController.java index b22abc5..2a0ecbd 100644 --- a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserViewingHistoryController.java +++ b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserViewingHistoryController.java @@ -69,6 +69,26 @@ private final RemoteAppUserService remoteAppUserService; /** + * 远程调用 根据章节id和用户id查询是否观看完毕 + * @param id + * @return + */ + @PostMapping("/getCourseChapterHistoryState/{id}/{chapterId}") + public R<Integer> getCourseChapterHistoryState(@PathVariable("id") Long id,@PathVariable("chapterId") Long chapterId) { + List<AppUserViewingHistory> list = appUserViewingHistoryService.lambdaQuery() + .eq(AppUserViewingHistory::getChapterId, chapterId) + .eq(AppUserViewingHistory::getAppUserId, id) + .eq(AppUserViewingHistory::getViewingType, 2) + .list(); + for (AppUserViewingHistory appUserViewingHistory : list) { + if (appUserViewingHistory.getIsOver()!=null && appUserViewingHistory.getIsOver()==1){ + return R.ok(1); + } + } + return R.ok(2); + } + + /** * 远程调用查询用户观看了哪些课程 * @return */ diff --git a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientNoticeRecordController.java b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientNoticeRecordController.java index 70153cd..68298cc 100644 --- a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientNoticeRecordController.java +++ b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientNoticeRecordController.java @@ -119,6 +119,7 @@ String formattedDateTime = createTime.format(formatter); // 将其转化为yyyy-MM-dd HH:mm格式 noticeDetailVO.setTime(formattedDateTime); + noticeDetailVO.setPublishTime(noticeRecord.getCreateTime()); if (noticeRecord!=null && noticeRecord.getMeditationQuestionId()!=null){ // 远程调用 根据冥想提问id 查询数据 noticeDetailVO.setMeditationQuestionId(noticeRecord.getMeditationQuestionId()); diff --git a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/utils/TaskUtil.java b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/utils/TaskUtil.java index 297d2a8..9f42692 100644 --- a/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/utils/TaskUtil.java +++ b/xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/utils/TaskUtil.java @@ -81,8 +81,10 @@ public static void main(String[] args) { LocalDate localDate = LocalDateTime.now().toLocalDate(); System.err.println(localDate); + } // 每天早上7点执行的定时任务 + @Scheduled(cron = "0 0 7 * * ?") public void taskSivenDay() { try { @@ -127,7 +129,7 @@ for (AppUser appUser : list) { AppUserTree one = appUserTreeService.lambdaQuery().eq(AppUserTree::getAppUserId, appUser.getId()) .eq(AppUserTree::getSowAgain, 2).one(); - if(one.getTaskOne()==2||one.getTaskTwo()==2){ + if(one!=null && (one.getTaskOne()==2||one.getTaskTwo()==2)){ NoticeRecord noticeRecord = new NoticeRecord(); noticeRecord.setAppUserId(appUser.getId()); noticeRecord.setReadStatus(1); -- Gitblit v1.7.1