From 770de42c8bbb10676663f33e2748c733c993d27b Mon Sep 17 00:00:00 2001
From: hjl <1657978663@qq.com>
Date: 星期四, 20 六月 2024 15:28:42 +0800
Subject: [PATCH] fix: 学习端bug

---
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java |  290 +++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 236 insertions(+), 54 deletions(-)

diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
index fb9e2fb..d35dab6 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java
@@ -2,7 +2,6 @@
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.core.constant.Constants;
 import com.ruoyi.common.core.domain.R;
@@ -220,10 +219,14 @@
                 studyId.setAnswerTime(game.getAnswerTime());
                 studyId.setAnswerIntegral(game.getAnswerIntegral());
                 studyId.setAnswerCount(game.getAnswerCount());
+                studyId.setRate(game.getRate());
+                studyId.setAnswerRate(game.getAnswerRate());
                 gameService.updateById(studyId);
             } else {
                 TGame tGame = new TGame();
                 tGame.setWeek(dto.getWeek());
+                tGame.setAnswerRate(game.getAnswerRate());
+                tGame.setRate(game.getRate());
                 tGame.setStudyId(one.getId());
                 tGame.setCount(game.getCount());
                 tGame.setIntegral(game.getIntegral());
@@ -601,7 +604,6 @@
                 studyPairVO.setIsVip(tStudyPair.getIsVip());
                 pairVOS.add(studyPairVO);
             }
-
         }
         List<TGame> list5 = gameService.list(new QueryWrapper<TGame>()
                 .eq("week", week));
@@ -613,6 +615,8 @@
             gameVO.setAnswerTime(tGame.getAnswerTime());
             gameVO.setAnswerIntegral(tGame.getAnswerIntegral());
             gameVO.setAnswerCount(tGame.getAnswerCount());
+            gameVO.setRate(tGame.getRate());
+            gameVO.setAnswerRate(tGame.getAnswerRate());
             gameVOS.add(gameVO);
         }
         List<TStoryListen> list6 = storyListenService.list(new QueryWrapper<TStoryListen>()
@@ -710,13 +714,28 @@
         if (null == loginStudy) {
             return R.tokenError("登录失效!");
         }
-        TUserStudy result = studyService.studySchedule(String.valueOf(loginStudy.getUserid()));
-        if (null != result) {
+        Integer userid = loginStudy.getUserid();
+        TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, loginStudy.getUserid())
+                .eq(TUserStudy::getDisabled, 0).one();
+        if (null != studyRecord) {
             // 计算当前周 day 1-5的总进度
-            int computeSchedule = studyService.computeSchedule(result, week);
-            result.setComputeSchedule(computeSchedule);
+            int computeSchedule = studyService.computeSchedule(studyRecord, week);
+            studyRecord.setComputeSchedule(computeSchedule);
+            // 学习时长格式转换
+            Integer todayStudy = studyRecord.getTodayStudy();
+            studyRecord.setTodayStudy(Math.round((float) todayStudy / 3600));
+            Integer weekStudy = studyRecord.getWeekStudy();
+            studyRecord.setWeekStudy(Math.round((float) weekStudy / 3600));
+            Integer monthStudy = studyRecord.getMonthStudy();
+            studyRecord.setMonthStudy(Math.round((float) monthStudy / 3600));
+            // 总时长还需计算上游戏测试成绩时长
+            List<TGameRecord> gameRecordList = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userid)
+                    .eq(TGameRecord::getDisabled, 0).list();
+            int sum = gameRecordList.stream().map(TGameRecord::getUseTime).mapToInt(Integer::intValue).sum();
+            Integer totalStudy = studyRecord.getTotalStudy();
+            studyRecord.setTotalStudy(Math.round((float) (totalStudy + sum) / 3600));
         }
