代码优化
This commit is contained in:
@@ -35,7 +35,13 @@ public class EmailParseForm95555(
|
||||
DateTime? occurredAt
|
||||
)[]> ParseEmailContentAsync(string emailContent)
|
||||
{
|
||||
var pattern = "您账户(?<card>\\d+)于.*?(?<type>收入|支出|消费|转入|转出)?.*?在?(?<reason>.+?)(?<amount>\\d+\\.\\d{1,2})元,余额(?<balance>\\d+\\.\\d{1,2})";
|
||||
var pattern =
|
||||
"您账户(?<card>\\d+)" +
|
||||
"于.*?" + // 时间等信息统统吞掉
|
||||
"(?:(?<type>收入|支出|消费|转入|转出).*?)?" + // 可选 type
|
||||
"(?:在(?<reason>.*?))?" + // 可选 reason(“财付通-微信支付-这有电快捷支付”)
|
||||
"(?<amount>\\d+\\.\\d{1,2})元,余额" +
|
||||
"(?<balance>\\d+\\.\\d{1,2})";
|
||||
|
||||
var matches = Regex.Matches(emailContent, pattern);
|
||||
|
||||
|
||||
@@ -144,6 +144,17 @@ public class EmailParseFormCCSVC(
|
||||
reason = string.Join(" ", parts.Skip(2));
|
||||
}
|
||||
|
||||
// 招商信用卡特殊,消费金额为正数,退款为负数
|
||||
if(amount > 0)
|
||||
{
|
||||
type = TransactionType.Expense;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = TransactionType.Income;
|
||||
amount = Math.Abs(amount);
|
||||
}
|
||||
|
||||
result.Add((card, reason, amount, balance, type, occurredAt));
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in New Issue
Block a user