-
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.
新增支付宝花呗支付规则,包括解析交易提醒的JSON数据并生成账单对象。同时添加了相应的测试用例,确保规则解析的正确性。
- Loading branch information
1 parent
5041831
commit 2a570e4
Showing
3 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/rule/com.eg.android.AlipayGphone/notice/支付宝花呗支付/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,24 @@ | ||
import { BillType, RuleObject, toFloat } from 'common/index.js'; | ||
|
||
export function get (data) { | ||
let json = JSON.parse(data); | ||
// 你有一笔43.73元的支出,点击领取4个支付宝积分。使用花呗支付,请及时还款。 | ||
let regex = /你有一笔([\d,]+.\d{2})元的支出,点击领取\d+个支付宝积分。使用花呗支付,请及时还款。/; | ||
const match = json.text.match(regex); | ||
if (!match) { | ||
return null; | ||
} | ||
let [, money] = match; | ||
let obj = new RuleObject(); | ||
|
||
obj.money = toFloat(money); | ||
obj.channel = `支付宝花呗[支出]`; | ||
obj.shopName = '支付宝'; | ||
obj.shopItem = json.text; | ||
obj.time = json.t; | ||
|
||
obj.type = BillType.Expend; | ||
|
||
obj.accountNameFrom = `支付宝花呗`; | ||
return obj; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/rule/com.eg.android.AlipayGphone/notice/支付宝花呗支付/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, 'com.eg.android.AlipayGphone'); | ||
test('支付宝花呗支付', () => | ||
testAnkio('支付宝花呗支付', [ | ||
{ | ||
'type': 'Expend', | ||
'money': 43.73, | ||
'fee': 0, | ||
'shopName': '支付宝', | ||
'shopItem': '你有一笔43.73元的支出,点击领取4个支付宝积分。使用花呗支付,请及时还款。', | ||
'accountNameFrom': '支付宝花呗', | ||
'accountNameTo': '', | ||
'currency': 'CNY', | ||
'time': 1734576048462, | ||
'channel': '支付宝花呗[支出]' | ||
} | ||
])); |
1 change: 1 addition & 0 deletions
1
src/rule/com.eg.android.AlipayGphone/notice/支付宝花呗支付/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 @@ | ||
{"title":"交易提醒","text":"你有一笔43.73元的支出,点击领取4个支付宝积分。使用花呗支付,请及时还款。","t":1734576048462} |