Jelajahi Sumber

fix adobe验证码

zoujiajian 1 bulan lalu
induk
melakukan
953a417eb0

+ 11 - 7
netflix-dao/src/main/java/com/cyksj/model/response/AdobeEmailResp.java

@@ -1,5 +1,6 @@
 package com.cyksj.model.response;
 
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -12,15 +13,18 @@ import lombok.Setter;
 @Getter
 @Setter
 public class AdobeEmailResp {
-	private Long id;
+    @JsonProperty("From")
+	private String From;
 
-	private String message_id;
+    @JsonProperty("Date")
+    private String Date;
 
-	private String source;
+    @JsonProperty("Subject")
+    private String Subject;
 
-	private String address;
+    @JsonProperty("To")
+    private String To;
 
-	private String raw;
-
-	private String created_at;
+    @JsonProperty("Body")
+    private String Body;
 }

+ 8 - 6
netflix-service/src/main/java/com/cyksj/service/mail/impl/CommonMailServiceImpl.java

@@ -84,18 +84,20 @@ public class CommonMailServiceImpl implements CommonMailService {
 		//Adobe 获取验证码
 		if (goodsId == Constant.ADOBE_GOODS_ID) {
 			try {
-				String url = "http://www.yxiang6.com/api/GetLastEmails?email=%s&boxType=1&num=5" + account;
+                String url = String.format("http://www.yxiang6.com/api/GetLastEmails?email=%s&boxType=1&num=2", account);
                 HttpRequest post = HttpUtil.createGet(url).header("x-admin-auth", "xin456");
 				HttpResponse execute = post.execute();
 				JSONObject resp = Jsons.parseObject(execute.body(), JSONObject.class);
-				List<AdobeEmailResp> AdobeEmailResps = Jsons.parseList(resp.getObj("results"), AdobeEmailResp.class);
+				List<AdobeEmailResp> AdobeEmailResps = Jsons.parseList(resp.getObj("data"), AdobeEmailResp.class);
 				if (CollUtil.isNotEmpty(AdobeEmailResps)) {
 					for (AdobeEmailResp adobeEmailResp : AdobeEmailResps) {
 						String str = "Your verification code is";
-						if (StrUtil.equals(adobeEmailResp.getAddress(), account) && StrUtil.isNotBlank(adobeEmailResp.getRaw()) && adobeEmailResp.getRaw().contains(str)) {
-							String code = StrUtil.subAfter(adobeEmailResp.getRaw(), str, false);
-							return StringUtil.getVerifyCodePattern(code, 6);
-						}
+                        String body = adobeEmailResp.getBody();
+                        if (adobeEmailResp.getTo().contains(account) && StrUtil.isNotBlank(body) && body.contains(str)) {
+                            String code = StrUtil.subAfter(body, str, false);
+                            code = code.replaceAll("<[^>]*>", " ");
+                            return StringUtil.getVerifyCodePattern(code, 6);
+                        }
 					}
 				}
 			} catch (Exception e) {