Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨新增适配微信公众号长沙住房公积金每月汇缴 #30 #34

Merged
merged 10 commits into from
Apr 10, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ function handleLink(pl, result) {
case pl.link.includes("bizType=B_TRANSFER"): //支付宝发红包
case pl.link.includes("bizType=TRADE"): //支付宝消费
case pl.link.includes("bizType=PREAUTHPAY"): //支付宝预授权消费
case pl.link.includes("bizType=PPAY"): //支付宝亲情卡消费
result.type = BillType.Expend;
break;
case pl.link.includes("bizType=D_TRANSFER"): //支付宝转账收款
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,4 +216,22 @@ test("支付宝预授权消费", () => {
});
})

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: 55,
fee: 0,
shopName: "173******86(未实名)",
shopItem: "",
accountNameFrom: "北京银行信用购(原花呗)",
accountNameTo: "",
currency: "CNY",
time: 1712723745000,
channel: "支付宝付款成功"
});
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"mk":240450123544200019,"st":1,"isSc":0,"appId":"","mct":1712723745000,"pl":"{\"templateType\":\"BN\",\"commandType\":\"UPDATE\",\"withPushNfc\":\"Y\",\"expireLink\":\"\",\"msgType\":\"TODO\",\"icon\":\"https:\/\/gw.alipayobjects.com\/mdn\/rms_f96971\/afts\/img\/A*leNcS41oUu0AAAAAAAAAAABkARQnAQ\",\"link\":\"alipays:\/\/platformapi\/startapp?appId=20000003&actionType=toBillDetails&tradeNO=2024041004200106001019049767&bizType=PPAY?tagid=MB_SEND_PUSH_WALLET_NEW\",\"businessId\":\"PAY_HELPER_CARD_2088512606574244\",\"msgId\":\"3873c9591038f08e088ec85ac8e0b0d600424\",\"templateCode\":\"00059_00094_zfzs001\",\"templateId\":\"WALLET-BILL@BLPaymentHelper\",\"title\":\"付款成功\",\"content\":\"{\\\"status\\\":\\\"付款成功\\\",\\\"date\\\":\\\"04月10日\\\",\\\"amountTip\\\":\\\"\\\",\\\"money\\\":\\\"55.00\\\",\\\"unit\\\":\\\"元\\\",\\\"infoTip\\\":\\\"\\\",\\\"failTip\\\":\\\"\\\",\\\"goto\\\":\\\"alipays:\/\/platformapi\/startapp?appId=20000003&actionType=toBillDetails&tradeNO=2024041004200106001019049767&bizType=PPAY\\\",\\\"content\\\":[{\\\"title\\\":\\\"付款方式:\\\",\\\"content\\\":\\\"北京银行信用购(原花呗)\\\"},{\\\"title\\\":\\\"交易对象:\\\",\\\"content\\\":\\\"173******86(未实名)\\\"}],\\\"ad\\\":[],\\\"actions\\\":[{\\\"name\\\":\\\"\\\",\\\"url\\\":\\\"\\\"},{\\\"name\\\":\\\"查看详情\\\",\\\"url\\\":\\\"alipays:\/\/platformapi\/startapp?appId=20000003&actionType=toBillDetails&tradeNO=2024041004200106001019049767&bizType=PPAY\\\"}]}\",\"linkName\":\"\",\"bizName\":\"支付助手\",\"msgCategory\":\"bill\",\"scm\":\"27.gotone.card.3873c9591038f08e088ec85ac8e0b0d600424.MB_SEND_PUSH_WALLET_NEW.null.payment_assist.43545.11069.2019062521000502094325.990\",\"assistInfo\":\"{\\\"showInFriendTab\\\":false,\\\"icon\\\":\\\"https:\/\/gw.alipayobjects.com\/mdn\/rms_f96971\/afts\/img\/A*ZapXT6AjvG0AAAAAAAAAAABkARQnAQ\\\",\\\"reminderType\\\":\\\"point\\\",\\\"hiddenMsgHeader\\\":false,\\\"title\\\":\\\"支付助手\\\",\\\"reminderTypeModifyEnable\\\":false,\\\"assistId\\\":\\\"payment_assist\\\",\\\"desc\\\":\\\"支付宝资金变动通知\\\"}\",\"ih\":\"{\\\"extInfo\\\":{},\\\"iid\\\":\\\"105\\\",\\\"ioty\\\":\\\"aor\\\",\\\"itemBasicInfo\\\":{\\\"dn\\\":\\\"服务提醒\\\",\\\"ic\\\":\\\"https:\/\/gw.alipayobjects.com\/zos\/bmw-prod\/b96c31e0-64ba-4cbb-9a64-73ff17d701fd.webp\\\",\\\"lk\\\":\\\"alipays:\/\/platformapi\/startapp?appId=20000235&source=friendTab\\\"},\\\"itemUserRelation\\\":{\\\"ilf\\\":\\\"N\\\",\\\"uc\\\":{\\\"top\\\":\\\"0\\\",\\\"notDisturb\\\":\\\"1\\\"},\\\"version\\\":0},\\\"ity\\\":\\\"105\\\",\\\"moty\\\":\\\"u\\\",\\\"msgInfo\\\":{\\\"bm\\\":\\\"付款成功¥55.00 \\\",\\\"cmid\\\":\\\"3873c9591038f08e088ec85ac8e0b0d600424\\\",\\\"lmt\\\":1712723744833,\\\"msrid\\\":\\\"00059_00094_zfzs001\\\",\\\"ncs\\\":\\\"N\\\",\\\"rps\\\":\\\"num\\\",\\\"sam\\\":\\\"Y\\\",\\\"ssrid\\\":\\\"PAY_HELPER_CARD_2088512606574244\\\",\\\"urn\\\":1}}\",\"bizMonitor\":\"{\\\"serviceCode\\\":\\\"MB_SEND_PUSH_WALLET_NEW\\\",\\\"bizName\\\":\\\"\\\",\\\"createTime\\\":1712723744967,\\\"businessId\\\":\\\"PAY_HELPER_CARD_2088512606574244\\\",\\\"messageId\\\":\\\"3873c9591038f08e088ec85ac8e0b0d600424\\\",\\\"messageTitle\\\":\\\"付款成功\\\",\\\"pid\\\":\\\"2088732136474061\\\",\\\"templateId\\\":\\\"WALLET-BILL@BLPaymentHelper\\\",\\\"status\\\":\\\"\\\"}\",\"languageType\":\"zh-Hans\",\"subscribeConfig\":\"0\",\"gmtCreate\":1712723744833,\"gmtValid\":1715315744825,\"operate\":\"SEND\",\"templateName\":\"支付助手\",\"homePageTitle\":\"付款成功¥55.00 \",\"status\":\"\",\"extraInfo\":\"{\\\"topSubContent\\\":\\\"付款成功\\\",\\\"preValue\\\":\\\"¥\\\",\\\"languageType\\\":\\\"zh-Hans\\\",\\\"isPaymentMsg\\\":true,\\\"assistName2\\\":\\\"交易对象\\\",\\\"assistName3\\\":\\\"\\\",\\\"assistName1\\\":\\\"付款方式\\\",\\\"templateId\\\":\\\"WALLET-FWC@remindNumber\\\",\\\"content\\\":\\\"55.00\\\",\\\"linkName\\\":\\\"\\\",\\\"assistMsg3\\\":\\\"\\\",\\\"sceneExt2\\\":{\\\"sceneUrl\\\":\\\"alipays:\/\/platformapi\/startapp?appId=20000003&actionType=toBillDetails&tradeNO=2024041004200106001019049767&bizType=PPAY\\\",\\\"sceneType\\\":\\\"nativeApp\\\",\\\"sceneName\\\":\\\"亲情卡\\\",\\\"sceneIcon\\\":\\\"http:\/\/appstoreisvpic.alipayobjects.com\/5d109f2d-971e-414d-86ce-74177a801855.jpg\\\"},\\\"assistMsg2\\\":\\\"173******86(未实名)\\\",\\\"assistMsg1\\\":\\\"北京银行信用购(原花呗)\\\",\\\"assistName4\\\":\\\"\\\",\\\"assistMsg5\\\":\\\"\\\",\\\"assistMsg4\\\":\\\"\\\",\\\"assistName5\\\":\\\"\\\",\\\"buttonLink\\\":\\\"\\\",\\\"cardAdInfo\\\":{\\\"p14\\\":{\\\"bizMonitor\\\":{\\\"marketingUniqueId\\\":\\\"MUfc5358afc71b45b79d22981075c457dd\\\",\\\"marketingRuleId\\\":\\\"MR17530a7808ea4d99935fd8da3ee81181\\\",\\\"style\\\":\\\"singleLineText3\\\",\\\"marketingItemId\\\":\\\"MIb45d6a9220ae4e94ae68f06ad7badac8\\\"},\\\"expireTime\\\":1744259744900,\\\"marketingUniqueId\\\":\\\"MUfc5358afc71b45b79d22981075c457dd\\\",\\\"minClientVersion\\\":\\\"10.1.98\\\",\\\"recommendTemplateId\\\":\\\"singleLineText3\\\",\\\"viewInfo\\\":{\\\"arrowIcon\\\":\\\"https:\/\/img.alicdn.com\/tfs\/TB1fN1OdggP7K4jSZFqXXamhVXa-32-52.png\\\",\\\"actionType\\\":\\\"link\\\",\\\"actionUrl\\\":\\\"alipays:\/\/platformapi\/startapp?appId=2021001160630824&source=socialMessage&page=%2Fpages%2Fcard-detail%2Findex%3FselfRole%3DPAYER%26partnerUserId%3D2088732136474061%26source%3DsocialMessage%26jumpFrom%3DsocialMessage%26groupId%3D2088620128372649\\\",\\\"text\\\":\\\"管理亲情卡\\\",\\\"textColor\\\":\\\"#333333\\\"}},\\\"p116\\\":{\\\"bizMonitor\\\":{\\\"marketingUniqueId\\\":\\\"MU4948c414be4e495a944d76ae7a3d6cbb\\\",\\\"outBizId\\\":\\\"LIFE_MSG_TEXT|AMTT202303091019436279|202311280460607296\\\",\\\"marketingRuleId\\\":\\\"MR9b1daa035f8440668c2cd692768d3308\\\",\\\"style\\\":\\\"actionLine2\\\",\\\"marketingItemId\\\":\\\"MIe2bc161773614c6cb36a9dc4968a0908\\\"},\\\"expireTime\\\":1744259744966,\\\"marketingUniqueId\\\":\\\"MU4948c414be4e495a944d76ae7a3d6cbb\\\",\\\"minClientVersion\\\":\\\"10.1.98\\\",\\\"recommendTemplateId\\\":\\\"actionLine2\\\",\\\"viewInfo\\\":{\\\"btnName\\\":\\\"支付奖励\\\",\\\"actionType\\\":\\\"link\\\",\\\"tagIcon\\\":\\\"https:\/\/mdn.alipayobjects.com\/huamei_cke3ep\/afts\/img\/A*s1xhTYe-_PQAAAAAAAAAAAAADk1-AQ\/original\\\",\\\"tagColor\\\":\\\"#FF6011\\\",\\\"actionUrl\\\":\\\"alipays:\/\/platformapi\/startapp?appId=68687805&url=https%3A%2F%2Frender.alipay.com%2Fp%2Fyuyan%2F180020380000000023%2Fhome-page.html%3Fbid%3D202311280460607296%26source%3DLIFE_MSG_TEXT%26chInfo%3DLIFE_MSG_TEXT%26passInfo%3D%7B%22ttci%22%3A%22AMTT202303091019436279%22%2C%22ch%22%3A%22LIFE_MSG_TEXT%22%2C%22pci%22%3A%2210025391698%22%2C%22obn%22%3A%222024041004200106001019049767%22%7D\\\",\\\"tag\\\":\\\"领4积分去兑公交红包\\\"}}}}\"}"}]
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: Currency['人民币'],
time: null,
channel:mapItem.title
};
let text = mapItem.description;
let regex = /账户类型:(.*?)\n业务日期:(.*?)\n业务描述:(.*?)\n业务金额:(.*?)\n账户余额:.*/;
let match = text.match(regex);
if (match) {
if (match[3].includes("汇缴")) {
result.type = BillType.Income;
}
result.time = match[2];
result.shopName = mapItem.source;
result.shopItem = match[3];
result.money = parseFloat(match[4]);
result.accountNameFrom = match[1];
}
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: 1,
money: 2154,
fee: 0,
shopName: '长沙住房公积金',
shopItem: '汇缴[202404]',
accountNameFrom: '住房公积金账户',
accountNameTo: '',
currency: 'CNY',
time: "20240410",
channel: '公积金账户资金变动提醒'
});
})
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"mMap":{"tableName":"AppMessage","description":"账户类型:住房公积金账户\n业务日期:20240410\n业务描述:汇缴[202404]\n业务金额:2154\n账户余额:29625.63","source":"长沙住房公积金","arg":"msgId","type":5,"appId":"","msgId":60287,"title":"公积金账户资金变动提醒"}}
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":"交易成功提醒"}}