-
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.
新增对招商银行收款通知的处理规则,支持解析“您账户6598于10月23日13:03收款人民币8650.00”格式文本。更新测试用例以验证新规则的正确性,并添加新的测试文件。
- Loading branch information
1 parent
82991d0
commit 1d597bd
Showing
3 changed files
with
68 additions
and
21 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 |
---|---|---|
@@ -1,27 +1,57 @@ | ||
import { BillType, Currency, RuleObject, toFloat } from 'common/index.js'; | ||
import { BillType, Currency, formatDate, RuleObject, toFloat, transferCurrency } from 'common/index.js'; | ||
|
||
// {"title":"招商银行","text":"您尾号6598的招行一卡通入账人民币1442.00元",t} | ||
export function get(data) { | ||
let json = JSON.parse(data) | ||
// 您尾号6598的招行一卡通入账人民币1442.00元 | ||
let regex = /您尾号(\d{4})的(.*?)入账(.*?)([\d,]+.\d{2})元/ | ||
const match = json.text.match(regex); | ||
if (!match) { | ||
return null; | ||
} | ||
let [,number,cardName,currency,money] = match; | ||
|
||
let obj = new RuleObject(); | ||
let rules = [ | ||
[ | ||
/您尾号(\d{4})的(.*?)入账(.*?)([\d,]+.\d{2})元/, | ||
(match,json) => { | ||
let [,number,cardName,currency,money] = match; | ||
|
||
let obj = new RuleObject(); | ||
|
||
obj.money = toFloat(money); | ||
obj.channel = `招商银行[入账]`; | ||
obj.shopName =cardName; | ||
obj.shopItem = "入账"; | ||
obj.currency = Currency[currency]; | ||
obj.time = json.t; | ||
|
||
obj.type = BillType.Income | ||
|
||
obj.accountNameFrom = `招商银行(${number})`; | ||
return obj; | ||
} | ||
], | ||
[ | ||
// 您账户6598于10月23日13:03收款人民币8650.00 | ||
/您账户(\d{4})于(.*?)收款(.*?)([\d,]+.\d{2})/, | ||
(match,json) => { | ||
let [,number,date,currency,money] = match; | ||
|
||
obj.money = toFloat(money); | ||
obj.channel = `招商银行[入账]`; | ||
obj.shopName =cardName; | ||
obj.shopItem = "入账"; | ||
obj.currency = Currency[currency]; | ||
obj.time = json.t; | ||
let obj = new RuleObject(); | ||
|
||
obj.type = BillType.Income | ||
obj.money = toFloat(money); | ||
obj.channel = `招商银行[收款]`; | ||
obj.shopItem = "入账"; | ||
obj.currency = Currency[currency]; | ||
obj.time = json.t; | ||
|
||
obj.accountNameFrom = `招商银行(${number})`; | ||
return obj; | ||
obj.type = BillType.Income | ||
|
||
obj.accountNameFrom = `招商银行(${number})`; | ||
return obj; | ||
} | ||
], | ||
] | ||
|
||
export function get(data) { | ||
let json = JSON.parse(data) | ||
|
||
for (let [regex,handler] of rules) { | ||
const match = json.text.match(regex); | ||
if (match) { | ||
return handler(match,json); | ||
} | ||
} | ||
return null; | ||
} |
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
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": "您账户6598于10月23日13:03收款人民币8650.00", | ||
"t": 1729659785984 | ||
} |