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 getUserEnergy(Long id) { return null; } @Override public R<List<Long>> getUserBlackList(Long appUserId) { return null; } 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("/client/app-user-tree/getUserEnergy/{id}") public R getUserEnergy(@PathVariable("id")Long id); @PostMapping("/client/app-user/getUserBlackList/{appUserId}") public R<List<Long>> getUserBlackList(@PathVariable("appUserId") Long appUserId); @GetMapping("/client/app-user/deleteBalance/{id}/{amount}") xinquan-auth/src/main/java/com/xinquan/auth/controller/TokenController.java
@@ -118,6 +118,7 @@ @PostMapping("/app/register") public R<AppLoginUser> appRegister(@RequestBody AppRegisterBody appRegisterBody) { System.err.println("controller传递的邀请人id"+(appRegisterBody.getInviteUserId()==null?"":appRegisterBody.getInviteUserId())); // 用户注册 AppLoginUser appLoginUser = sysLoginService.appRegister(appRegisterBody); return R.ok(tokenService.createToken4AppLoginUser(appLoginUser)); @@ -199,7 +200,9 @@ if (data.getUserStatus() == 2){ return R.fail("您的账号已被冻结"); } return R.ok(tokenService.createToken4AppLoginUser(appLoginUser)); AppLoginUser token4AppLoginUser = tokenService.createToken4AppLoginUser(appLoginUser); System.err.println("微信登录token"+token4AppLoginUser.getAccessToken()); return R.ok(token4AppLoginUser); } /** @@ -240,8 +243,9 @@ public R<?> verifyCellPhone(@Validated @RequestBody AppVerifyCellPhoneBody body) { AppLoginUser appLoginUser = sysLoginService.verifyCellPhone(body); return R.ok(tokenService.createToken4AppLoginUser( appLoginUser)); AppLoginUser token4AppLoginUser = tokenService.createToken4AppLoginUser(appLoginUser); System.err.println("校验手机号token"+token4AppLoginUser.getAccessToken()); return R.ok(token4AppLoginUser); } /** xinquan-modules/xinquan-meditation/src/main/java/com/xinquan/meditation/service/impl/MeditationServiceImpl.java
@@ -214,15 +214,11 @@ for (ClientMeditationVO clientMeditationVO : meditationListByCateId) { Integer data = remoteOrderService.getMeditationIsBuy(loginUser.getUserid(),clientMeditationVO.getId() ).getData(); clientMeditationVO.setIsBuy(data); Long data1 = remoteAppUserService.getMeditationHistoryCount(clientMeditationVO.getId()).getData(); clientMeditationVO.setRealLearnedNum(Integer.valueOf(data1+"")); clientMeditationVO.setRealLearnedNum(clientMeditationVO.getVirtualLearnedNum()+clientMeditationVO.getRealLearnedNum()); } }else{ for (ClientMeditationVO clientMeditationVO : meditationListByCateId) { clientMeditationVO.setIsBuy(2); Long data = remoteAppUserService.getMeditationHistoryCount(clientMeditationVO.getId()).getData(); clientMeditationVO.setRealLearnedNum(Integer.valueOf(data+"")); clientMeditationVO.setRealLearnedNum(clientMeditationVO.getVirtualLearnedNum()+clientMeditationVO.getRealLearnedNum()); if (tokenService.getLoginUser()!=null){ Integer data2 = remoteOrderService.getMeditationIsBuy(tokenService.getLoginUser().getUserid() xinquan-modules/xinquan-system/src/main/java/com/xinquan/system/controller/CommonQuestionController.java
@@ -199,11 +199,13 @@ return R.tokenError("登录失效"); } Long userId = loginUser.getUserid(); String string = userId.toString(); CommissionRule one = commissionRuleService.lambdaQuery().one(); HashMap<String, String> blueCode = new HashMap<>(); blueCode.put("user_id", userId + ""); String blueS = "http://113.45.158.158/share/#/pages/register/register?userId="+userId; blueCode.put("user_id", string); System.err.println("APP推广活动页"+string); String blueS = "https://xq.xqzhihui.com/share/#/pages/register/register?userId="+string; MyQrCodeUtil.createCodeToFile(blueS); BufferedImage blueImage = QRCodeUtil.createImage(blueS); @@ -226,10 +228,11 @@ @PostMapping("/getCommissionRuleShare") @ApiOperation(value = "推广活动页",tags = "H5分享") public R<CommissionRule> getCommissionRuleShare(String userId) throws Exception { System.err.println("推广人id"+userId); CommissionRule one = commissionRuleService.lambdaQuery().one(); HashMap<String, String> blueCode = new HashMap<>(); blueCode.put("user_id", userId + ""); String blueS = "http://113.45.158.158/share/#/pages/register/register?userId="+userId; String blueS = "https://xq.xqzhihui.com/share/#/pages/register/register?userId="+userId; MyQrCodeUtil.createCodeToFile(blueS); BufferedImage blueImage = QRCodeUtil.createImage(blueS); MultipartFile blueFile = convert(blueImage, new Date().getTime() + UUIDUtil.getRandomCode(3) + ".PNG"); xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserTreeController.java
@@ -315,6 +315,190 @@ return R.ok(appUserTree); } } /** * 刷新用户观看和任务完成记录 * @return */ @PostMapping("/getUserEnergy/{id}") public R getUserEnergy(@PathVariable("id")Long id) { AppUser byId = appUserService.getById(id); 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, id) .eq(AppUserViewingHistory::getViewingType, 1) .eq(BaseModel::getDelFlag, 0) .between(AppUserViewingHistory::getCreateTime, startOfDay, endOfDay).list(); int temp = 0; for (AppUserViewingHistory appUserViewingHistory : list) { if (appUserViewingHistory.getTimeLook()!=null){ temp += appUserViewingHistory.getTimeLook(); } } AppUserTree one = appUserTreeService.lambdaQuery().eq(AppUserTree::getAppUserId, id) .eq(AppUserTree::getSowAgain, 2).one(); if (one == null) { AppUserTree appUserTree = new AppUserTree(); appUserTree.setTime(LocalDateTime.now()); appUserTree.setAppUserId(id); 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 (temp >= 3600) { if (appUserTree.getTaskOne() == 2) { AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); appUserEnergyRecord.setAppUserId(id); appUserEnergyRecord.setChangeType(1); appUserEnergyRecord.setEnergyValue(10); appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务"); appUserEnergyRecordService.save(appUserEnergyRecord); byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 10); byId.setEnergyValue(byId.getEnergyValue() + 10); } if (appUserTree.getTaskTwo() == 2) { AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); appUserEnergyRecord.setAppUserId(id); appUserEnergyRecord.setChangeType(1); appUserEnergyRecord.setEnergyValue(20); appUserEnergyRecord.setReason("完成【每日疗愈60分钟】任务"); appUserEnergyRecordService.save(appUserEnergyRecord); byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 20); byId.setEnergyValue(byId.getEnergyValue() + 20); } appUserTree.setTaskOne(1); appUserTree.setTaskTwo(1); } else if (temp >= 1800) { if (appUserTree.getTaskOne() == 2) { AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); appUserEnergyRecord.setAppUserId(id); appUserEnergyRecord.setChangeType(1); appUserEnergyRecord.setEnergyValue(10); appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务"); appUserEnergyRecordService.save(appUserEnergyRecord); byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 10); byId.setEnergyValue(byId.getEnergyValue() + 10); } appUserTree.setTaskOne(2); appUserTree.setTaskTwo(1); } else { appUserTree.setTaskOne(2); appUserTree.setTaskTwo(2); } appUserTree.setEnergyValue(byId.getEnergyValue()); appUserTree.setNextLevel(1000); appUserTreeService.save(appUserTree); appUserTree.setTotalEnergyValue(byId.getTotalEnergyValue()); return R.ok(); } else { if (temp >= 3600) { if (one.getTaskOne() == 2) { AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); appUserEnergyRecord.setAppUserId(id); appUserEnergyRecord.setChangeType(1); appUserEnergyRecord.setEnergyValue(10); appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务"); appUserEnergyRecordService.save(appUserEnergyRecord); byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 10); one.setTaskOne(1); byId.setEnergyValue(byId.getEnergyValue() + 10); } if (one.getTaskTwo() == 2) { AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); appUserEnergyRecord.setAppUserId(id); appUserEnergyRecord.setChangeType(1); appUserEnergyRecord.setEnergyValue(20); appUserEnergyRecord.setReason("完成【每日疗愈60分钟】任务"); appUserEnergyRecordService.save(appUserEnergyRecord); byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 20); one.setTaskTwo(1); byId.setEnergyValue(byId.getEnergyValue() + 20); } } else if (temp >= 1800) { if (one.getTaskOne() == 2) { AppUserEnergyRecord appUserEnergyRecord = new AppUserEnergyRecord(); appUserEnergyRecord.setAppUserId(id); appUserEnergyRecord.setChangeType(1); appUserEnergyRecord.setEnergyValue(10); appUserEnergyRecord.setReason("完成【每日疗愈30分钟】任务"); appUserEnergyRecordService.save(appUserEnergyRecord); byId.setTotalEnergyValue(byId.getTotalEnergyValue() + 10); one.setTaskOne(1); byId.setEnergyValue(byId.getEnergyValue() + 10); } } 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(); 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; 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()); appUserService.updateById(byId); return R.ok(); } } @Autowired private TokenService tokenService; @PostMapping("/restart") xinquan-modules/xinquan-user/src/main/java/com/xinquan/user/controller/client/ClientAppUserViewingHistoryController.java
@@ -13,12 +13,11 @@ import com.xinquan.course.api.feign.RemoteCourseService; import com.xinquan.meditation.api.domain.Meditation; import com.xinquan.meditation.api.feign.RemoteMeditationService; import com.xinquan.system.api.domain.AppUser; import com.xinquan.system.api.domain.AppUserTree; import com.xinquan.system.api.domain.AppUserViewingHistory; import com.xinquan.system.api.domain.*; import com.xinquan.system.api.domain.vo.AppUserVO; import com.xinquan.system.api.model.LoginUser; import com.xinquan.user.api.feign.RemoteAppUserService; import com.xinquan.user.service.AppUserEnergyRecordService; import com.xinquan.user.service.AppUserService; import com.xinquan.user.service.AppUserTreeService; import com.xinquan.user.service.AppUserViewingHistoryService; @@ -71,6 +70,7 @@ /** * 远程调用 根据章节id和用户id查询是否观看完毕 * * @param id * @return */ @@ -91,6 +91,7 @@ /** * 远程调用查询用户观看了哪些课程 * * @return */ @PostMapping("/getCourseHistoryByUserId/{id}") @@ -102,6 +103,7 @@ .collect(Collectors.toList()); return R.ok(one); } @PostMapping("/getMeditationHistoryCount/{id}") public R<Long> getMeditationHistoryCount(@PathVariable("id") Long id) { List<AppUserViewingHistory> list = appUserViewingHistoryService.lambdaQuery() @@ -111,6 +113,7 @@ .list(); return R.ok(Long.valueOf(list.size())); } @PostMapping("/getCourseHistoryCount/{id}") public R<Long> getCourseHistoryCount(@PathVariable("id") Long id) { List<AppUserViewingHistory> list = appUserViewingHistoryService.lambdaQuery() @@ -119,6 +122,7 @@ .list(); return R.ok(Long.valueOf(list.size())); } @PostMapping("/getCourseChapterHistoryCount/{id}") public R<Long> getCourseChapterHistoryCount(@PathVariable("id") Long id) { List<AppUserViewingHistory> list = appUserViewingHistoryService.lambdaQuery() @@ -128,6 +132,7 @@ .list(); return R.ok(Long.valueOf(list.size())); } @PostMapping("/lookHistory") @ApiOperation(value = "观看历史") @ApiImplicitParams({ @@ -215,9 +220,9 @@ } return R.ok(orderCourseVOS); } /** * 记录用户观看记录 * */ @PostMapping("/saveViewingHistory") @ApiOperation(value = "记录用户观看冥想记录", tags = {"用户端-用户相关接口"}) @@ -240,8 +245,139 @@ appUserViewingHistory.setTimeLook(timeLook); appUserViewingHistory.setCreateTime(LocalDateTime.now()); appUserViewingHistoryService.save(appUserViewingHistory); AppUser byId = appUserService.getById(userId); 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 appUserViewingHistory1 : list) { if (appUserViewingHistory1.getTimeLook() != null) { temp += appUserViewingHistory1.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 (temp >= 3600) { 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); byId.setEnergyValue(byId.getEnergyValue() + 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); byId.setEnergyValue(byId.getEnergyValue() + 20); } appUserTree.setTaskOne(1); appUserTree.setTaskTwo(1); } else if (temp >= 1800) { 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); byId.setEnergyValue(byId.getEnergyValue() + 10); } appUserTree.setTaskOne(2); appUserTree.setTaskTwo(1); } 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 >= 3600) { 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); byId.setEnergyValue(byId.getEnergyValue() + 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.setTaskTwo(1); byId.setEnergyValue(byId.getEnergyValue() + 20); } } else if (temp >= 1800) { 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); byId.setEnergyValue(byId.getEnergyValue() + 10); } } else { one.setTaskOne(2); one.setTaskTwo(2); } appUserTreeService.updateById(one); appUserService.updateById(byId); return R.ok(); } } @Resource private AppUserEnergyRecordService appUserEnergyRecordService; @PostMapping("/saveCourseStudyHistory") @ApiOperation(value = "记录用户观看课程记录", tags = {"用户端-用户相关接口"}) @ApiImplicitParams({ @@ -289,6 +425,7 @@ } return R.ok(); } @PostMapping("/getCourseStudyHistory") public R<AppUserViewingHistory> getCourseStudyHistory(@RequestParam("chapterId") Long chapterId) { LoginUser loginUser = tokenService.getLoginUser();