Skip to content

Commit

Permalink
✨ (微信支付): 更新微信支付规则和测试用例
Browse files Browse the repository at this point in the history
- 新增支付凭证标题 "微信支付凭证"
- 扩展正则表达式以匹配更多支付场景
- 添加新的测试用例以覆盖不同支付方式
- 重命名并移动测试文件至微信支付在线支付目录
- 更新测试数据以反映实际支付场景
  • Loading branch information
AnkioTomas committed Dec 28, 2024
1 parent 0030b62 commit 2a51890
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 174 deletions.
44 changes: 41 additions & 3 deletions src/rule/com.tencent.mm/app/微信支付在线支付/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import { BillType, Currency, parseWechat, RuleObject, toFloat } from 'common/ind
const SOURCE_NAME_WECHAT = '微信支付';
const TITLE_WECHAT = [
'已支付¥',
'¥ paid'
'¥ paid',
'微信支付凭证'
];

// 正则表达式和处理函数的映射关系
const rules =[
[
/付款金额[¥¥](\d+\.\d{2})\n付款方式(.*?)\n收单机构.*/,
/(付款|支付)金额[¥¥](\d+\.\d{2})\n(付款|支付)方式(.*?)\n收单机构.*/,
(match,t,item) => {
let [, money, accountNameFrom] = match;
let [, , money, , accountNameFrom] = match;
return new RuleObject(
BillType.Expend,
toFloat(money),
Expand All @@ -27,6 +28,24 @@ const rules =[
);
},
],
[ // 付款金额¥10.00\n支付方式徽商银行储蓄卡\n交易状态支付成功,对方已收款
/付款金额[¥¥](\d+\.\d{2})\n支付方式(.*?)\n交易状态支付成功,对方已收款/,
(match, t, item) => {
let [, money, accountNameFrom] = match;
return new RuleObject(
BillType.Expend,
toFloat(money),
item.display_name,
'',
accountNameFrom,
'',
0.0,
Currency['人民币'],
t,
'微信[微信支付-在线支付]'
);
}
],
[
// 收款方产地鲜友公司李锆\n使用农业银行储蓄卡支付¥65.17\n付款留言梁峻翊\n交易状态支付成功,对方已收款
/收款方(.*?)\n使用(.*?)支付[¥¥](\d+\.\d{2})\n付款留言(.*?)\n交易状态支付成功,对方已收款/,
Expand All @@ -46,7 +65,26 @@ const rules =[
);
}
],
[
// 付款金额¥5.00\n收款方发财\n交易状态支付成功,对方已收款
/付款金额¥(\d+\.\d{2})\n收款方(.*?)\n交易状态(.*?)$/,
(match, t, item) => {
const [, money, shopName, shopItem] = match;

return new RuleObject(
BillType.Expend,
toFloat(money),
shopName,
shopItem,
item.cachedPayTools,
'',
0.0,
Currency['人民币'],
t,
'微信[微信支付-在线支付]'
);
},
],
[
//使用零钱支付¥17.30\n车牌宁A·T4386\n交易状态支付成功,对方已收款
/使用(.*?)支付¥(\d+\.\d{2})\n车牌(.*?)\n交易(状态|狀態)支付成功,([对對])方已收款/,
Expand Down
55 changes: 55 additions & 0 deletions src/rule/com.tencent.mm/app/微信支付在线支付/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,60 @@ test('微信支付在线支付', () =>
'currency': 'CNY',
'time': 1735185126829,
'channel': '微信[微信支付-在线支付]'
}, {
'type': 'Expend',
'money': 10,
'fee': 0,
'shopName': '开心快乐每一天',
'shopItem': '',
'accountNameFrom': '徽商银行储蓄卡',
'accountNameTo': '',
'currency': 'CNY',
'time': 0,
'channel': '微信[微信支付-在线支付]'
}, {
'type': 'Expend',
'money': 70,
'fee': 0,
'shopName': '酱骨头焖面',
'shopItem': '',
'accountNameFrom': '零钱',
'accountNameTo': '',
'currency': 'CNY',
'time': 0,
'channel': '微信[微信支付-在线支付]'
}, {
'type': 'Expend',
'money': 9,
'fee': 0,
'shopName': '川香源',
'shopItem': '',
'accountNameFrom': '零钱通',
'accountNameTo': '',
'currency': 'CNY',
'time': 0,
'channel': '微信[微信支付-在线支付]'
}, {
'type': 'Expend',
'money': 5,
'fee': 0,
'shopName': '发财',
'shopItem': '支付成功,对方已收款',
'accountNameFrom': '零钱',
'accountNameTo': '',
'currency': 'CNY',
'time': 1727788529055,
'channel': '微信[微信支付-在线支付]'
}, {
'type': 'Expend',
'money': 29,
'fee': 0,
'shopName': '十六楼工作室',
'shopItem': '',
'accountNameFrom': '零钱',
'accountNameTo': '',
'currency': 'CNY',
'time': 1734092827912,
'channel': '微信[微信支付-在线支付]'
}
]));
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"cachedPayMoney": "¥70.00",
"cachedPayShop": "付款给酱骨头焖面(**强)"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"cachedPayMoney": "¥9.00",
"cachedPayShop": "付款给川香源(**挥)"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"cachedPayMoney": "¥10.00",
"cachedPayShop": "付款给开心快乐每一天(**财)"
}
}
}
100 changes: 0 additions & 100 deletions src/rule/com.tencent.mm/app/微信支付扫码支付/main.js

This file was deleted.

68 changes: 0 additions & 68 deletions src/rule/com.tencent.mm/app/微信支付扫码支付/main.test.js

This file was deleted.

0 comments on commit 2a51890

Please sign in to comment.