From aa34f5b4a80eec408185cc36500149679e1a71c9 Mon Sep 17 00:00:00 2001
From: hjl <1657978663@qq.com>
Date: 星期三, 19 六月 2024 09:40:50 +0800
Subject: [PATCH] fix: 学习端bug

---
 ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java             |   15 ++-
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java          |   12 --
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TStudyController.java             |   85 ++++++++++++++++-----
 ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/dto/GoodExchangeDTO.java                     |    7 +
 ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java |   22 ++--
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/vo/ExitLearnVO.java                          |    6 +
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java              |   22 ++--
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TUserStudyServiceImpl.java      |   62 +++++++--------
 ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/ITGoodsService.java                  |    2 
 9 files changed, 142 insertions(+), 91 deletions(-)

diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java
index 963d895..661ab20 100644
--- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java
+++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/service/TokenService.java
@@ -220,17 +220,17 @@
             String userkey = JwtUtils.getUserKeyStudy(token);
             user = redisService.getCacheObject(getTokenKeyStudy(userkey));
             // 再次判断登录状态是否已过期
-//            if (null == user) {
-//                throw new StudyLoginException("登录信息已过期,请重新登录!", 504);
-//            }
-//            // 优先判断当前账号是否已在其他设备登录
-//            if (!user.getIsCanLogin()) {
-//                throw new StudyLoginException("当前登录账号在其他设备登录!", 505);
-//            }
-//            // 再次判断登录状态是否已过期
-//            if (System.currentTimeMillis() > user.getExpireTime()) {
-//                throw new StudyLoginException("登录信息已过期,请重新登录!", 504);
-//            }
+            if (null == user) {
+                throw new StudyLoginException("登录信息已过期,请重新登录!", 504);
+            }
+            // 优先判断当前账号是否已在其他设备登录
+            if (!user.getIsCanLogin()) {
+                throw new StudyLoginException("当前登录账号在其他设备登录!", 505);
+            }
+            // 再次判断登录状态是否已过期
+            if (System.currentTimeMillis() > user.getExpireTime()) {
+                throw new StudyLoginException("登录信息已过期,请重新登录!", 504);
+            }
             return user;
         }
         return user;
diff --git a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
index 48ebee7..e806e35 100644
--- a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
+++ b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/controller/TGoodsController.java
@@ -25,6 +25,7 @@
 import io.swagger.annotations.ApiOperationSupport;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -287,6 +288,7 @@
         }
         TOrder byId = orderService.getById(id);
         byId.setState(3);
+        byId.setCompleteTime(new Date());
         return R.ok(orderService.updateById(byId));
     }
 
@@ -615,6 +617,9 @@
             @ApiImplicitParam(value = "商品id", name = "goodId", dataType = "String", required = true)
     })
     public R<GoodDetailVO> goodDetail(@RequestParam String goodId) {
+        if (tokenService.getLoginUserStudy() == null) {
+            return R.tokenError("登录失效!");
+        }
         // 商品详情
         TGoods goods = goodsService.lambdaQuery().eq(TGoods::getId, goodId).one();
         if (null == goods) {
@@ -673,7 +678,8 @@
         }
         Recipient recipient = recipientService.lambdaQuery()
                 .eq(Recipient::getUserId, tokenService.getLoginUserStudy().getUserid())
-                .eq(Recipient::getIsDefault, 1).one();
+                .eq(Recipient::getIsDefault, 1)
+                .eq(Recipient::getDisabled, 0).one();
         GoodDetailVO goodDetailVO = goodsService.redeemNow(goodId, recipient);
         LocalDateTime currentDateTime = LocalDateTime.now();
         // 格式化日期和时间信息
@@ -683,10 +689,11 @@
         Random random = new Random();
         StringBuilder randomPart = new StringBuilder();
         for (int i = 0; i < 3; i++) {
-            randomPart.append((char) (random.nextInt(26) + 'A')); // 大写字母
+            // 大写字母
+            randomPart.append((char) (random.nextInt(26) + 'A'));
         }
         // 组合订单编号
-        String orderNumber = formattedDateTime + randomPart.toString();
+        String orderNumber = formattedDateTime + randomPart;
         goodDetailVO.setOrderNumber(orderNumber);
         return R.ok(goodDetailVO);
     }
@@ -750,7 +757,7 @@
     @PostMapping("/goodExchangeStudy")
     @ApiOperation(value = "商品兑换确认", tags = {"学习端-商城"})
     @ApiOperationSupport(order = 42)
