From 2885941cf88da7397f2e641e383a26337f3c2b03 Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期三, 22 五月 2024 20:55:51 +0800
Subject: [PATCH] 代码提交

---
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java |   97 ++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 80 insertions(+), 17 deletions(-)

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 d55f8cb..4f7e44d 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
@@ -14,15 +14,11 @@
 import com.ruoyi.management.api.feignClient.ManagementClient;
 import com.ruoyi.management.api.model.*;
 import com.ruoyi.management.api.query.UseGuideQuery;
-import com.ruoyi.study.domain.TUser;
-import com.ruoyi.study.domain.TUserShare;
-import com.ruoyi.study.domain.TVipOrder;
+import com.ruoyi.study.domain.*;
 import com.ruoyi.study.dto.AppUserQuery;
 import com.ruoyi.study.dto.UserInfoQuery;
 import com.ruoyi.study.request.RegisterPhoneRequest;
-import com.ruoyi.study.service.ITUserService;
-import com.ruoyi.study.service.ITUserShareService;
-import com.ruoyi.study.service.IVipOrderService;
+import com.ruoyi.study.service.*;
 import com.ruoyi.study.utils.PayMoneyUtil;
 import com.ruoyi.study.utils.UUIDUtil;
 import com.ruoyi.study.vo.*;
@@ -183,8 +179,12 @@
                     calendar.setTime(new Date());
                     calendar.add(Calendar.MONTH, time);
                     Date dateAfterOneMonth = calendar.getTime();
-                    byId.setTime(dateAfterOneMonth);
+                    dateAfterOneMonth.setHours(23);
+                    dateAfterOneMonth.setMinutes(59);
+                    dateAfterOneMonth.setSeconds(59);
                     byId1.setVipEndTime(dateAfterOneMonth);
+                    byId.setTime(dateAfterOneMonth);
+
                 } else {
                     // 不是首次 判断vipEndTime 是否到期 如果没有 加指定月份时间 如果到期了 将会员到期时间从当前增加指定月份
                     if (byId1.getVipEndTime().getTime() < new Date().getTime()) {
@@ -192,6 +192,9 @@
                         calendar.setTime(new Date());
                         calendar.add(Calendar.MONTH, time);
                         Date dateAfterOneMonth = calendar.getTime();
+                        dateAfterOneMonth.setHours(23);
+                        dateAfterOneMonth.setMinutes(59);
+                        dateAfterOneMonth.setSeconds(59);
                         byId.setTime(dateAfterOneMonth);
                         byId1.setVipEndTime(dateAfterOneMonth);
                     } else {
@@ -199,6 +202,9 @@
                         calendar.setTime(byId1.getVipEndTime());
                         calendar.add(Calendar.MONTH, time);
                         Date dateAfterOneMonth = calendar.getTime();
+                        dateAfterOneMonth.setHours(23);
+                        dateAfterOneMonth.setMinutes(59);
+                        dateAfterOneMonth.setSeconds(59);
                         byId.setTime(dateAfterOneMonth);
                         byId1.setVipEndTime(dateAfterOneMonth);
                     }
@@ -257,6 +263,9 @@
                     calendar.setTime(new Date());
                     calendar.add(Calendar.MONTH, time);
                     Date dateAfterOneMonth = calendar.getTime();
+                    dateAfterOneMonth.setHours(23);
+                    dateAfterOneMonth.setMinutes(59);
+                    dateAfterOneMonth.setSeconds(59);
                     byId.setTime(dateAfterOneMonth);
                     byId1.setVipEndTime(dateAfterOneMonth);
                 } else {
@@ -266,6 +275,9 @@
                         calendar.setTime(new Date());
                         calendar.add(Calendar.MONTH, time);
                         Date dateAfterOneMonth = calendar.getTime();
+                        dateAfterOneMonth.setHours(23);
+                        dateAfterOneMonth.setMinutes(59);
+                        dateAfterOneMonth.setSeconds(59);
                         byId.setTime(dateAfterOneMonth);
                         byId1.setVipEndTime(dateAfterOneMonth);
                     } else {
@@ -273,6 +285,9 @@
                         calendar.setTime(byId1.getVipEndTime());
                         calendar.add(Calendar.MONTH, time);
                         Date dateAfterOneMonth = calendar.getTime();
+                        dateAfterOneMonth.setHours(23);
+                        dateAfterOneMonth.setMinutes(59);
+                        dateAfterOneMonth.setSeconds(59);
                         byId.setTime(dateAfterOneMonth);
                         byId1.setVipEndTime(dateAfterOneMonth);
                     }
