-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ (rule): 添加微信公众号郑州银行信用卡的规则解析和测试文件 #630
新增了针对微信公众号郑州银行信用卡的规则解析文件 `main.js`,包含交易提醒的正则匹配和处理逻辑。同时添加了对应的测试文件 `main.test.js` 和测试数据文件 `郑州银行信用卡消费.txt`,确保规则解析的正确性。
- Loading branch information
1 parent
8907a97
commit 4f352b7
Showing
3 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Currency, formatDate, isPaymentType, parseWechat, RuleObject, toFloat } from 'common/index.js'; | ||
|
||
// 定义源名称和需要匹配的标题数组 | ||
const SOURCE = '郑州银行信用卡'; | ||
const TITLE = ['交易提醒']; | ||
|
||
// 正则表达式和处理函数的映射关系 | ||
const rules = [ | ||
[ | ||
/交易时间:(.*?)\n交易类型:(.*?)(尾号(\d+))\n交易金额:人民币(.*?)元,当前可用额度:.*?元/, | ||
match => { | ||
const [, time, type, number, money] = match; | ||
let { matchType, typeName } = isPaymentType(type); | ||
return new RuleObject( | ||
matchType, | ||
toFloat(money), | ||
'', | ||
'', | ||
`${SOURCE}(${number})`, | ||
'', | ||
0.0, | ||
Currency['人民币'], | ||
formatDate(time, 'Y年M月D日h时i分'), // 2024年12月24日09时09分 | ||
`微信[${SOURCE}-${typeName}]` | ||
); | ||
} | ||
] | ||
]; | ||
|
||
/** | ||
* 获取规则对象 | ||
* @param {string} data - JSON格式的数据 | ||
* @returns {RuleObject|null} - 规则对象,如果获取失败则返回null | ||
*/ | ||
export function get (data) { | ||
return parseWechat(data, rules, SOURCE, TITLE); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const { get } = require('./main'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { testAnkioInit, testAnkio } = require('../../../../tests/TestUtils'); | ||
|
||
const { formatDate } = require('common/index.js'); | ||
|
||
testAnkioInit(get, __dirname, 'com.tencent.mm'); | ||
|
||
test('郑州银行信用卡消费', () => | ||
testAnkio('郑州银行信用卡消费', [ | ||
{ | ||
'type': 'Expend', | ||
'money': 5.24, | ||
'fee': 0, | ||
'shopName': '', | ||
'shopItem': '', | ||
'accountNameFrom': '郑州银行信用卡(2328)', | ||
'accountNameTo': '', | ||
'currency': 'CNY', | ||
'time': formatDate('2024年12月24日09时09分', 'Y年M月D日h时i分'), | ||
'channel': '微信[郑州银行信用卡-支出]' | ||
} | ||
])); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"mMap":{"tableName":"AppMessage","description":"交易时间:2024年12月24日09时09分\n交易类型:消费(尾号2328)\n交易金额:人民币5.24元,当前可用额度:8015.87元","source":"郑州银行信用卡","t":1735002582703,"arg":"msgId","type":5,"appId":"","msgId":249840,"title":"交易提醒"}} |