Skip to content

Commit

Permalink
✨新增适配微信支付转账过期退款 #74
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Jones committed Apr 14, 2024
1 parent d78a819 commit f427c99
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/rule/app/com.tencent.mm/微信支付/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { Currency } from "../../../../utils/Currency";

// 定义源名称和需要匹配的标题数组
const SOURCE_NAME_WECHAT = "微信支付";
const TITLES_WECHAT = ["已支付¥", "已扣费¥", "微信支付收款元"];
const TITLES_WECHAT = [
"已支付¥",
"已扣费¥",
"微信支付收款元",
"转账过期退款到账通知"
];

// 正则表达式和处理函数的映射关系
const regexMap = new Map([
Expand All @@ -29,6 +34,12 @@ const regexMap = new Map([
type: BillType.Income,
shopItem: match[2],
accountNameFrom: "零钱"
})],
[/退款金额¥(\d+\.\d{2})\n退款方式退回(.*?)\n退款原因(.*?)\n到账时间(.*?)/, (match) => ({
money: parseFloat(match[1]),
type: BillType.Income,
shopItem: `${match[3]}`,
accountNameFrom: match[2]
})]
]);

Expand Down Expand Up @@ -58,12 +69,16 @@ export function get(data) {
!TITLES_WECHAT.includes(
mapItem.title.replace(/\d+\.\d{2}/, "")
)
){
) {
return null;
}
// 解析文本
const parsedText = parseWeChatText(mapItem.description);
if (!parsedText || parsedText.type === null) return null;
if (!parsedText ||
parsedText.type === null
) {
return null;
}

// 创建并返回RuleObject对象
return new RuleObject(
Expand Down
15 changes: 15 additions & 0 deletions src/rule/app/com.tencent.mm/微信支付/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,18 @@ test("微信支付收款", () => testAnkio('微信支付收款',[
channel: '微信[微信支付]'
}
]))

test("微信支付转账过期退款", () => testAnkio('微信支付转账过期退款',[
{
type: 1,
money: 1000,
fee: 0,
shopName: '',
shopItem: "微信支付未在24小时内接收你的转账",
accountNameFrom: '中国银行(7575)',
accountNameTo: '',
currency: 'CNY',
time: 0,
channel: '微信[微信支付]'
}
]))
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"mMap": {
"description": "退款金额¥1000.00\n退款方式退回中国银行(7575)\n退款原因微信支付未在24小时内接收你的转账\n到账时间2024-04-14 13:02:31\n备注退款资金已到账",
"source": "微信支付",
"type": 5,
"appId": "",
"msgId": 99064,
"title": "转账过期退款到账通知",
"display_name": ""
}
}

0 comments on commit f427c99

Please sign in to comment.