Skip to content

Commit

Permalink
✨ (短信中国银行): 新增中国银行支出短信解析功能 #632
Browse files Browse the repository at this point in the history
新增对中国银行支出短信的解析规则,支持提取交易金额、时间、账户信息等,并添加相应的测试用例。
  • Loading branch information
AnkioTomas committed Dec 27, 2024
1 parent 86fc176 commit e4a79bf
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
22 changes: 21 additions & 1 deletion src/rule/com.android.phone/app/短信中国银行/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BillType, formatDate, RuleObject, splitSms, toFloat, transferCurrency } from 'common/index.js';
import { BillType, formatDate, isPaymentType, RuleObject, splitSms, toFloat, transferCurrency } from 'common/index.js';

// 正则表达式和处理函数的映射关系
const rules = [
Expand All @@ -23,6 +23,26 @@ const rules = [
}
],

[
// 尊敬的黄胜辉,您在2024-12-24 13:05:14使用银行卡1502进行了RMB 45.00元的网上支付交易。详询95566
/尊敬的(.*?),您在(.*?)使用银行卡(\d{4})进行了(.*?) ([\d,]+.\d{2})元的(.*?)交易。/,
match => {
let [, name, date, number, currency, money, type] = match;

let obj = new RuleObject();
let { matchType, typeName } = isPaymentType(type);
obj.money = toFloat(money);
obj.channel = `中国银行[${typeName}]`;
obj.currency = transferCurrency(currency);
obj.time = formatDate(date, 'Y-M-D h:i:s');
obj.type = matchType;
obj.accountNameFrom = `中国银行(${number})`;
obj.shopName = name;
obj.shopItem = type;

return obj;
}
]


];
Expand Down
16 changes: 16 additions & 0 deletions src/rule/com.android.phone/app/短信中国银行/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,19 @@ test('中国银行信用卡支出', () =>
"channel": '中国银行信用卡[消费]',
},
]));

test('中国银行支出', () =>
testAnkio('中国银行支出', [
{
'type': 'Expend',
'money': 45,
'fee': 0,
'shopName': '黄胜辉',
'shopItem': '网上支付',
'accountNameFrom': '中国银行(1502)',
'accountNameTo': '',
'currency': 'CNY',
'time': formatDate('2024-12-24 13:05:14', 'Y-M-D h:i:s'),
'channel': '中国银行[支出]'
}
]));
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sender": "95566",
"body": "尊敬的黄胜辉,您在2024-12-24 13:05:14使用银行卡1502进行了RMB 45.00元的网上支付交易。详询95566【中国银行】",
"t": 1735016724565
}

0 comments on commit e4a79bf

Please sign in to comment.