Ver código fonte

fix 切换人机验证

zoujiajian 2 anos atrás
pai
commit
a569d0107d

+ 20 - 21
netflix-service/src/main/java/com/cyksj/service/user/impl/BadIntentionOpServiceImpl.java

@@ -1,11 +1,10 @@
 package com.cyksj.service.user.impl;
 
-import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.extra.servlet.ServletUtil;
 import cn.hutool.http.HttpUtil;
 import cn.hutool.json.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.cyksj.common.exception.BusinessRuntimeException;
-import com.cyksj.common.util.SmsUtil;
 import com.cyksj.common.util.StringUtil;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.user.BadIntentionOpService;
@@ -43,27 +42,27 @@ public class BadIntentionOpServiceImpl implements BadIntentionOpService {
         if ("13662979985".equals(phone)) {
             throw BusinessRuntimeException.getInstance("异常手机号");
         }
-//        if (StringUtils.isBlank(verifyCode)) {
-//            throw BusinessRuntimeException.getInstance("人机校验不通过");
-//        } else {
-//            //银河官网
-//            JSONObject res = checkVerifyCode(apiKey, verifyCode);
-//            if (!res.getStr("res").equals("success")) {
-//                //小店域名
-//                res = checkVerifyCode(shoppingApikey, verifyCode);
-//                if (!res.getStr("res").equals("success")) {
-//                    log.error("手机号:{}验证码校验不通过 res:{}", phone, res);
-//                    throw BusinessRuntimeException.getInstance("人机校验不通过");
-//                }
-//            }
-//        }
-        if (ObjectUtil.hasEmpty(ticket, randStr)) {
-            throw BusinessRuntimeException.getInstance("请先完成图形认证");
+        if (StringUtils.isBlank(verifyCode)) {
+            throw BusinessRuntimeException.getInstance("人机校验不通过");
         } else {
-            //腾讯云图形验证
-            String ip = StringUtil.getInternalAddressByIP(ServletUtil.getClientIP(request));
-            SmsUtil.checkTencentCaptcha(ticket, ip, randStr);
+            //银河官网
+            JSONObject res = checkVerifyCode(apiKey, verifyCode);
+            if (!res.getStr("res").equals("success")) {
+                //小店域名
+                res = checkVerifyCode(shoppingApikey, verifyCode);
+                if (!res.getStr("res").equals("success")) {
+                    log.error("手机号:{}验证码校验不通过 res:{}", phone, res);
+                    throw BusinessRuntimeException.getInstance("人机校验不通过");
+                }
+            }
         }
+//        if (ObjectUtil.hasEmpty(ticket, randStr)) {
+//            throw BusinessRuntimeException.getInstance("请先完成图形认证");
+//        } else {
+//            //腾讯云图形验证
+//            String ip = StringUtil.getInternalAddressByIP(ServletUtil.getClientIP(request));
+//            SmsUtil.checkTencentCaptcha(ticket, ip, randStr);
+//        }
         String dayKey = RedisService.key.PHONE_CODE_USER_NUM_KEY_DAY.getName() + phone;
         if (redisService.hasKey(RedisService.key.PHONE_CODE_BALCK_KEY.getName() + phone)) {
             throw BusinessRuntimeException.getInstance("异常手机号");