From b48de0e35c54bd4715f8de2b86bac5a539c27275 Mon Sep 17 00:00:00 2001
From: ZQN <364596817@qq.com>
Date: 星期六, 22 六月 2024 16:23:44 +0800
Subject: [PATCH] 更换手机,发送短信放开

---
 project-framework/src/main/java/com/project/framework/web/service/SysLoginService.java |   55 +++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/project-framework/src/main/java/com/project/framework/web/service/SysLoginService.java b/project-framework/src/main/java/com/project/framework/web/service/SysLoginService.java
index 50cf765..49e14fb 100644
--- a/project-framework/src/main/java/com/project/framework/web/service/SysLoginService.java
+++ b/project-framework/src/main/java/com/project/framework/web/service/SysLoginService.java
@@ -114,6 +114,26 @@
         return tokenService.createToken(loginUser);
     }
 
+    /**
+     * 鏂版敞鍐岃幏鍙栭獙璇佺爜
+     * @param phone 鎵嬫満
+     * @return  楠岃瘉鐮�
+     */
+    public Boolean getVerifyCodeNew(String phone) {
+        // 鐢熸垚4浣嶉殢鏈烘暟
+        String code = "";
+        Random ran = new Random();
+        int randomNum = ran.nextInt(10000);
+        code = String.format("%04d", randomNum);
+        log.info("鎵嬫満鍙凤細"+phone+"->楠岃瘉鐮侊細"+code);
+        boolean send = sendYp(phone, code);
+        if (send){
+            redisCache.setCacheObject(getCacheKey(phone), code, Constants.PHONE_EXPIRATION, TimeUnit.MINUTES);
+            return true;
+        }
+        redisCache.setCacheObject(getCacheKey(phone), code, Constants.PHONE_EXPIRATION, TimeUnit.MINUTES);
+        return false;
+    }
 
     /**
      * 鑾峰彇楠岃瘉鐮�
@@ -126,23 +146,11 @@
         if (user==null){
             throw new BaseException("鎮ㄦ墜鏈哄彿灏氭湭娉ㄥ唽锛�");
         }
-        // 鐢熸垚4浣嶉殢鏈烘暟
-        String code = "";
-        Random ran = new Random();
-        int randomNum = ran.nextInt(10000);
-        code = String.format("%04d", randomNum);
-        log.info("鎵嬫満鍙凤細"+phone+"->楠岃瘉鐮侊細"+code);
-        boolean send = sendAl(phone, code);
-        if (send){
-            redisCache.setCacheObject(getCacheKey(phone), code, Constants.PHONE_EXPIRATION, TimeUnit.MINUTES);
-            return true;
-        }
-        redisCache.setCacheObject(getCacheKey(phone), code, Constants.PHONE_EXPIRATION, TimeUnit.MINUTES);
-        return false;
+        return getVerifyCodeNew(phone);
     }
 
     private boolean sendYp(String phone, String code ){
-        String result = YPSmsApi.sendSms(phone, StringUtils.format(YPSmsApi.VERIFY_CODE_TEMPLATE, code, Constants.PHONE_EXPIRATION));
+        String result = YPSmsApi.sendSms(phone, StringUtils.format(YPSmsApi.CODE_TMP, code, Constants.PHONE_EXPIRATION));
         if (result.contains("\"code\":0,\"msg\":\"OK\"")){
             log.info("鍙戦�佹垚鍔� ->楠岃瘉鐮侊細"+code);
             return true;
@@ -187,9 +195,22 @@
         if (!verified){
             throw new BaseException("鎵嬫満鍙烽獙璇佺爜鏍¢獙澶辫触锛�");
         }
-        SysUser user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getPhonenumber,bo.getPhone()));
+        SysUser user = null;
+        if ("01".equals(bo.getUserType())){
+            user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getPhonenumber,bo.getPhone())
+                    .and(wrapper->wrapper.eq(SysUser::getUserType,"00").or().eq(SysUser::getUserType, "01")));
+        } else {
+            user = userMapper.selectOne(new LambdaQueryWrapper<SysUser>()
+                    .eq(SysUser::getPhonenumber,bo.getPhone())
+                    .eq(SysUser::getUserType,bo.getUserType())
+                    );
+        }
         if (user==null){
-            throw new BaseException("鎮ㄦ墜鏈哄彿灏氭湭娉ㄥ唽锛�");
+            throw new BaseException("鎮ㄦ墜鏈哄彿灏氭湭娉ㄥ唽鎴栨偍閫夋嫨鐧诲綍绫诲瀷鏈夎锛�");
+        }
+        if (!"0".equals(user.getStatus())){
+            throw new BaseException("鎮ㄨ处鍙峰凡鍋滅敤鎴栧緟瀹℃壒锛岃鑱旂郴钀ュ晢鍔炵鐞嗕汉鍛橈紒");
         }
         return this.login(user.getUserName(), user.getRecommendUser(), null, null);
     }
@@ -264,4 +285,6 @@
 
         return verify;
     }
+
+
 }

--
Gitblit v1.9.1