-        return R.ok(result);
+        return R.ok(studyRecord);
     }
 
     /**
@@ -732,7 +751,11 @@
             @ApiImplicitParam(value = "季度 首次进入季度quarter默认传1", name = "quarter", dataType = "Integer", required = true)
     })
     public R<List<StudyWeekDTO>> weekList(@RequestParam(defaultValue = "1") Integer type, @RequestParam Integer quarter) {
-        List<StudyWeekDTO> result = studyService.weekList(type, quarter);
+        LoginUserParent loginUserStudy = tokenService.getLoginUserStudy();
+        if (null == loginUserStudy) {
+            return R.tokenError("登录失效!");
+        }
+        List<StudyWeekDTO> result = studyService.weekList(type, quarter,loginUserStudy.getUserid());
         return R.ok(result);
     }
 
@@ -809,7 +832,7 @@
                     .collect(Collectors.toList());
             result = new SubjectRecordResultVO(teamIds, topicIds, subjectRecord.getAnswerNumber(), subjectRecord.getCorrectNumber());
         } else {
-            result = new SubjectRecordResultVO();
+            result = null;
         }
         subjectRecordService.lambdaUpdate().set(TSubjectRecord::getDisabled, 0)
                 .eq(TSubjectRecord::getUserId, loginStudy.getUserid()).update();
@@ -831,32 +854,71 @@
         TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userid)
                 .eq(TUserStudy::getDisabled, 0).one();
         if (null == userStudy) {
-            throw new GlobalException("登录用户学习记录不存在!");
+            userStudy = createUserStudy(userid);
         }
+        Integer quarter = exitLearn.getQuarter();
+        Integer week = exitLearn.getWeek();
+        Integer day = exitLearn.getDay();
         if (userStudy.getWeek().equals(exitLearn.getWeek()) && userStudy.getDay().equals(exitLearn.getDay())) {
             // 计算完成率
-            int completionRate = exitLearn.getTopicIds().split(",").length * 5;
             Integer type = exitLearn.getType();
             // 更新用户学习完成率
-            LambdaUpdateChainWrapper<TUserStudy> wrapper = userStudyService.lambdaUpdate();
-            if (Constants.ONE.equals(type) && userStudy.getListen() < completionRate) {
+            if (Constants.ONE.equals(type)) {
                 // 听音选图
-                wrapper.set(TUserStudy::getListen, completionRate);
-            } else if (Constants.TWO.equals(type) && userStudy.getLook() < completionRate) {
+                List<TStudyListen> studyListens = studyListenService.listenSelectPicture(quarter, week, day);
+                int item = 0;
+                for (TStudyListen studyListen : studyListens) {
+                    item += studyListen.getSubject().split(",").length;
+                }
+                int i = (int) ((double) (exitLearn.getTopicIds().split(",").length / item) * 100);
+                if (i > userStudy.getListen()) {
+                    userStudy.setListen(100 - i);
+                }
+            } else if (Constants.TWO.equals(type)) {
                 // 看图选音
-                wrapper.set(TUserStudy::getLook, completionRate);
-            } else if (Constants.THREE.equals(type) && userStudy.getInduction() < completionRate) {
+                List<TStudyLook> lookList = studyLookService.pictureSelectVoice(quarter, week, day);
+                if (!lookList.isEmpty()) {
+                    int item = lookList.size();
+                    int i = (int) ((double) (exitLearn.getSchedule() / item)) * 100;
+                    if (i > userStudy.getLook()) {
+                        userStudy.setLook(100 - i);
+                    }
+                }
+            } else if (Constants.THREE.equals(type)) {
                 // 归纳排除
-                wrapper.set(TUserStudy::getInduction, completionRate);
-            } else if (Constants.FOUR.equals(type) && userStudy.getAnswer() < completionRate) {
+                List<TStudyInduction> inductionList = studyInductionService.induceExclude(quarter, week, day);
+                if (!inductionList.isEmpty()) {
+                    int item = inductionList.size();
+                    int i = (int) ((double) (exitLearn.getSchedule() / item)) * 100;
+                    if (i > userStudy.getInduction()) {
+                        userStudy.setInduction(100 - i);
+                    }
+                }
+            } else if (Constants.FOUR.equals(type)) {
                 // 有问有答
-                wrapper.set(TUserStudy::getAnswer, completionRate);
-            } else if (Constants.FIVE.equals(type) && userStudy.getPair() < completionRate) {
+                List<TStudyAnswer> answerList = studyAnswerService.questionsAndAnswers(quarter, week, day);
+                if (answerList.size() % Constants.TWO == Constants.ZERO) {
+                    int i = (int) ((double) (exitLearn.getSchedule() / (answerList.size() / 2))) * 100;
+                    if (i > userStudy.getAnswer()) {
+                        userStudy.setAnswer(100 - i);
+                    }
+                }
+            } else if (Constants.FIVE.equals(type)) {
                 // 音图相配
-                wrapper.set(TUserStudy::getPair, completionRate);
+                List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day);
+                int item = pairList.size();
+                int i = (int) ((double) (exitLearn.getSchedule() / item)) * 100;
+                if (i > userStudy.getPair()) {
+                    userStudy.setPair(100 - i);
+                }
             }
-            wrapper.eq(TUserStudy::getUserId, userid).update();
         }
+        // 学习时长更新
+        userStudy.setTotalStudy(userStudy.getTotalStudy() + exitLearn.getStudyTime());
+        userStudy.setTodayStudy(userStudy.getTodayStudy() + exitLearn.getStudyTime());
+        userStudy.setWeekStudy(userStudy.getWeekStudy() + exitLearn.getStudyTime());
+        userStudy.setMonthStudy(userStudy.getMonthStudy() + exitLearn.getStudyTime());
+        userStudyService.updateById(userStudy);
         return R.ok(subjectRecordService.exitLearning(exitLearn, userid));
     }
 
@@ -880,7 +942,7 @@
         // 非会员只能查看非会员题目,会员可以查看所有题目
         List<TStudyListen> studyListens = studyListenService.listenSelectPicture(quarter, week, day);
         for (TStudyListen studyListen : studyListens) {
-            if (studyListen.getIsVip() == 1) {
+            if (studyListen.getIsVip() == 0) {
                 // 需要会员查看
                 if (!isVip) {
                     // 不是会员
@@ -911,7 +973,7 @@
         // 非会员只能查看非会员题目,会员可以查看所有题目
         List<TStudyLook> lookList = studyLookService.pictureSelectVoice(quarter, week, day);
         for (TStudyLook studyListen : lookList) {
-            if (studyListen.getIsVip() == 1) {
+            if (studyListen.getIsVip() == 0) {
                 // 需要会员查看
                 if (!isVip) {
                     // 不是会员
@@ -942,7 +1004,7 @@
         // 非会员只能查看非会员题目,会员可以查看所有题目
         List<TStudyInduction> inductionList = studyInductionService.induceExclude(quarter, week, day);
         for (TStudyInduction studyListen : inductionList) {
-            if (studyListen.getIsVip() == 1) {
+            if (studyListen.getIsVip() == 0) {
                 // 需要会员查看
                 if (!isVip) {
                     // 不是会员
@@ -973,7 +1035,7 @@
         // 非会员只能查看非会员题目,会员可以查看所有题目
         List<TStudyAnswer> answerList = studyAnswerService.questionsAndAnswers(quarter, week, day);
         for (TStudyAnswer studyListen : answerList) {
-            if (studyListen.getIsVip() == 1) {
+            if (studyListen.getIsVip() == 0) {
                 // 需要会员查看
                 if (!isVip) {
                     // 不是会员
@@ -1004,7 +1066,7 @@
         // 非会员只能查看非会员题目,会员可以查看所有题目
         List<TStudyPair> pairList = studyPairService.pictureMateVoice(quarter, week, day);
         for (TStudyPair pair : pairList) {
-            if (pair.getIsVip() == 1) {
+            if (pair.getIsVip() == 0) {
                 // 需要会员查看
                 if (!isVip) {
                     // 不是会员
@@ -1073,14 +1135,13 @@
             record.setType(Constants.ZERO);
             update = update && studyRecordService.save(record);
         }
-        // 学习配置列表
-        List<TStudy> studyList = studyService.lambdaQuery().eq(TStudy::getDisabled, 0)
-                .orderByAsc(TStudy::getWeek).list();
-        if (studyList.isEmpty()) {
-            throw new GlobalException("学习配置列表未配置或数据失效!");
-        }
         // 更改学习记录
-        Boolean updateStudyRecord = userStudyService.exchangeStudyRecord(studyList, userId, completeStudy);
+        TUserStudy userStudyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId)
+                .eq(TUserStudy::getDisabled, 0).one();
+        if (null == userStudyRecord) {
+            userStudyRecord = createUserStudy(userId);
+        }
+        Boolean updateStudyRecord = userStudyService.exchangeStudyRecord(userStudyRecord, userId, completeStudy);
         return R.ok(update && updateStudyRecord);
     }
 
@@ -1218,8 +1279,8 @@
     @PostMapping("/gameAchievement")
     @ApiOperation(value = "完成游戏-记录游戏测试成绩", tags = {"学习端-听-自主游戏"})
     public R<Boolean> gameAchievement(@RequestBody CompleteGameDTO completeStudy) {
-        LoginUserParent userStudy = tokenService.getLoginUserStudy();
-        if (null == userStudy) {
+        LoginUserParent loginUserStudy = tokenService.getLoginUserStudy();
+        if (null == loginUserStudy) {
             return R.tokenError("登录失效!");
         }
         /*
@@ -1227,7 +1288,7 @@
          * 并且需要判断如果该游戏用户已获取一部分积分,再次测试后正确率增长,只能获取高于上次正确率的部分积分
          * 例如:游戏配置的积分是100,他的正确率是50%那么拿50分,下次他再玩这个游戏 正确率是60% 那么他该获得60分 但是上次已经拿了50 所以这次就只给他加10积分
          */
