Skip to content

Commit

Permalink
Merge pull request #87 from taigongzhaihua/master
Browse files Browse the repository at this point in the history
✨ 新增适配微信支付收款(分销佣金) #86
  • Loading branch information
taigongzhaihua authored Apr 16, 2024
2 parents 713c424 + a4dc542 commit 04d28f0
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 25 deletions.
35 changes: 23 additions & 12 deletions src/rule/app/com.tencent.mm/微信支付/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ const TITLES_WECHAT = [
"已支付¥",
"已扣费¥",
"微信支付收款元",
"转账过期退款到账通知"
"转账过期退款到账通知",
"你收到一笔分销佣金"
];
var mapItem;

Expand All @@ -17,39 +18,49 @@ const regexMap = new Map([
[/付款金额¥(\d+\.\d{2})\n支付方式(.*?)\n交易状态.*/, (match) => ({
money: parseFloat(match[1]),
accountNameFrom: match[2],
type: BillType.Expend
type: BillType.Expend,
channel: "微信[微信支付-付款]"
})],
[/付款金额¥(\d+\.\d{2})\n付款方式(.*?)\n收单机构.*/, (match) => ({
money: parseFloat(match[1]),
accountNameFrom: match[2],
type: BillType.Expend
type: BillType.Expend,
channel: "微信[微信支付-付款]"
})],
[/扣费金额¥(\d+\.\d{2})\n(扣费服务(.*?)\n)?扣费(内容|项目)(.*?)\n支付方式(.*?)\n收单机构.*/, (match) => {
const [, money, , shopName, , shopItem, accountNameFrom] = match;
return {
money: parseFloat(money),
accountNameFrom,
shopName: !mapItem.display_name ? shopName : mapItem.display_name,
shopItem:
(
!(mapItem.display_name && mapItem.display_name == shopName) ||
!shopName
) ? shopItem :
`${shopName}(${shopItem})`,
type: BillType.Expend
shopItem: (!(mapItem.display_name && mapItem.display_name == shopName) || !shopName)
? shopItem
: `${shopName}(${shopItem})`,
type: BillType.Expend,
channel: "微信[微信支付-扣费]"
}
}],
[/收款金额¥(\d+\.\d{2})\n汇总(.*?)\n备注.*/, (match) => ({
money: parseFloat(match[1]),
type: BillType.Income,
shopItem: match[2],
accountNameFrom: "零钱"
accountNameFrom: "零钱",
channel: "微信[微信支付-收款]"
})],
[/收款金额¥(\d+\.\d{2})\n收款账户(.*?)\n付款商家(.*)/, (match) => ({
money: parseFloat(match[1]),
type: BillType.Income,
accountNameFrom: match[2],
shopName: match[3],
shopItem: mapItem.title,
channel: "微信[微信支付-收款]"
})],
[/退款金额¥(\d+\.\d{2})\n退款方式退回(.*?)\n退款原因(.*?)\n(到账|退款)时间(.*?)\n.*/, (match) => {
const [, money, accountNameFrom, shopItem, , time] = match;
return {
money: parseFloat(money),
type: BillType.Income,
channel: "微信[微信支付-退款]",
time, shopItem, accountNameFrom
}
}]
Expand Down Expand Up @@ -103,6 +114,6 @@ export function get(data) {
0,
Currency['人民币'],
parsedText.time,
`微信[${mapItem.source}]`
parsedText.channel
);
}
39 changes: 26 additions & 13 deletions src/rule/app/com.tencent.mm/微信支付/main.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
const { get } = require('./main');
const fs = require('fs');
const path = require('path');
const {testAnkioInit, testAnkio} = require("../../../../tests/TestUtils");
const {DataType} = require("../../../../utils/DataType");

Expand All @@ -16,7 +14,7 @@ test("微信支付消费(商家收款)", () => testAnkio('微信支付消费
accountNameTo: '',
currency: 'CNY',
time: 0,
channel: '微信[微信支付]'
channel: '微信[微信支付-付款]'
}
]))

