-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ (utils): 添加 splitShop 函数用于处理店铺名称和商品名称的分隔逻辑 #475
✨ (rule): 新增招商银行微信公众号交易提醒规则及测试用例 ✅ (test): 添加招商银行消费测试用例
- Loading branch information
1 parent
d319fe9
commit 1b38b9e
Showing
4 changed files
with
102 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,38 @@ | ||
import { BillType, Currency, formatDate, parseWechat, RuleObject, toFloat } from 'common/index.js'; | ||
import { splitShop } from 'common/Html.js'; | ||
|
||
// 定义源名称和需要匹配的标题数组 | ||
const SOURCE = '招商银行'; | ||
const TITLE = ['交易提醒']; | ||
|
||
// 正则表达式和处理函数的映射关系 | ||
const rules = [ | ||
[ | ||
// 交易卡号:**** 5157\n交易时间:11月07日 11:50\n交易类型:财付通-微信支付-群收款快捷支付扣款\n交易金额:人民币20.00元 | ||
/交易卡号:.*? (\d+)\n交易时间:(.*?)\n交易类型:(.*?)\n交易金额:人民币(.*?)元/, | ||
match => { | ||
const [,number, time, shopItem_, money] = match; | ||
let {shopName,shopItem} = splitShop(shopItem_); | ||
return new RuleObject( | ||
BillType.Expend, | ||
toFloat(money), | ||
shopName, | ||
shopItem, | ||
`${SOURCE}(${number})`, | ||
'', | ||
0.0, | ||
Currency['人民币'], | ||
formatDate(time, 'M月D日 h:i'), | ||
`微信[${SOURCE}-消费]`) | ||
} | ||
], | ||
]; | ||
|
||
|
||
/** | ||
* @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,25 @@ | ||
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": 20, | ||
"fee": 0, | ||
"shopName": '财付通-微信支付', | ||
"shopItem": '群收款快捷支付扣款', | ||
"accountNameFrom": '招商银行(5157)', | ||
"accountNameTo": '', | ||
"currency": 'CNY', | ||
"time": formatDate('11月07日 11:50', '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,13 @@ | ||
{ | ||
"mMap": { | ||
"tableName": "AppMessage", | ||
"description": "交易卡号:**** 5157\n交易时间:11月07日 11:50\n交易类型:财付通-微信支付-群收款快捷支付扣款\n交易金额:人民币20.00元", | ||
"source": "招商银行", | ||
"t": 1730951431953, | ||
"arg": "msgId", | ||
"type": 5, | ||
"appId": "", | ||
"msgId": 254303, | ||
"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