From 941caf616bded8ff1faa0a0875f2f37a11d9913d Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期四, 04 七月 2024 15:52:56 +0800
Subject: [PATCH] bug修改

---
 ruoyi-service/ruoyi-study/src/main/java/com/ruoyi/study/controller/TUserController.java |   47 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 40 insertions(+), 7 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 63f340d..c0a7ef0 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
@@ -28,6 +28,7 @@
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import io.swagger.models.auth.In;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.*;
@@ -192,6 +193,9 @@
                 String s1 = out_trade_no.split("_")[1];
                 Integer integer1 = Integer.valueOf(s1);
                 TVipOrder byId = vipOrderService.getById(integer1);
+                if (byId.getBackTime()!=null){
+                    return;
+                }
                 byId.setPayState(2);
                 byId.setTransactionId(trade_no);
                 byId.setOutTradeNo(out_trade_no);
@@ -447,13 +451,14 @@
         return R.ok("反馈成功");
     }
 
+
     @PostMapping("/parentLogin")
     @ApiOperation(value = "登录", tags = {"家长端-登录"})
     @ApiImplicitParams({
             @ApiImplicitParam(value = "手机号", name = "phone", dataType = "string", required = true),
             @ApiImplicitParam(value = "验证码", name = "phoneCode", dataType = "string", required = true)
     })
-    public R<Map<String, Object>> login(String phone, String phoneCode) {
+    public R<Map<String, Object>> login(String phone, String phoneCode) throws Exception {
         TUser tUser1 = userService.getOne(new QueryWrapper<TUser>()
                 .ne("state", 3)
                 .eq("phone", phone));
@@ -476,14 +481,18 @@
                     } else {
                         tUser1.setHeadImg("https://haitunyingyu.obs.cn-southwest-2.myhuaweicloud.com/admin/1c6ee218aa18434db2e86df903990de8.jpg");
                         tUser1 = getUser(phone);
-                        tUser1.setAccount("用户"+UUIDUtil.getNumberRandom(6));
+                        String upperCase = UUIDUtil.getRandomCode(6).toUpperCase();
+                        tUser1.setAccount("用户"+upperCase);
+                        tUser1.setName("用户"+upperCase);
                         userService.save(tUser1);
                     }
                 }
             } else {
+                String upperCase = UUIDUtil.getRandomCode(6).toUpperCase();
                 tUser1 = getUser(phone);
                 tUser1.setHeadImg("https://haitunyingyu.obs.cn-southwest-2.myhuaweicloud.com/admin/1c6ee218aa18434db2e86df903990de8.jpg");
-                tUser1.setAccount("用户"+UUIDUtil.getNumberRandom(6));
+                tUser1.setAccount("用户"+upperCase);
+                tUser1.setName("用户"+upperCase);
                 userService.save(tUser1);
             }
         }
@@ -527,7 +536,7 @@
      */
     @PostMapping("/studyLogin")
     @ApiOperation(value = "学习端-登录", tags = {"学习端-登录"})
-    public R<Map<String, Object>> studyLogin(@RequestBody RegisterPhoneRequest phoneRequest) {
+    public R<Map<String, Object>> studyLogin(@RequestBody RegisterPhoneRequest phoneRequest) throws Exception {
         String phone = phoneRequest.getPhone();
         String phoneCode = phoneRequest.getPhoneCode();
         if (!"123456".equals(phoneCode)) {
@@ -555,7 +564,9 @@
         } else {
             user = getUser(phone);
             user.setHeadImg("https://haitunyingyu.obs.cn-southwest-2.myhuaweicloud.com/admin/1c6ee218aa18434db2e86df903990de8.jpg");
-            user.setAccount("用户"+UUIDUtil.getNumberRandom(6));
+            String upperCase = UUIDUtil.getRandomCode(6).toUpperCase();
+            user.setAccount("用户"+upperCase);
+            user.setName("用户"+upperCase);
             userService.save(user);
         }
         // 生成登录用户信息
@@ -614,8 +625,25 @@
     @ApiOperation(value = "发送手机验证码", tags = {"家长端/学习端-发送手机验证码"})
     @ApiImplicitParams({
             @ApiImplicitParam(value = "手机号", name = "phone", dataType = "string", required = true),
+            @ApiImplicitParam(value = "类型 更换手机号的时候传该参数 传1", name = "type", dataType = "int"),
     })
-    public R<?> sendPhoneCode(@RequestParam String phone) throws Exception {
+    public R<?> sendPhoneCode(String phone, Integer type) throws Exception {
+        if (type != null && type == 1){
+            List<TUser> list = userService.list(new QueryWrapper<TUser>()
+                    .eq("phone", phone)
+                    .ne("state", 3));
+            if (!list.isEmpty()) {
+                return R.fail("更换的手机号已被使用!");
+            }
+            LoginUserParent loginUser1 = tokenService.getLoginUser1();
+            if (loginUser1==null){
+                return R.tokenError("登录失效!");
+            }
+            TUser byId = userService.getById(loginUser1.getUserid());
+            if (byId.getPhone().equals(phone)){
+                return R.fail("更换的手机号不能和原手机号相同!");
+            }
+        }
         return userService.phoneCode(phone) ? R.ok() : R.fail();
     }
 
@@ -816,7 +844,7 @@
             List<TUser> list = userService.list(new QueryWrapper<TUser>()
                     .eq("phone", phone)
                     .ne("state", 3));
-            if (list.size() > 0) {
+            if (!list.isEmpty()) {
                 return R.fail("更换的手机号已被使用!");
             }
             byId.setPhone(phone);
@@ -922,6 +950,7 @@
                 if (!"10000".equals(code)) {
                     return R.fail(stringStringMap1.get("return_msg"));
                 }
+                System.err.println("修改会员订单状态"+ byId);
                 byId.setPayState(3);
                 byId.setBackTime(new Date());
                 vipOrderService.updateById(byId);
@@ -938,15 +967,19 @@
                         .orderByDesc("createTime"));
                 int size = list.size();
                 if (size == 0) {
+                    System.err.println("证明这是用户第一次充值会员 将首次充值会员时间和会员到期时间清空");
                     // 证明这是用户第一次充值会员 将首次充值会员时间和会员到期时间清空
                     byId1.setVipEndTime(null);
                     byId1.setVipPayTime(null);
                     userService.updateById(byId1);
+                    userService.updateOne(byId1.getId(),null,null);
                 } else {
+                    System.err.println("最近的一次充值会员时间  将会员到期时间回退到上一次");
                     // 最近的一次充值会员时间
                     TVipOrder tVipOrder = list.get(0);
                     // 将会员到期时间回退到上一次
                     byId1.setVipEndTime(tVipOrder.getTime());
+                    byId1.setVipPayTime(tVipOrder.getPayTime());
                     userService.updateById(byId1);
                 }
                 return R.ok();

--
Gitblit v1.7.1