diff --git "a/src/rule/cmb.pb/notice/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\246\351\200\232\347\237\245/main.js" "b/src/rule/cmb.pb/notice/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\246\351\200\232\347\237\245/main.js" index f8835a9..4ba0377 100644 --- "a/src/rule/cmb.pb/notice/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\246\351\200\232\347\237\245/main.js" +++ "b/src/rule/cmb.pb/notice/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\246\351\200\232\347\237\245/main.js" @@ -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; } diff --git "a/src/rule/cmb.pb/notice/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\246\351\200\232\347\237\245/main.test.js" "b/src/rule/cmb.pb/notice/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\246\351\200\232\347\237\245/main.test.js" index b1fb1a2..db86f6c 100644 --- "a/src/rule/cmb.pb/notice/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\246\351\200\232\347\237\245/main.test.js" +++ "b/src/rule/cmb.pb/notice/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\246\351\200\232\347\237\245/main.test.js" @@ -30,4 +30,16 @@ test('招商银行入账', () => "time": 1729137578155, "channel": '招商银行[入账]', }, + { + "type": "Income", + "money": 8650, + "fee": 0, + "shopName": '', + "shopItem": '入账', + "accountNameFrom": '招商银行(6598)', + "accountNameTo": '', + "currency": 'CNY', + "time": 1729659785984, + "channel": '招商银行[收款]', + }, ])); diff --git "a/src/rule/cmb.pb/notice/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\246\351\200\232\347\237\245/tests/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\2463.txt" "b/src/rule/cmb.pb/notice/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\246\351\200\232\347\237\245/tests/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\2463.txt" new file mode 100644 index 0000000..9625274 --- /dev/null +++ "b/src/rule/cmb.pb/notice/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\246\351\200\232\347\237\245/tests/\346\213\233\345\225\206\351\223\266\350\241\214\345\205\245\350\264\2463.txt" @@ -0,0 +1,5 @@ +{ +"title": "招商银行", +"text": "您账户6598于10月23日13:03收款人民币8650.00", +"t": 1729659785984 +}