Skip to content

Commit

Permalink
🎉 新增微信公众号农业银行退款规则、支出额外兼容一种可能出现的消息格式 (#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
TrioTea authored Dec 2, 2024
1 parent 58faaaa commit 675f1cc
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ const TITLE = ['交易成功通知'];
const rules = [
// 支出规则
[
/交易时间:(.*?)\n交易类型:卡号尾号((\d+)),网上支付\n交易金额:([\d,]+.\d{2})元\n可用余额:.*?元\n交易地址:(.*?),(.*?)$/,
/交易时间:(.*?)\n交易类型:卡号尾号((\d+)),网上支付\n交易金额:([\d,]+.\d{2})元\n可用余额:.*?元\n交易地址:(.*?)(?:,(.*))?$/,
match => {
const [, time, number, money, shopName, shopItem] = match;

return new RuleObject(
BillType.Expend,
toFloat(money),
shopName,
shopItem,
shopItem || shopName, // 如果没有详细描述,则使用商户名称作为描述
`${SOURCE}(${number})`,
'',
0.0,
Expand All @@ -35,7 +35,7 @@ const rules = [
return new RuleObject(
BillType.Income, // 收入类型
toFloat(money),
SOURCE,
SOURCE, // 商户名称(如:农业银行信用卡)
description, // 描述(如:天天返现)
`${SOURCE}(${number})`,
'',
Expand All @@ -46,6 +46,25 @@ const rules = [
)
},
],
// 收入规则(退款收入)
[
/交易时间:(.*?)\n交易类型:卡号尾号((\d+)),退货\n交易金额:([\d,]+.\d{2})元\n可用余额:.*?元\n交易地址:(.*)$/,
match => {
const [, time, number, money, description] = match;
return new RuleObject(
BillType.Income, // 收入类型
toFloat(money),
description, // 商户名称(如:多多支付退款)
description, // 描述
`${SOURCE}(${number})`,
'',
0.0,
Currency['人民币'],
formatDate(time, 'Y-M-D h:i:s'),
`退款[${SOURCE}-收入]`
)
},
],
];


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,22 @@ test('农业银行信用卡支出', () =>
},
]));

test('农业银行信用卡支出2', () =>
testAnkio('农业银行信用卡支出2', [
{
"type": "Expend",
"money": 2.00,
"fee": 0,
"shopName": "杭州兑吧网络科技有限公司",
"shopItem": "杭州兑吧网络科技有限公司",
"accountNameFrom": "农业银行信用卡(8487)",
"accountNameTo": "",
"currency": "CNY",
"time": formatDate('2024-12-02 08:21:01', 'Y-M-D h:i:s'),
"channel": "杭州兑吧网络科技有限公司[农业银行信用卡-消费]"
}
]));

test("农业银行信用卡刷卡金返现", () =>
testAnkio('农业银行信用卡刷卡金返现', [
{
Expand All @@ -37,4 +53,20 @@ test("农业银行信用卡刷卡金返现", () =>
"time": formatDate('2024-11-21 09:15:06', 'Y-M-D h:i:s'),
"channel": '刷卡金返现[农业银行信用卡-收入]'
}
]));
]));

test('农业银行信用卡退款', () =>
testAnkio('农业银行信用卡退款', [
{
"type": "Income",
"money": 17.67,
"fee": 0,
"shopName": "多多支付退款",
"shopItem": "多多支付退款",
"accountNameFrom": "农业银行信用卡(6395)",
"accountNameTo": "",
"currency": "CNY",
"time": formatDate('2024-12-02 12:32:19', 'Y-M-D h:i:s'),
"channel": "退款[农业银行信用卡-收入]"
}
]));
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"mMap":{"tableName":"AppMessage","description":"交易时间:2024-12-02 08:21:01\n交易类型:卡号尾号(8487),网上支付\n交易金额:2.00元\n可用余额:5818.22元\n交易地址:杭州兑吧网络科技有限公司","source":"农业银行信用卡","t":1733098872406,"arg":"msgId","type":5,"appId":"","msgId":11269488,"title":"交易成功通知"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"mMap":{"tableName":"AppMessage","description":"交易时间:2024-12-02 12:32:19\n交易类型:卡号尾号(6395),退货\n交易金额:17.67元\n可用余额:29478.66元\n交易地址:多多支付退款","source":"农业银行信用卡","t":1733113940899,"arg":"msgId","type":5,"appId":"","msgId":361339,"title":"交易成功通知"}}

0 comments on commit 675f1cc

Please sign in to comment.