-    public R goodExchangeStudy(@RequestBody GoodExchangeDTO goodExchange) {
+    public R<String> goodExchangeStudy(@RequestBody @Validated GoodExchangeDTO goodExchange) {
         Recipient recipient = recipientService.getById(goodExchange.getRecipientId());
         return goodsService.goodExchange(goodExchange, recipient);
     }
diff --git a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/dto/GoodExchangeDTO.java b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/dto/GoodExchangeDTO.java
index 11a00e6..adf63bb 100644
--- a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/dto/GoodExchangeDTO.java
+++ b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/dto/GoodExchangeDTO.java
@@ -3,6 +3,9 @@
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+
 /**
  * @author HJL
  * @version 1.0
@@ -15,6 +18,7 @@
      * 商品id
      */
     @ApiModelProperty("商品id")
+    @NotNull(message = "选择商品不存在!")
     private Integer goodId;
 
     /**
@@ -27,18 +31,21 @@
      * 兑换数量
      */
     @ApiModelProperty("兑换数量")
+    @NotNull(message = "兑换数量不能为空!")
     private Integer number;
 
     /**
      * 订单编号
      */
     @ApiModelProperty("订单编号")
+    @NotBlank(message = "订单编号不能为空!")
     private String orderNumber;
 
     /**
      * 收货地址id
      */
     @ApiModelProperty("收货地址id")
+    @NotNull(message = "请选择:该订单收货地址!")
     private String recipientId;
 
 }
diff --git a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/ITGoodsService.java b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/ITGoodsService.java
index 5a590df..2cfda80 100644
--- a/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/ITGoodsService.java
+++ b/ruoyi-service/ruoyi-goods/src/main/java/com/ruoyi/goods/service/ITGoodsService.java
@@ -45,6 +45,6 @@
      * @param recipient    收货地址
      * @return 兑换结果
      */
-    R goodExchange(GoodExchangeDTO goodExchange, Recipient recipient);
+    R<String> goodExchange(GoodExchangeDTO goodExchange, Recipient recipient);
     R goodExchange1(GoodExchangeDTO goodExchange, Recipient recipient);
 }
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 f94ae07..794b731 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;
@@ -712,7 +711,8 @@
         if (null == loginStudy) {
             return R.tokenError("登录失效!");
         }
-        TUserStudy result = studyService.studySchedule(String.valueOf(loginStudy.getUserid()));
+        TUserStudy result = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, loginStudy.getUserid())
+                .eq(TUserStudy::getDisabled, 0).one();
         if (null != result) {
             // 计算当前周 day 1-5的总进度
             int computeSchedule = studyService.computeSchedule(result, week);
@@ -840,25 +840,29 @@
             int completionRate = exitLearn.getTopicIds().split(",").length * 5;
             Integer type = exitLearn.getType();
             // 更新用户学习完成率
-            LambdaUpdateChainWrapper<TUserStudy> wrapper = userStudyService.lambdaUpdate();
             if (Constants.ONE.equals(type) && userStudy.getListen() < completionRate) {
                 // 听音选图
-                wrapper.set(TUserStudy::getListen, completionRate);
+                userStudy.setListen(completionRate);
             } else if (Constants.TWO.equals(type) && userStudy.getLook() < completionRate) {
                 // 看图选音
-                wrapper.set(TUserStudy::getLook, completionRate);
+                userStudy.setLook(completionRate);
             } else if (Constants.THREE.equals(type) && userStudy.getInduction() < completionRate) {
                 // 归纳排除
-                wrapper.set(TUserStudy::getInduction, completionRate);
+                userStudy.setInduction(completionRate);
             } else if (Constants.FOUR.equals(type) && userStudy.getAnswer() < completionRate) {
                 // 有问有答
-                wrapper.set(TUserStudy::getAnswer, completionRate);
+                userStudy.setAnswer(completionRate);
             } else if (Constants.FIVE.equals(type) && userStudy.getPair() < completionRate) {
                 // 音图相配
-                wrapper.set(TUserStudy::getPair, completionRate);
+                userStudy.setPair(completionRate);
             }
-            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));
     }
 
@@ -1362,21 +1366,35 @@
     @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();
+        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("自主故事-看图配音正确率异常!");
@@ -1391,7 +1409,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) {
@@ -1432,9 +1451,23 @@
         // 学习记录
         TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, userId)
                 .eq(TUserStudy::getDisabled, 0).one();
-        // 游戏测试成绩
+        // 学习时长格式转换
+        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));
+        // 剩余周目
+        int size = studyService.list(new QueryWrapper<TStudy>()
+                .eq("type", 1)).size();
+        studyRecord.setSurplus(size - studyRecord.getWeek());
         return R.ok(new StudyRecordResultVO(studyRecord, gameRecordList));
     }
 
@@ -1461,9 +1494,19 @@
                     .eq("type", 1)).size());
             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));
     }
 
