소스 검색

fix 导出邮箱密码;gpt验证码;codex抵扣金额

zoujiajian 1 개월 전
부모
커밋
d2f772ac9d

+ 10 - 2
netflix-common/pom.xml

@@ -112,5 +112,13 @@
         </dependency>
     </dependencies>
 
-
-</project>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>2.22.2</version>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 30 - 0
netflix-common/src/main/java/com/cyksj/common/util/TicketCodeCommonUtil.java

@@ -2,6 +2,7 @@ package com.cyksj.common.util;
 
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HtmlUtil;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -18,6 +19,15 @@ import java.util.regex.Pattern;
 
 public class TicketCodeCommonUtil {
 	private static final Logger LOGGER = LoggerFactory.getLogger(TicketCodeCommonUtil.class);
+
+	private static final Pattern GPT_VERIFY_CODE_PATTERN = Pattern.compile(
+			"(?:Enter\\s+this\\s+temporary\\s+verification\\s+code(?:\\s+to\\s+continue)?"
+					+ "|Your\\s+(?:ChatGPT|Sora)\\s+code\\s+is"
+					+ "|输入\\s*此\\s*临时\\s*验证码\\s*以\\s*继续"
+					+ "|輸入\\s*此\\s*臨時\\s*驗證碼\\s*以\\s*繼續)"
+					+ "\\s*[::]?\\s*(?<!\\d)((?:\\d\\s*){6})(?!\\s*\\d)",
+			Pattern.CASE_INSENSITIVE);
+
 	/**
 	 * 车票邮箱验证码
 	 */
@@ -25,6 +35,9 @@ public class TicketCodeCommonUtil {
 		if (StrUtil.isEmpty(body)) {
 			return body;
 		}
+		if (Long.valueOf(18L).equals(goodsId)) {
+			return getGptVerifyCode(body);
+		}
 		String str = getCodeStartStr(goodsId, body);
 		if (StrUtil.isEmpty(str)) {
 			return null;
@@ -49,6 +62,23 @@ public class TicketCodeCommonUtil {
 		return code.trim();
 	}
 
+	/**
+	 * 获取 GPT/Sora 登录验证码。将 HTML 邮件转为纯文本后,
+	 * 按正文出现顺序返回第一个符合明确登录提示语的六位验证码。
+	 */
+	public static String getGptVerifyCode(String body) {
+		if (StrUtil.isBlank(body)) {
+			return StrUtil.EMPTY;
+		}
+		String text = HtmlUtil.unescape(body)
+				.replaceAll("(?is)<(?:script|style)\\b[^>]*>.*?</(?:script|style)>", " ")
+				.replaceAll("(?s)<[^>]+>", " ")
+				.replace('\u00a0', ' ')
+				.replaceAll("\\s+", " ");
+		Matcher matcher = GPT_VERIFY_CODE_PATTERN.matcher(text);
+		return matcher.find() ? matcher.group(1).replaceAll("\\s", "") : StrUtil.EMPTY;
+	}
+
 	public static String extractUrl(String body, String prefixUrl) {
 		String urlPattern = "(https?://\\S+)";
 		Pattern pattern = Pattern.compile(urlPattern);

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/model/excel/ExcelManageAccountData.java

@@ -54,7 +54,7 @@ public class ExcelManageAccountData {
 	private String password;
 
 	@ExcelProperty("邮箱密码")
-	@DbField("select password from sys_email where email = a.account limit 1")
+	@DbField("coalesce(nullif(a.gpt_email_pwd, ''), (select password from sys_email where email = a.account limit 1))")
 	private String emailPassword;
 
 	@ExcelProperty("APIkey")

+ 19 - 18
netflix-service/src/main/java/com/cyksj/service/mail/impl/CommonMailServiceImpl.java

@@ -61,26 +61,27 @@ public class CommonMailServiceImpl implements CommonMailService {
                 emailPwd = sysEmail.getPassword();
             }
         }
-		if (StrUtil.isEmpty(relateEmail)) {
-			//25年的GPT账号获取验证码 特殊处理
-			//获取失败走下一步
-			if (goodsId == 18 && emailCreatedTime.compareTo(DateUtil.parse("2025-01-01")) > 0) {
-				try {
-					//获取近十封邮件
-					String url = "https://ms.lqqq.cc/web/" + account + "----" + emailPwd;
-					HttpRequest post = HttpUtil.createGet(url);
-					HttpResponse execute = post.execute();
-					String body = execute.body();
-					if (body.contains("Your ChatGPT code is") || body.contains("Your Sora code is")) {
-						String code = TicketCodeCommonUtil.getTicketCodeStr(body, goodsId);
-						return code;
-					}
+        //25年的GPT账号获取验证码 特殊处理
+        //获取失败走下一步
+        if (Long.valueOf(18L).equals(goodsId) && emailCreatedTime != null
+                && emailCreatedTime.compareTo(DateUtil.parse("2025-01-01")) > 0) {
+            try {
+                //获取近十封邮件
+                String url = "https://ms.lqqq.cc/web/" + account + "----" + emailPwd;
+                HttpRequest post = HttpUtil.createGet(url);
+                HttpResponse execute = post.execute();
+                String body = execute.body();
+                String code = TicketCodeCommonUtil.getGptVerifyCode(body);
+                if (StrUtil.isNotEmpty(code)) {
+                    return code;
+                }
+
+            } catch (Exception e) {
+
+            }
+        }
 
-				} catch (Exception e) {
 
-				}
-			}
-		}
 		//迪士尼 获取验证码
 		if (goodsId == Constant.DISNEY_GID) {
 			try {

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/mail/impl/MailLuServiceImpl.java

@@ -138,7 +138,7 @@ public class MailLuServiceImpl implements MailLuService {
 			}
 			//PS、Disney
 			code = TicketCodeCommonUtil.getTicketCodeStr(body, goodsId);
-			if (code != null) {
+			if (StrUtil.isNotBlank(code)) {
 				return code;
 			}
 		}

+ 2 - 5
netflix-service/src/main/java/com/cyksj/service/mail/impl/YhEmailServiceImpl.java

@@ -7,7 +7,6 @@ import cn.hutool.http.HttpUtil;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.cyksj.common.exception.BusinessRuntimeException;
-import com.cyksj.common.util.StringUtil;
 import com.cyksj.common.util.TicketCodeCommonUtil;
 import com.cyksj.mapper.sys.SysEmailMapper;
 import com.cyksj.model.entity.SysEmail;
@@ -71,10 +70,8 @@ public class YhEmailServiceImpl implements YhMailService {
 	@Override
 	public String getGptCode(String account) {
 		String body = readEmail(account);
-		String prefix = "Enter this temporary verification";
-		if (body.contains(prefix)) {
-			String str = StrUtil.subAfter(body, prefix, true);
-			String code = StringUtil.getVerifyCodePattern(str, 6);
+		String code = TicketCodeCommonUtil.getGptVerifyCode(body);
+		if (StrUtil.isNotEmpty(code)) {
 			return code;
 		}
 		throw BusinessRuntimeException.getInstance("获取验证码失败或被新邮件覆盖");