@@ -496,6 +511,17 @@
         return AjaxResult.success();
     }
 
+    /**
+     * 获取用户信息
+     *
+     * @return 用户信息
+     */
+    @GetMapping("/userInfo")
+    @ApiOperation(value = "用户详情", tags = {"用户详情"})
+    public R<TUser> userInfo() {
+        return R.ok(userService.lambdaQuery().eq(TUser::getId,tokenService.getLoginUserStudy().getUserid()).one());
+    }
+
     @PostMapping("/deleteUser")
     @ApiOperation(value = "注销当前帐号", tags = {"家长端-个人中心"})
     @ApiImplicitParams({
@@ -637,6 +663,7 @@
                 if (!"SUCCESS".equals(result_code)) {
                     return R.fail(stringStringMap.get("return_msg"));
                 }
+                byId.setBackTime(new Date());
                 byId.setPayState(3);
                 vipOrderService.updateById(byId);
             case 2:
@@ -702,7 +729,12 @@
         res.setTotal(list.size());
         return R.ok(res);
     }
-
+    @Resource
+    private ITUserStudyService userStudyService;
+    @Resource
+    private ITGameRecordService gameRecordService;
+    @Autowired
+    private ITStudyService studyService;
     @PostMapping("/getUserInfo")
     @ApiOperation(value = "查看用户详情", tags = {"管理后台-用户管理"})
     public R<UserInfoVO> getUserInfo(@RequestBody UserInfoQuery dto) {
@@ -734,17 +766,48 @@
         res.setPhone(phone);
         res.setInsertTime(format.format(insertTime));
         res.setIntegral(byId.getIntegral());
-        // todo 查询进度
-        res.setCurrent(0);
-        res.setSurplus(0);
-        res.setTotalHours(0d);
-        res.setTodayHours(0d);
-        res.setWeekHours(0d);
-        res.setMonthHours(0d);
-        // todo 查询用户的游戏记录
+        TUserStudy studyRecord = userStudyService.lambdaQuery().eq(TUserStudy::getUserId, dto.getId())
+                .eq(TUserStudy::getDisabled, 0).one();
+        // 游戏测试成绩
+        List<TGameRecord> gameRecordList = gameRecordService.lambdaQuery().eq(TGameRecord::getUserId, dto.getId())
+                .eq(TGameRecord::getDisabled, 0).list();
+        if (studyRecord!=null){
+            res.setCurrent(studyRecord.getWeek());
+            // 查询当前听的总周目
+            List<TStudy> list1 = studyService.list(new QueryWrapper<>());
+            res.setSurplus(list1.size()-studyRecord.getWeek());
+            res.setTotalHours(studyRecord.getTotalStudy().doubleValue());
+            res.setTodayHours(studyRecord.getTodayStudy().doubleValue());
+            res.setWeekHours(studyRecord.getWeekStudy().doubleValue());
+            res.setMonthHours(studyRecord.getMonthStudy().doubleValue());
+        }else{
+            res.setCurrent(0);
+            res.setSurplus(0);
+            res.setTotalHours(0.0);
+            res.setTodayHours(0.0);
+            res.setWeekHours(0.0);
+            res.setMonthHours(0.0);
+        }
+
         List<UserGameRecordVO> userGameRecordVOS = new ArrayList<>();
+        for (TGameRecord tGameRecord : gameRecordList) {
+            UserGameRecordVO userGameRecordVO = new UserGameRecordVO();
+            userGameRecordVO.setGameName(tGameRecord.getGameName());
+            userGameRecordVO.setUseTime(tGameRecord.getUseTime().toString());
+            if (tGameRecord.getGameDifficulty() == 0) {
+                userGameRecordVO.setAccuracy("100%");
+            } else {
+                userGameRecordVO.setAccuracy(tGameRecord.getAccuracy() + "%");
+            }
+            if (tGameRecord.getGameDifficulty() == 0) {
+                userGameRecordVO.setTime(tGameRecord.getUseTime());
+            } else {
+                userGameRecordVO.setTime(tGameRecord.getUseTime() / 2);
+            }
+            userGameRecordVOS.add(userGameRecordVO);
+        }
         list.setRecords(userGameRecordVOS);
-        list.setTotal(0);
+        list.setTotal(userGameRecordVOS.size());
         res.setGameRecords(list);
         return R.ok(res);
     }

--
Gitblit v1.7.1