@@ -1505,10 +1548,10 @@
             @ApiImplicitParam(value = "每页显示条数", name = "pageSize", required = true)
     })
     public R<IPage<TIntegralRecord>> integralDetailParent(String time,
-                                                         @RequestParam("pageNum")  Integer pageNum,
-                                                         @RequestParam("pageSize") Integer pageSize) {
-        System.err.println("页码"+pageNum);
-        System.err.println("页数"+ pageSize);
+                                                          @RequestParam("pageNum") Integer pageNum,
+                                                          @RequestParam("pageSize") Integer pageSize) {
+        System.err.println("页码" + pageNum);
+        System.err.println("页数" + pageSize);
         if (tokenService.getLoginUser1() == null) {
             return R.tokenError("登录失效");
         }
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java
index 5017009..4fed5af 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java
@@ -511,17 +511,17 @@
         String phone = phoneRequest.getPhone();
         String phoneCode = phoneRequest.getPhoneCode();
         // 验证码校验
-        Object redisPhoneCode = redisService.getCacheObject(RedisConstants.PHONE_CODE + phone);
-        if (null == redisPhoneCode) {
-            return R.errorCode("登录失败,验证码无效!");
-        } else {
-            // redis 验证码的value 为 code:时间戳
-            String rCodeAndTime = String.valueOf(redisPhoneCode);
-            String rCode = rCodeAndTime.split(":")[0];
-            if (!rCode.equalsIgnoreCase(phoneCode)) {
-                return R.errorCode("登录失败,验证码无效!");
-            }
-        }
+//        Object redisPhoneCode = redisService.getCacheObject(RedisConstants.PHONE_CODE + phone);
+//        if (null == redisPhoneCode) {
+//            return R.errorCode("登录失败,验证码无效!");
+//        } else {
+//            // redis 验证码的value 为 code:时间戳
+//            String rCodeAndTime = String.valueOf(redisPhoneCode);
+//            String rCode = rCodeAndTime.split(":")[0];
+//            if (!rCode.equalsIgnoreCase(phoneCode)) {
+//                return R.errorCode("登录失败,验证码无效!");
+//            }
+//        }
         // 获取手机号所注册用户信息
         TUser user = userService.getOne(new QueryWrapper<TUser>()
                 .ne("state", 3)
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
index 1e3f7f7..b77c602 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TStudyServiceImpl.java
@@ -400,15 +400,13 @@
 
     @Override
     public int computeTotalIntegral(List<String> studyIds, Integer type, Integer accuracy) {
-        int sum;
+        int sum = 0;
         if (Constants.ONE.equals(type)) {
             List<TStudyListen> list = studyListenService.lambdaQuery().in(TStudyListen::getId, studyIds)
                     .eq(TStudyListen::getDisabled, 0).list();
             Optional<TStudyListen> any = list.stream().findAny();
             if (any.isPresent()) {
                 sum = any.get().getIntegral();
-            } else {
-                sum = 0;
             }
         } else if (Constants.TWO.equals(type)) {
             List<TStudyLook> list = studyLookService.lambdaQuery().in(TStudyLook::getId, studyIds)
@@ -416,8 +414,6 @@
             Optional<TStudyLook> any = list.stream().findAny();
             if (any.isPresent()) {
                 sum = any.get().getIntegral();
-            } else {
-                sum = 0;
             }
         } else if (Constants.THREE.equals(type)) {
             List<TStudyInduction> list = studyInductionService.lambdaQuery().in(TStudyInduction::getId, studyIds)
@@ -425,8 +421,6 @@
             Optional<TStudyInduction> any = list.stream().findAny();
             if (any.isPresent()) {
                 sum = any.get().getIntegral();
-            } else {
-                sum = 0;
             }
         } else if (Constants.FOUR.equals(type)) {
             List<TStudyAnswer> list = studyAnswerService.lambdaQuery().in(TStudyAnswer::getId, studyIds)
@@ -434,8 +428,6 @@
             Optional<TStudyAnswer> any = list.stream().findAny();
             if (any.isPresent()) {
                 sum = any.get().getIntegral();
-            } else {
-                sum = 0;
             }
         } else if (Constants.FIVE.equals(type)) {
             List<TStudyPair> list = studyPairService.lambdaQuery().in(TStudyPair::getId, studyIds)
@@ -443,8 +435,6 @@
             Optional<TStudyPair> any = list.stream().findAny();
             if (any.isPresent()) {
                 sum = any.get().getIntegral();
-            } else {
-                sum = 0;
             }
         } else {
             throw new GlobalException("题目信息异常!");
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TUserStudyServiceImpl.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TUserStudyServiceImpl.java
index 24cfed5..eba7df6 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TUserStudyServiceImpl.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/service/impl/TUserStudyServiceImpl.java
@@ -93,38 +93,36 @@
         // 学习记录
         TUserStudy userStudyRecord = lambdaQuery().eq(TUserStudy::getUserId, userId)
                 .eq(TUserStudy::getDisabled, 0).one();
-        Integer type = completeStudy.getType();
-        if (Constants.ONE.equals(type)) {
-            userStudyRecord.setListen(Constants.ONE_HUNDRED);
-            userStudyRecord.setLook(Constants.BURDEN_ONE);
-            userStudyRecord.setInduction(Constants.BURDEN_ONE);
-            userStudyRecord.setAnswer(Constants.BURDEN_ONE);
-            userStudyRecord.setPair(Constants.BURDEN_ONE);
-        } else if (Constants.TWO.equals(type)) {
-            userStudyRecord.setLook(Constants.ONE_HUNDRED);
-            userStudyRecord.setInduction(Constants.BURDEN_ONE);
-            userStudyRecord.setAnswer(Constants.BURDEN_ONE);
-            userStudyRecord.setPair(Constants.BURDEN_ONE);
-        } else if (Constants.THREE.equals(type)) {
-            userStudyRecord.setInduction(Constants.ONE_HUNDRED);
-            userStudyRecord.setAnswer(Constants.BURDEN_ONE);
-            userStudyRecord.setPair(Constants.BURDEN_ONE);
-        } else if (Constants.FOUR.equals(type)) {
-            userStudyRecord.setAnswer(Constants.ONE_HUNDRED);
-        } else if (Constants.FIVE.equals(type)) {
-            userStudyRecord.setPair(Constants.ONE_HUNDRED);
-            // type为5并且day为5应该进入游戏日
-            Integer nextDay = DAY_MAP.get(String.valueOf(userStudyRecord.getDay()));
-            userStudyRecord.setDay(nextDay);
-            // 游戏难度初始化 0(入门难度)
-            userStudyRecord.setGameDifficulty(Constants.ZERO);
-            // 学习day已切换更新学习进度及学习时长
-//            userStudyRecord.setListen(Constants.BURDEN_ONE);
-//            userStudyRecord.setLook(Constants.BURDEN_ONE);
-//            userStudyRecord.setInduction(Constants.BURDEN_ONE);
-//            userStudyRecord.setAnswer(Constants.BURDEN_ONE);
-//            userStudyRecord.setPair(Constants.BURDEN_ONE);
-            // 下一day为 1说明该周目已完成,应更改为下一周目
+        Integer week = userStudyRecord.getWeek();
+        Integer day = userStudyRecord.getDay();
+        if (week.equals(completeStudy.getWeek()) && day.equals(completeStudy.getDay())) {
+            Integer type = completeStudy.getType();
+            if (Constants.ONE.equals(type)) {
+                userStudyRecord.setListen(Constants.ONE_HUNDRED);
+                userStudyRecord.setLook(Constants.BURDEN_ONE);
+                userStudyRecord.setInduction(Constants.BURDEN_ONE);
+                userStudyRecord.setAnswer(Constants.BURDEN_ONE);
+                userStudyRecord.setPair(Constants.BURDEN_ONE);
+            } else if (Constants.TWO.equals(type)) {
+                userStudyRecord.setLook(Constants.ONE_HUNDRED);
+                userStudyRecord.setInduction(Constants.BURDEN_ONE);
+                userStudyRecord.setAnswer(Constants.BURDEN_ONE);
+                userStudyRecord.setPair(Constants.BURDEN_ONE);
+            } else if (Constants.THREE.equals(type)) {
+                userStudyRecord.setInduction(Constants.ONE_HUNDRED);
+                userStudyRecord.setAnswer(Constants.BURDEN_ONE);
+                userStudyRecord.setPair(Constants.BURDEN_ONE);
+            } else if (Constants.FOUR.equals(type)) {
+                userStudyRecord.setAnswer(Constants.ONE_HUNDRED);
+                userStudyRecord.setPair(Constants.BURDEN_ONE);
+            } else if (Constants.FIVE.equals(type)) {
+                userStudyRecord.setPair(Constants.ONE_HUNDRED);
+                // type为5并且day为5应该进入游戏日
+                Integer nextDay = DAY_MAP.get(String.valueOf(userStudyRecord.getDay()));
+                userStudyRecord.setDay(nextDay);
+                // 游戏难度初始化 0(入门难度)
+                userStudyRecord.setGameDifficulty(Constants.ZERO);
+            }
         }
         // 更新学习时长
         userStudyRecord.setTotalStudy(userStudyRecord.getTotalStudy() + studyTime);
diff --git a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/vo/ExitLearnVO.java b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/vo/ExitLearnVO.java
index 38462ab..df6dcd3 100644
--- a/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/vo/ExitLearnVO.java
+++ b/ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/vo/ExitLearnVO.java
@@ -53,4 +53,10 @@
     @ApiModelProperty(value = "答题正确次数")
     private Integer correctNumber;
 
+    /**
+     * 完成学习所用时长
+     */
+    @ApiModelProperty("完成学习所用时长(秒)")
+    private Integer studyTime;
+
 }

--
Gitblit v1.7.1