Skip to content

Commit

Permalink
✨新增适配微信公众号长沙银行支付宝支付取出 #31
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Jones committed Apr 10, 2024
1 parent 49bfd71 commit f60f085
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/rule/app/com.tencent.mm/微信公众号长沙银行/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { RuleObject } from "../../../../utils/RuleObject";
import { BillType } from "../../../../utils/BillType";
import { Currency } from "../../../../utils/Currency";


export function get(data) {
data = JSON.parse(data);
let mapItem = data.mMap;
if (mapItem.source!=="长沙银行") return null;
if (mapItem.title==="交易成功提醒") {
let result = {
type: null,
money: 0,
fee: 0,
shopName: "",
shopItem: "",
accountNameFrom: "",
accountNameTo: "",
currency: null,
time: null,
channel:"长沙银行"+mapItem.title
};
let text = mapItem.description;
let regex = /交易时间:(.*?)\n交易类型:(.*?)(个人账户:尾号(\d{4}))\n交易金额:人民币(.*?)元\n账户余额:.*?元\n交易说明:(.*)/;
let match = text.match(regex);
if (match) {
if (match[2].includes("支付取出")) {
result.type = BillType.Expend;
}
result.time = match[1];
result.shopItem = match[5];
result.money = parseFloat(match[4]);
result.accountNameFrom =`长沙银行(${match[3]})`;
result.currency = Currency['人民币'];
}
return new RuleObject(
result.type,
result.money,
result.shopName,
result.shopItem,
result.accountNameFrom,
result.accountNameTo,
result.fee,
result.currency,
result.time,
result.channel
);
}
}
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');

test("长沙住房公积金每月汇缴", () => {

const dataFilePath = path.join(__dirname, 'tests', '长沙银行支付宝支付取出.txt');
// 使用readFileSync来同步读取文件内容
const data = fs.readFileSync(dataFilePath, 'utf8')

let result = get(data);

expect(result).toEqual({
type: 0,
money: 200,
fee: 0,
shopName: '',
shopItem: '中国电信股份有限公司全渠道运营中心-商品...',
accountNameFrom: '长沙银行(2754)',
accountNameTo: '',
currency: 'CNY',
time: "04月10日09:03",
channel: '长沙银行交易成功提醒'
});
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"mMap":{"tableName":"AppMessage","description":"交易时间:04月10日09:03\n交易类型:支付宝支付取出(个人账户:尾号2754)\n交易金额:人民币200.00元\n账户余额:19,720.27元\n交易说明:中国电信股份有限公司全渠道运营中心-商品...","source":"长沙银行","arg":"msgId","type":5,"appId":"","msgId":60255,"title":"交易成功提醒"}}

0 comments on commit f60f085

Please sign in to comment.