| | |
| | | // 可获得积分不为null时,才添加积分明细记录 |
| | | if (null != availableIntegral && !Constants.ZERO.equals(availableIntegral)) { |
| | | add = add && integralRecordService.add(String.valueOf(availableIntegral), |
| | | Constants.COMPLETE_GAME, completeStudy.getGameId(), null, difficulty); |
| | | Constants.COMPLETE_GAME, completeStudy.getGameId(), null, difficulty, null); |
| | | // 用户账户添加积分 |
| | | TUser user = userService.getById(userid); |
| | | user.setIntegral(user.getIntegral() + availableIntegral); |
| | |
| | | Integer userId = loginUserStudy.getUserid(); |
| | | Boolean result = true; |
| | | // 学习时长更新 |
| | | TStudy study = studyService.lambdaQuery().eq(TStudy::getId, storyListen.getStudyId()) |
| | | .eq(TStudy::getDisabled, 0).one(); |
| | | TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId) |
| | | .eq(TUserStudy::getDisabled, 0).one(); |
| | | if (null == userStudy) { |
| | | userStudy = createUserStudy(userId); |
| | | } |
| | | userStudy.setTotalStudy(userStudy.getTotalStudy() + studyTime); |
| | | userStudy.setTodayStudy(userStudy.getTodayStudy() + studyTime); |
| | | userStudy.setWeekStudy(userStudy.getWeekStudy() + studyTime); |
| | | userStudy.setMonthStudy(userStudy.getMonthStudy() + studyTime); |
| | | } |
| | | boolean update = userStudyService.updateById(userStudy); |
| | | if (!update) { |
| | | throw new GlobalException("学习时长更新失败!"); |
| | |
| | | throw new GlobalException("自主故事-看图配音正确率异常!"); |
| | | } |
| | | // 看图配音模式,也需要根据游戏正确率计算积分 |
| | | int integral = storyListen.getLookIntegral() * (accuracy / 100); |
| | | double d = (double) accuracy / 100; |
| | | int integral = (int) (storyListen.getLookIntegral() * d); |
| | | int obtainedIntegral; |
| | | // 看图配音已获取积分数量 |
| | | List<TUserStudyRecord> list = studyRecordService.lambdaQuery() |
| | | .eq(TUserStudyRecord::getStoryId, storyId) |
| | | .eq(TUserStudyRecord::getType, 1) |
| | | .eq(TUserStudyRecord::getQuarter, study.getQuarter()) |
| | | .eq(TUserStudyRecord::getWeek, storyListen.getWeek()) |
| | | .eq(TUserStudyRecord::getUserId, userId).list(); |
| | | if (list.isEmpty()) { |
| | | obtainedIntegral = 0; |
| | |
| | | .mapToInt(Integer::intValue).sum(); |
| | | } |
| | | // 可获得积分计算 |
| | | if (integral > obtainedIntegral) { |
| | | int i = integral - obtainedIntegral; |
| | | if (i > 0) { |
| | | TUserStudyRecord data = new TUserStudyRecord(); |
| | | data.setUserId(userId); |
| | | data.setObtainedIntegral(integral - obtainedIntegral); |
| | | data.setObtainedIntegral(i); |
| | | data.setType(Constants.ONE); |
| | | data.setStoryId(storyId); |
| | | data.setQuarter(study.getQuarter()); |
| | | data.setWeek(storyListen.getWeek()); |
| | | result = studyRecordService.save(data); |
| | | sum = integral - obtainedIntegral; |
| | | sum = i; |
| | | // 添加积分明细记录 |
| | | result = integralRecordService.add(String.valueOf(sum), |
| | | Constants.COMPLETE_STORY, null, storyId, null, Constants.ZERO); |
| | | TUser user = userService.lambdaQuery().eq(TUser::getId, userId).one(); |
| | | // 添加积分 |
| | | user.setIntegral(user.getIntegral() + sum); |
| | | result = result && userService.updateById(user); |
| | | } |
| | | } else { |
| | | // 超级记忆只有首次才能获取积分 |
| | | TIntegralRecord integralRecord = integralRecordService.lambdaQuery() |
| | | .eq(TIntegralRecord::getUserId, userId) |
| | | .eq(TIntegralRecord::getStoryId, storyId) |
| | | .eq(TIntegralRecord::getDisabled, 0).one(); |
| | | .eq(TIntegralRecord::getDisabled, 0) |
| | | .eq(TIntegralRecord::getStoryType, Constants.ONE) |
| | | .one(); |
| | | if (null == integralRecord) { |
| | | // 添加积分明细记录 |
| | | result = integralRecordService.add(String.valueOf(storyListen.getIntegral()), |
| | | Constants.COMPLETE_STORY, null, storyId, null); |
| | | Constants.COMPLETE_STORY, null, storyId, null, Constants.ONE); |
| | | TUser user = userService.lambdaQuery().eq(TUser::getId, userId).one(); |
| | | // 添加积分 |
| | | user.setIntegral(user.getIntegral() + storyListen.getIntegral()); |