-        Integer userid = userStudy.getUserid();
+        Integer userid = loginUserStudy.getUserid();
         TGame game = gameService.lambdaQuery().eq(TGame::getId, completeStudy.getGameId()).eq(TGame::getDisabled, 0).one();
         if (null == game) {
             throw new GlobalException("游戏信息异常!");
@@ -1257,6 +1318,17 @@
             user.setIntegral(user.getIntegral() + availableIntegral);
             add = add && userService.updateById(user);
         }
+        // 学习时长更新
+        TUserStudy userStudy = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userid)
+                .eq(TUserStudy::getDisabled, 0).one();
+        if (null == userStudy) {
+            userStudy = createUserStudy(userid);
+            userStudy.setTotalStudy(userStudy.getTotalStudy() + completeStudy.getUseTime());
+            userStudy.setTodayStudy(userStudy.getTodayStudy() + completeStudy.getUseTime());
+            userStudy.setWeekStudy(userStudy.getWeekStudy() + completeStudy.getUseTime());
+            userStudy.setMonthStudy(userStudy.getMonthStudy() + completeStudy.getUseTime());
+        }
+        boolean update = userStudyService.updateById(userStudy);
         // 超级记忆逻辑
         if (Constants.MEMORY.equals(completeStudy.getGameName())) {
             // 学习配置列表
@@ -1267,13 +1339,35 @@
             }
             // 超级记忆正确率达到通关率标准,才能进入下一周目学习
             userStudyService.checkRate(game, userid, completeStudy, studyList);
