Skip to content

Commit

Permalink
Merge pull request #78 from taigongzhaihua/master
Browse files Browse the repository at this point in the history
✨新增测试用例 #50 #56
🎨优化代码,适配更多数据
  • Loading branch information
taigongzhaihua authored Apr 14, 2024
2 parents 1ccb655 + d78a819 commit 4a0fab4
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/rule/app/com.tencent.mm/微信公众号美团/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const SOURCE_NAME = "美团";
const TITLES = ["支付成功通知"];

// 定义用于解析文本的正则表达式
const regex = /消费账户:(.*?)\n支付金额:(.*?)元\n支付方式:(.*?)\n支付时间:(.+)/;
const regex = /消费账户:(.*?)\n支付金额:(人民币)?(.*?)元\n支付方式:(.*?)\n支付时间:(.+)/;

/**
* 解析文本并返回解析结果。
Expand All @@ -19,23 +19,17 @@ function parseText(text) {
if (!match) return null;

// 解析数据
let type = BillType.Expend;
let time = match[4].trim();
let shopName = SOURCE_NAME;
let shopItem = match[1];
let money = parseFloat(match[2]);
let accountNameFrom = match[3];
let channel = "微信[美团消费]";
const [, shopItem,, money, accountNameFrom, time] = match;

// 返回解析结果
return {
type,
time,
shopName,
shopItem,
money,
accountNameFrom,
channel
type: BillType.Expend,
time: time.trim(),
shopName:SOURCE_NAME,
shopItem:shopItem,
money:parseFloat(money),
accountNameFrom:accountNameFrom,
channel:"微信[美团消费]"
};
}

Expand Down
24 changes: 24 additions & 0 deletions src/rule/app/com.tencent.mm/微信公众号美团/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,29 @@ test("美团消费", () => testAnkio('美团消费',[
currency: 'CNY',
time: "2024年04月11日 18:05",
channel: '微信[美团消费]'
},
{
type: 0,
money: 19.68,
fee: 0,
shopName: '美团',
shopItem: "185****6210",
accountNameFrom: '招商银行信用卡(1356)',
accountNameTo: '',
currency: 'CNY',
time: "2024年04月12日 10:53",
channel: '微信[美团消费]'
},
{
type: 0,
money: 29,
fee: 0,
shopName: '美团',
shopItem: "133****6923",
accountNameFrom: "美团月付",
accountNameTo: '',
currency: 'CNY',
time: "2024-04-12 15:29:46",
channel: '微信[美团消费]'
}
]))
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"mMap": {
"tableName": "AppMessage",
"description": "消费账户:185****6210\n支付金额:19.68元\n支付方式:招商银行信用卡(1356)\n支付时间:2024年04月12日 10:53 ",
"source": "美团",
"arg": "msgId",
"type": 5,
"appId": "",
"msgId": 98506,
"title": "支付成功通知"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"mMap": {
"tableName": "AppMessage",
"description": "消费账户:133****6923\n支付金额:人民币29.00元\n支付方式:美团月付\n支付时间:2024-04-12 15:29:46",
"source": "美团",
"arg": "msgId",
"type": 5,
"appId": "",
"msgId": 10032407,
"title": "支付成功通知"
}
}

0 comments on commit 4a0fab4

Please sign in to comment.