Skip to content

Commit

Permalink
✨ (rule): 添加招商银行退款短信解析规则 #609
Browse files Browse the repository at this point in the history
新增招商银行退款短信的解析规则,支持解析退款金额、商户信息及时间等字段。同时添加了相应的测试用例和测试数据文件,确保规则的正确性。
  • Loading branch information
AnkioTomas committed Dec 28, 2024
1 parent 79ae6ca commit 21b2f43
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/rule/com.android.phone/app/短信招商银行/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,25 @@ const rules = [
obj.shopItem = '银联卡转入';
obj.time = formatDate(date, 'M月D日');

obj.type = BillType.Income;
obj.accountNameFrom = `招商银行(${number})`;
return obj;
}
],
[
//【招商银行】您账户0877于12月16日23:38在支付宝-盈思网络科技(深圳)有限公司退款4529.48元
/您账户(\d{4})于(\d+月\d+日\d+:\d+)在(.*?)退款([\d,]+.\d{2})元/,
match => {
let [, number, date, merchant, money] = match;

let obj = new RuleObject();

obj.money = toFloat(money);
obj.channel = `招商银行[退款]`;
obj.currency = 'CNY';
obj.shopItem = `${merchant}`;
obj.time = formatDate(date, 'M月D日h:i');

obj.type = BillType.Income;
obj.accountNameFrom = `招商银行(${number})`;
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
@@ -1,3 +1,4 @@

const { get } = require('./main');
const { testAnkio, testAnkioInit } = require('../../../../tests/TestUtils');
const { formatDate } = require('common/Time.js');
Expand Down Expand Up @@ -64,3 +65,18 @@ test('招商银行收入', () =>
}
]));

test('招商银行退款', () =>
testAnkio('招商银行退款', [
{
'type': 'Income',
'money': 4529.48,
'fee': 0,
'shopName': '',
'shopItem': '支付宝-盈思网络科技(深圳)有限公司',
'accountNameFrom': '招商银行(0877)',
'accountNameTo': '',
'currency': 'CNY',
'time': formatDate('12月16日23:38', 'M月D日h:i'),
'channel': '招商银行[退款]'
}
]));
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"sender":"95555","body":"【招商银行】您账户0877于12月16日23:38在支付宝-盈思网络科技(深圳)有限公司退款4529.48元","t":1734363498181}

0 comments on commit 21b2f43

Please sign in to comment.