-            return R.ok(add && completeStudy.getAccuracy() >= Integer.parseInt(game.getAnswerRate()));
+            add = add && completeStudy.getAccuracy() >= Integer.parseInt(game.getAnswerRate());
         } else {
             // 超级听力需根据正确率判断是否允许进入下一难度
             userStudyService.gameHearing(game, userid, completeStudy);
             String rate = game.getRate().split(",")[completeStudy.getDifficulty()];
-            return R.ok(add && completeStudy.getAccuracy() >= Integer.parseInt(rate));
+            add = add && completeStudy.getAccuracy() >= Integer.parseInt(rate);
         }
+        return R.ok(add && update);
+    }
+
+    private TUserStudy createUserStudy(Integer userid) {
+        TUserStudy userStudy = new TUserStudy();
+        userStudy.setUserId(userid);
+        // 学习周目
+        TStudy tStudy = studyService.lambdaQuery().eq(TStudy::getQuarter, Constants.ONE)
+                .orderByAsc(TStudy::getWeek).last("limit 1").one();
+        userStudy.setWeek(tStudy.getWeek());
+        userStudy.setDay(Constants.ONE);
+        userStudy.setTotalStudy(Constants.ZERO);
+        userStudy.setTodayStudy(Constants.ZERO);
+        userStudy.setWeekStudy(Constants.ZERO);
+        userStudy.setMonthStudy(Constants.ZERO);
+        userStudy.setListen(Constants.BURDEN_ONE);
+        userStudy.setLook(Constants.BURDEN_ONE);
+        userStudy.setInduction(Constants.BURDEN_ONE);
+        userStudy.setAnswer(Constants.BURDEN_ONE);
+        userStudy.setPair(Constants.BURDEN_ONE);
+        userStudyService.save(userStudy);
+        return userStudy;
     }
 
     private List<String> getSubjectId(Integer week) {
@@ -1360,21 +1454,38 @@
     @ApiImplicitParams({
             @ApiImplicitParam(value = "故事id", name = "storyId", dataType = "Integer", required = true),
             @ApiImplicitParam(value = "类型(1:看图配音;2:超级记忆)", name = "type", dataType = "Integer", required = true),
-            @ApiImplicitParam(value = "正确率", name = "accuracy", dataType = "Integer")
+            @ApiImplicitParam(value = "正确率", name = "accuracy", dataType = "Integer"),
+            @ApiImplicitParam(value = "学习时长(秒)", name = "studyTime", dataType = "Integer", required = true)
     })
-    public R<Boolean> completeStory(@RequestParam Integer storyId, @RequestParam Integer type, Integer accuracy) {
+    public R<Boolean> completeStory(@RequestParam Integer storyId, @RequestParam Integer type,
+                                    Integer accuracy, @RequestParam Integer studyTime) {
         TStoryListen storyListen = storyListenService.lambdaQuery().eq(TStoryListen::getId, storyId)
                 .eq(TStoryListen::getDisabled, 0).one();
         if (null == storyListen) {
             throw new GlobalException("当前故事学习失败,故事信息异常,请重试!");
         }
-        LoginUserParent userStudy = tokenService.getLoginUserStudy();
-        if (null == userStudy) {
+        LoginUserParent loginUserStudy = tokenService.getLoginUserStudy();
+        if (null == loginUserStudy) {
             return R.tokenError("登录失效!");
         }
         // 用户信息
-        Integer userId = userStudy.getUserid();
+        Integer userId = loginUserStudy.getUserid();
         Boolean result = true;
+        // 学习时长更新
+        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("学习时长更新失败!");
+        }
+        // 根据故事类型不同,逻辑处理
         if (Constants.ONE.equals(type)) {
             if (null == accuracy) {
                 throw new GlobalException("自主故事-看图配音正确率异常!");
@@ -1389,7 +1500,8 @@
             if (list.isEmpty()) {
                 obtainedIntegral = 0;
             } else {
-                obtainedIntegral = list.stream().map(TUserStudyRecord::getObtainedIntegral).mapToInt(Integer::intValue).sum();
+                obtainedIntegral = list.stream().map(TUserStudyRecord::getObtainedIntegral)
+                        .mapToInt(Integer::intValue).sum();
             }
             // 可获得积分计算
             if (integral > obtainedIntegral) {
@@ -1430,9 +1542,26 @@
         // 学习记录
         TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId)
                 .eq(TUserStudy::getDisabled, 0).one();
-        // 游戏测试成绩
+        // 总时长还需计算上游戏测试成绩时长
         List<TGameRecord> gameRecordList = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userId)
                 .eq(TGameRecord::getDisabled, 0).list();
+        if (null != studyRecord) {
+            // 学习时长格式转换
+            Integer todayStudy = studyRecord.getTodayStudy();
+            studyRecord.setTodayStudy(Math.round((float) todayStudy / 3600));
+            Integer weekStudy = studyRecord.getWeekStudy();
+            studyRecord.setWeekStudy(Math.round((float) weekStudy / 3600));
+            Integer monthStudy = studyRecord.getMonthStudy();
+            studyRecord.setMonthStudy(Math.round((float) monthStudy / 3600));
+            // 游戏总时长
+            int sum = gameRecordList.stream().map(TGameRecord::getUseTime).mapToInt(Integer::intValue).sum();
+            Integer totalStudy = studyRecord.getTotalStudy();
+            studyRecord.setTotalStudy(Math.round((float) (totalStudy + sum) / 3600));
+            // 剩余周目
+            int size = studyService.list(new QueryWrapper<TStudy>()
+                    .eq("type", 1)).size();
+            studyRecord.setSurplus(size - studyRecord.getWeek());
+        }
         return R.ok(new StudyRecordResultVO(studyRecord, gameRecordList));
     }
 
@@ -1440,6 +1569,7 @@
     @ApiOperation(value = "游戏测试成绩", tags = {"家长端-游戏测试成绩"})
     public R<StudyRecordResultVO> record() {
         LoginUserParent loginUser1 = tokenService.getLoginUser1();
+        System.err.println("用户登录信息:" + loginUser1);
         if (loginUser1 == null) {
             return R.tokenError("登陆失效,请重新登录");
         }
@@ -1457,11 +1587,25 @@
             TUserStudy tUserStudy = new TUserStudy();
             tUserStudy.setSurplus(studyService.list(new QueryWrapper<TStudy>()
                     .eq("type", 1)).size());
+            tUserStudy.setTodayStudy(Constants.ZERO);
+            tUserStudy.setTotalStudy(Constants.ZERO);
+            tUserStudy.setWeekStudy(Constants.ZERO);
+            tUserStudy.setMonthStudy(Constants.ZERO);
             studyRecord = tUserStudy;
         }
-        // 游戏测试成绩
+        // 学习时长格式转换
+        Integer todayStudy = studyRecord.getTodayStudy();
+        studyRecord.setTodayStudy(Math.round((float) todayStudy / 3600));
+        Integer weekStudy = studyRecord.getWeekStudy();
+        studyRecord.setWeekStudy(Math.round((float) weekStudy / 3600));
+        Integer monthStudy = studyRecord.getMonthStudy();
+        studyRecord.setMonthStudy(Math.round((float) monthStudy / 3600));
+        // 总时长还需计算上游戏测试成绩时长
         List<TGameRecord> gameRecordList = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, userId)
                 .eq(TGameRecord::getDisabled, 0).list();
+        int sum = gameRecordList.stream().map(TGameRecord::getUseTime).mapToInt(Integer::intValue).sum();
+        Integer totalStudy = studyRecord.getTotalStudy();
+        studyRecord.setTotalStudy(Math.round((float) (totalStudy + sum) / 3600));
         return R.ok(new StudyRecordResultVO(studyRecord, gameRecordList));
     }
 
@@ -1498,17 +1642,18 @@
     @GetMapping("/integralDetailParent")
     @ApiOperation(value = "个人中心-积分明细", tags = {"家长端"})
     @ApiImplicitParams({
-            @ApiImplicitParam(value = "查询时间 格式yyyy-MM", name = "time", dataType = "Integer"),
-            @ApiImplicitParam(value = "页码", name = "pageNum", dataType = "Integer", required = true),
-            @ApiImplicitParam(value = "每页显示条数", name = "pageSize", dataType = "Integer", required = true)
+            @ApiImplicitParam(value = "查询时间 格式yyyy-MM", name = "time"),
+            @ApiImplicitParam(value = "页码", name = "pageNum", required = true),
+            @ApiImplicitParam(value = "每页显示条数", name = "pageSize", required = true)
     })
     public R<IPage<TIntegralRecord>> integralDetailParent(String time,
-                                                          Integer pageNum,
-                                                          Integer pageSize) {
+                                                          @RequestParam("pageNum") Integer pageNum,
+                                                          @RequestParam("pageSize") Integer pageSize) {
+        System.err.println("页码" + pageNum);
+        System.err.println("页数" + pageSize);
         if (tokenService.getLoginUser1() == null) {
             return R.tokenError("登录失效");
         }
-
         return R.ok(integralRecordService.integralDetail(new Page<>(pageNum, pageSize), tokenService.getLoginUser1().getUserid(), time));
     }
 
@@ -1527,6 +1672,28 @@
     public R<Boolean> addIntegralDetail(@RequestParam("integral") String integral, @RequestParam("method") String method) {
         // 当前登录用户
         LoginUserParent userStudy = tokenService.getLoginUserStudy();
+        // 生成积分明细信息
+        TIntegralRecord integralRecord = new TIntegralRecord();
+        integralRecord.setIntegral(integral);
+        integralRecord.setMethod(method);
+        integralRecord.setUserId(userStudy.getUserid());
+        integralRecord.setDisabled(Boolean.FALSE);
+        integralRecord.setCreateBy(userStudy.getPhone());
+        integralRecord.setCreateTime(new Date());
+        integralRecord.setUpdateBy(userStudy.getPhone());
+        integralRecord.setUpdateTime(new Date());
+        return R.ok(integralRecordService.save(integralRecord));
+    }
+
+    @GetMapping("/addIntegralDetailParent")
+//    @ApiOperation(value = "添加-积分明细", tags = {"添加-积分明细"})
+    @ApiImplicitParams({
+            @ApiImplicitParam(value = "积分数量", name = "integral", dataType = "Integer", required = true),
+            @ApiImplicitParam(value = "变动源(完成学习、完成游戏...)", name = "method", dataType = "String", required = true)
+    })
+    public R<Boolean> addIntegralDetailParent(@RequestParam("integral") String integral, @RequestParam("method") String method) {
+        // 当前登录用户
+        LoginUserParent userStudy = tokenService.getLoginUser1();
         // 生成积分明细信息
         TIntegralRecord integralRecord = new TIntegralRecord();
         integralRecord.setIntegral(integral);
@@ -1583,6 +1750,21 @@
         return R.ok(userService.updateById(user));
     }
 
+    @GetMapping("/exchangeIntegralParent")
+//    @ApiOperation(value = "用户积分变动", tags = {"用户积分变动"})
+    public R<Boolean> exchangeIntegralParent(@RequestParam("integral") Integer integral, @RequestParam("method") String method) {
+        if (tokenService.getLoginUser1() == null) {
+            return R.tokenError("登录失效");
+        }
+        TUser user = userService.getById(tokenService.getLoginUser1().getUserid());
+        if (Constants.BURDEN.equals(method)) {
+            user.setIntegral(user.getIntegral() - integral);
+        } else {
+            user.setIntegral(user.getIntegral() + integral);
+        }
+        return R.ok(userService.updateById(user));
+    }
+
     @GetMapping("/exchangeIntegral1")
 //    @ApiOperation(value = "用户积分变动", tags = {"用户积分变动"})
     public R<Boolean> exchangeIntegral1(@RequestParam("integral") Integer integral, @RequestParam("method") String method) {

--
Gitblit v1.7.1