更新邮件解析服务,添加主题参数以增强解析能力;修改HTML文件以支持PWA和优化视图设置
This commit is contained in:
@@ -50,9 +50,10 @@ public class EmailHandleService(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var parsed = await ParseEmailBodyAsync(
|
var parsed = await ParseEmailBodyAsync(
|
||||||
from,
|
from,
|
||||||
string.IsNullOrEmpty(emailMessage.Body)
|
subject,
|
||||||
? emailMessage.HtmlBody
|
string.IsNullOrEmpty(emailMessage.Body)
|
||||||
|
? emailMessage.HtmlBody
|
||||||
: emailMessage.Body
|
: emailMessage.Body
|
||||||
);
|
);
|
||||||
if (parsed == null || parsed.Length == 0)
|
if (parsed == null || parsed.Length == 0)
|
||||||
@@ -112,7 +113,8 @@ public class EmailHandleService(
|
|||||||
|
|
||||||
var parsed = await ParseEmailBodyAsync(
|
var parsed = await ParseEmailBodyAsync(
|
||||||
emailMessage.From,
|
emailMessage.From,
|
||||||
string.IsNullOrEmpty(emailMessage.Body)
|
emailMessage.Subject,
|
||||||
|
string.IsNullOrEmpty(emailMessage.Body)
|
||||||
? emailMessage.HtmlBody
|
? emailMessage.HtmlBody
|
||||||
: emailMessage.Body
|
: emailMessage.Body
|
||||||
);
|
);
|
||||||
@@ -159,7 +161,7 @@ public class EmailHandleService(
|
|||||||
{
|
{
|
||||||
From = from,
|
From = from,
|
||||||
Subject = subject,
|
Subject = subject,
|
||||||
|
|
||||||
ReceivedDate = date,
|
ReceivedDate = date,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -260,9 +262,9 @@ public class EmailHandleService(
|
|||||||
return inserted;
|
return inserted;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<(string card, string reason, decimal amount, decimal balance, TransactionType type, DateTime? occurredAt)[]?> ParseEmailBodyAsync(string from, string body)
|
private async Task<(string card, string reason, decimal amount, decimal balance, TransactionType type, DateTime? occurredAt)[]?> ParseEmailBodyAsync(string from, string subject, string body)
|
||||||
{
|
{
|
||||||
var service = emailParsers.FirstOrDefault(s => s.CanParse(from, body));
|
var service = emailParsers.FirstOrDefault(s => s.CanParse(from, subject, body));
|
||||||
|
|
||||||
if (service == null)
|
if (service == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,13 +5,18 @@ public class EmailParseForm95555(
|
|||||||
IOpenAiService openAiService
|
IOpenAiService openAiService
|
||||||
) : EmailParseServicesBase(logger, openAiService)
|
) : EmailParseServicesBase(logger, openAiService)
|
||||||
{
|
{
|
||||||
public override bool CanParse(string from, string body)
|
public override bool CanParse(string from, string subject, string body)
|
||||||
{
|
{
|
||||||
if (!from.Contains("95555@message.cmbchina.com"))
|
if (!from.Contains("95555@message.cmbchina.com"))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!subject.Contains("账户变动通知"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// 不能包含HTML标签
|
// 不能包含HTML标签
|
||||||
if (Regex.IsMatch(body, "<.*?>"))
|
if (Regex.IsMatch(body, "<.*?>"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,13 +7,18 @@ public class EmailParseFormCCSVC(
|
|||||||
IOpenAiService openAiService
|
IOpenAiService openAiService
|
||||||
) : EmailParseServicesBase(logger, openAiService)
|
) : EmailParseServicesBase(logger, openAiService)
|
||||||
{
|
{
|
||||||
public override bool CanParse(string from, string body)
|
public override bool CanParse(string from, string subject, string body)
|
||||||
{
|
{
|
||||||
if (!from.Contains("ccsvc@message.cmbchina.com"))
|
if (!from.Contains("ccsvc@message.cmbchina.com"))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!subject.Contains("每日信用管家"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// 必须包含HTML标签
|
// 必须包含HTML标签
|
||||||
if (!Regex.IsMatch(body, "<.*?>"))
|
if (!Regex.IsMatch(body, "<.*?>"))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
public interface IEmailParseServices
|
public interface IEmailParseServices
|
||||||
{
|
{
|
||||||
bool CanParse(string from, string body);
|
bool CanParse(string from, string subject, string body);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 解析邮件内容,提取交易信息
|
/// 解析邮件内容,提取交易信息
|
||||||
@@ -22,7 +22,7 @@ public abstract class EmailParseServicesBase(
|
|||||||
IOpenAiService openAiService
|
IOpenAiService openAiService
|
||||||
) : IEmailParseServices
|
) : IEmailParseServices
|
||||||
{
|
{
|
||||||
public abstract bool CanParse(string from, string body);
|
public abstract bool CanParse(string from, string subject, string body);
|
||||||
|
|
||||||
public async Task<(
|
public async Task<(
|
||||||
string card,
|
string card,
|
||||||
|
|||||||
@@ -3,8 +3,15 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="icon" href="/favicon.ico">
|
<link rel="icon" href="/favicon.ico">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover">
|
||||||
<title>Vite App</title>
|
|
||||||
|
<!-- PWA - 让应用在添加到主屏幕后以全屏模式运行 -->
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||||
|
<meta name="apple-mobile-web-app-title" content="账单管理">
|
||||||
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
|
|
||||||
|
<title>账单管理</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user