From d4202e0a054617cc1d18e5e5f92581cf9b07e1db Mon Sep 17 00:00:00 2001
From: ZQN <364596817@qq.com>
Date: 星期六, 22 六月 2024 10:35:06 +0800
Subject: [PATCH] 执法结果上报

---
 project-framework/src/main/java/com/project/framework/web/service/SysLoginService.java |   44 ++++++++++++++++++++++++++++++++++++--------
 1 files changed, 36 insertions(+), 8 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 0a9eb08..8cb0c51 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
@@ -21,6 +21,7 @@
 import com.project.common.exception.user.CaptchaException;
 import com.project.common.exception.user.CaptchaExpireException;
 import com.project.common.exception.user.UserPasswordNotMatchException;
+import com.project.common.sms.YPSmsApi;
 import com.project.common.utils.DateUtils;
 import com.project.common.utils.MessageUtils;
 import com.project.common.utils.ServletUtils;
@@ -125,14 +126,31 @@
         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 flag = true;
+//        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;
+    }
+
+    private boolean sendYp(String phone, String code ){
+        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;
+        }
+        return false;
+    }
+
+    private boolean sendAl(String phone, String code ){
         DefaultProfile profile = DefaultProfile.getProfile("cn-beijing", AliyunSmsConstants.SMS_APPID, AliyunSmsConstants.SMS_SECRET);
         IAcsClient client = new DefaultAcsClient(profile);
         CommonRequest request = new CommonRequest();
@@ -149,15 +167,12 @@
             JSONObject jsonObject = JSON.parseObject(response.getData());
             if ("OK".equals(jsonObject.get("Code"))) {
                 log.info("鍙戦�佹垚鍔� ->楠岃瘉鐮侊細"+code);
-                redisCache.setCacheObject(getCacheKey(phone), code, Constants.PHONE_EXPIRATION, TimeUnit.MINUTES);
                 return true;
             }
-
         } catch (ClientException e) {
             e.printStackTrace();
         }
-        redisCache.setCacheObject(getCacheKey(phone), code, Constants.PHONE_EXPIRATION, TimeUnit.MINUTES);
-        return flag;
+        return false;
     }
 
     /**
@@ -172,9 +187,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);
     }

--
Gitblit v1.9.1