Expand All @@ -31,7 +29,7 @@ test("微信支付消费(第三方收款)", () => testAnkio('微信支付消
accountNameTo: '',
currency: 'CNY',
time: 0,
channel: '微信[微信支付]'
channel: '微信[微信支付-付款]'
},
{
type: 0,
Expand All @@ -43,7 +41,7 @@ test("微信支付消费(第三方收款)", () => testAnkio('微信支付消
accountNameTo: '',
currency: 'CNY',
time: 0,
channel: '微信[微信支付]'
channel: '微信[微信支付-付款]'
},
{
type: 0,
Expand All @@ -55,7 +53,7 @@ test("微信支付消费(第三方收款)", () => testAnkio('微信支付消
accountNameTo: '',
currency: 'CNY',
time: 0,
channel: '微信[微信支付]'
channel: '微信[微信支付-付款]'
},
{
type: 0,
Expand All @@ -67,7 +65,7 @@ test("微信支付消费(第三方收款)", () => testAnkio('微信支付消
accountNameTo: '',
currency: 'CNY',
time: 0,
channel: '微信[微信支付]'
channel: '微信[微信支付-付款]'
}
]))

Expand All @@ -82,7 +80,7 @@ test("微信支付自动扣费", () => testAnkio('微信支付自动扣费',[
accountNameTo: '',
currency: 'CNY',
time: 0,
channel: '微信[微信支付]'
channel: '微信[微信支付-扣费]'
},
{
type: 0,
Expand All @@ -94,7 +92,7 @@ test("微信支付自动扣费", () => testAnkio('微信支付自动扣费',[
accountNameTo: '',
currency: 'CNY',
time: 0,
channel: '微信[微信支付]'
channel: '微信[微信支付-扣费]'
},
{
type: 0,
Expand All @@ -106,7 +104,7 @@ test("微信支付自动扣费", () => testAnkio('微信支付自动扣费',[
accountNameTo: '',
currency: 'CNY',
time: 0,
channel: '微信[微信支付]'
channel: '微信[微信支付-扣费]'
}
]))

Expand All @@ -121,7 +119,7 @@ test("微信支付收款", () => testAnkio('微信支付收款',[
accountNameTo: '',
currency: 'CNY',
time: 0,
channel: '微信[微信支付]'
channel: '微信[微信支付-收款]'
}
]))

Expand All @@ -136,7 +134,7 @@ test("微信支付转账过期退款", () => testAnkio('微信支付转账过期
accountNameTo: '',
currency: 'CNY',
time: "2024-04-14 13:02:31",
channel: '微信[微信支付]'
channel: '微信[微信支付-退款]'
},
{
type: 1,
Expand All @@ -148,6 +146,21 @@ test("微信支付转账过期退款", () => testAnkio('微信支付转账过期
accountNameTo: '',
currency: 'CNY',
time: "2024-04-15 08:59:11",
channel: '微信[微信支付]'
channel: '微信[微信支付-退款]'
}
]))

test("微信支付收款(分销佣金)", () => testAnkio('微信支付收款(分销佣金)',[
{
type: 1,
money: 0.10,
fee: 0,
shopName: '宿迁兆盈商服科技有限公司',
shopItem: '你收到一笔分销佣金',
accountNameFrom: '零钱',
accountNameTo: '',
currency: 'CNY',
time: 0,
channel: '微信[微信支付-收款]'
}
]))
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"mMap": {
"tableName": "AppMessage",
"description": "收款金额¥0.10\n收款账户零钱\n付款商家宿迁兆盈商服科技有限公司",
"source": "微信支付",
"arg": "msgId",
"type": 5,
"appId": "",
"msgId": 292981,
"title": "你收到一笔分销佣金"
}
}

0 comments on commit 04d28f0

Please sign in to comment.