Parcourir la source

fix 迪士尼登录验证码

zoujiajian il y a 2 ans
Parent
commit
3ce770d6c6

+ 16 - 11
netflix-service/src/main/java/com/cyksj/service/relation/impl/GroupRelationFrontServiceImpl.java

@@ -595,27 +595,32 @@ public class GroupRelationFrontServiceImpl implements GroupRelationFrontService
 		}
 		//迪士尼
 		if (goodsId == 3) {
-			code = StrUtil.subWithLength(body, body.indexOf(" 15 "), 215);
+			int index = body.indexOf("otp_code");
+			if (index == -1) {
+				index = body.indexOf(" 15 ");
+			}
+			code = StrUtil.subWithLength(body, index, 215);
 		}
 		//PS
 		if (goodsId == 33l) {
 			code = StrUtil.subWithLength(body, body.indexOf("ADOBE"), 215);
 		}
+		code = getVerifyCode(code);
+		if (!Validator.isNumber(code)) {
+			log.error("获取账号验证码失败:{}", StrUtil.subSufByLength(code, 512));
+			throw BusinessRuntimeException.getInstance("获取验证码失败,请重新获取...");
+		}
+		return code.trim();
+	}
+
+	public String getVerifyCode(String code) {
 		if (StrUtil.isNotEmpty(code)) {
 			Pattern pattern = Pattern.compile("\\d{6}");
 			Matcher matcher = pattern.matcher(code);
 			while (matcher.find()) {
-				code = matcher.group();
-				break;
+				return matcher.group();
 			}
 		}
-		if (!Validator.isNumber(code)) {
-			throw BusinessRuntimeException.getInstance("获取验证码失败,请重新获取");
-		}
-		if (StrUtil.isEmpty(code)) {
-			log.error("获取账号验证码失败:{}", StrUtil.subSufByLength(code, 512));
-			throw BusinessRuntimeException.getInstance("获取验证码失败,请重新获取...");
-		}
-		return code.trim();
+		return StrUtil.EMPTY;
 	}
 }