Skip to content

Commit

Permalink
✨ 适配微信转账收款 #105
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkioTomas committed Apr 29, 2024
1 parent 3141477 commit e4dc32c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/rule/app/com.tencent.mm/微信转账/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { RuleObject } from '../../../../utils/RuleObject';
import { BillType } from '../../../../utils/BillType';
import { Currency } from '../../../../utils/Currency';
import { formatDate } from '../../../../utils/Time';
import { DataType } from '../../../../utils/DataType';

/**
* @param {string} data - 包含数据的JSON字符串。
* @returns {RuleObject|null} - 解析后的RuleObject对象,如果解析失败则返回null。
*/
export function get(data) {
// 解析数据
data = JSON.parse(data);

// 创建并返回RuleObject对象
return new RuleObject(
BillType.Income,
data.fee,
data.hookUser,
data.status_desc,
'零钱',
'',
0,
Currency['人民币'],
formatDate(data.desc_item_list[1].value, 'Y年M月D日 h:i:s'),
'微信[转账收款]',
);
}
21 changes: 21 additions & 0 deletions src/rule/app/com.tencent.mm/微信转账/main.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { get } = require('./main');
const { testAnkioInit, testAnkio } = require('../../../../tests/TestUtils');
const { DataType } = require('../../../../utils/DataType');
const { formatDate } = require('../../../../utils/Time');

testAnkioInit(get, __dirname, DataType.App, 'com.tencent.mm');
test('微信转账收款', () =>
testAnkio('微信转账收款', [
{
type: 1,
money: 1700,
fee: 0,
shopName: '师大123',
shopItem: '你已收款,资金已存入零钱',
accountNameFrom: '零钱',
accountNameTo: '',
currency: 'CNY',
time: formatDate('2024年04月23日 11:50:05', 'Y年M月D日 h:i:s'),
channel: '微信[转账收款]',
},
]));
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"trans_status": 2001,
"retcode": "0",
"retmsg": "ok",
"fee": 1700,
"fee_type": "1",
"refund_bank_type": "BANK",
"payer_name": "huanqi5383",
"receiver_name": "wxid_9uggr4pqbcut22",
"status_desc": "你已收款,资金已存入零钱",
"status_supplementary": "\u003c_wc_custom_link_ href\u003d\"weixin://wcpay/transfer/watchbalance\"\u003e零钱余额\u003c/_wc_custom_link_\u003e",
"delay_confirm_flag": 0,
"is_payer": false,
"exposure_info": {
"icon": "https://act.weixin.qq.com/static/images/201811/fa7720735f3f4db765f354c4daf5e620.png",
"name": "零钱通 七日年化1.73%",
"wording": "给小金库再添一笔",
"is_show_btn": 1,
"btn_wording": "转入",
"jump_info": {
"type": 3,
"url": "weixin://wcpay/lqt/save?operate_id\u003d00005453141700017138442058873690\u0026trace_info\u003dCPqqg4QCEAIaNgoMYXBwX3RyYW5zZmVyEiAxZDU0MjhlOTcyZGI5ZWNlNTg2ZjlmMTkzOGIyYzM2Mxjt35yxBiI2CgxhcHBfdHJhbnNmZXISIDFkNTQyOGU5NzJkYjllY2U1ODZmOWYxOTM4YjJjMzYzGO3fnLEG",
"username": "",
"pagepath": ""
}
},
"text_info": {},
"desc_item_list": [
{
"key": "转账时间",
"value": "2024年04月23日 11:48:26",
"item_type": 3
},
{
"key": "收款时间",
"value": "2024年04月23日 11:50:05",
"item_type": 4
}
],
"upright_corner_list": [],
"customer_info_list": [],
"hookUser": "师大123"
}

0 comments on commit e4dc32c

Please sign in to comment.