-
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.
新增掌上生活消费通知的规则处理逻辑,包括解析消费信息、生成账单对象等功能。同时添加了相应的测试用例,确保规则的正确性和稳定性。
- Loading branch information
1 parent
349f1f3
commit 60dbd74
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/rule/com.cmbchina.ccd.pluto.cmbActivity/app/掌上生活消费通知/main.js
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,27 @@ | ||
import { BillType, RuleObject, splitShop, toFloat } from 'common/index.js'; | ||
|
||
export function get (data) { | ||
let json = JSON.parse(data); | ||
// 信用卡通知:您尾号1356的招行信用卡消费6225.34人民币。 | ||
// 信用卡通知:您尾号1356的招行信用卡预授权1,362.41人民币。 | ||
// 您在美团支付-美团App酱新香酥鸡饼(鸡柳拌饼益有一笔29.96人民币的消费已成功,点击查看详情【消费达标集喵赢好礼,限特邀用户,戳此>>】 | ||
let regex = /您在(.*?)有一笔(.*?)人民币的消费已成功,点击查看详情/; | ||
const match = json.text.match(regex); | ||
if (!match) { | ||
return null; | ||
} | ||
|
||
let obj = new RuleObject(); | ||
|
||
let [, shopItem_, money] = match; | ||
let { shopName, shopItem } = splitShop(shopItem_); | ||
obj.money = toFloat(money); | ||
obj.channel = `掌上生活[信用卡消费]`; | ||
obj.shopName = shopName; | ||
obj.shopItem = shopItem; | ||
obj.time = json.t; | ||
obj.type = BillType.Expend; | ||
|
||
obj.accountNameFrom = `招商银行信用卡`; | ||
return obj; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/rule/com.cmbchina.ccd.pluto.cmbActivity/app/掌上生活消费通知/main.test.js
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,20 @@ | ||
const { get } = require('./main'); | ||
const { testAnkio, testAnkioInit } = require('../../../../tests/TestUtils'); | ||
const { formatDate } = require('common/Time.js'); | ||
|
||
testAnkioInit(get, __dirname, 'cmb.pb'); | ||
test('掌上生活消费通知', () => | ||
testAnkio('掌上生活消费通知', [ | ||
{ | ||
'type': 'Expend', | ||
'money': 29.96, | ||
'fee': 0, | ||
'shopName': '美团支付', | ||
'shopItem': '美团App酱新香酥鸡饼(鸡柳拌饼益', | ||
'accountNameFrom': '招商银行信用卡', | ||
'accountNameTo': '', | ||
'currency': 'CNY', | ||
'time': 1735045607824, | ||
'channel': '掌上生活[信用卡消费]' | ||
} | ||
])); |
5 changes: 5 additions & 0 deletions
5
src/rule/com.cmbchina.ccd.pluto.cmbActivity/app/掌上生活消费通知/tests/掌上生活消费通知.txt
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,5 @@ | ||
{ | ||
"title": "交易提醒", | ||
"text": "您在美团支付-美团App酱新香酥鸡饼(鸡柳拌饼益有一笔29.96人民币的消费已成功,点击查看详情【消费达标集喵赢好礼,限特邀用户,戳此>>】", | ||
"t": 1735045607824 | ||
} |