Skip to content

Commit

Permalink
✨ (rule): 新增微信发红包规则并重命名相关文件 #626
Browse files Browse the repository at this point in the history
新增微信发红包规则文件 `微信发红包.txt`,并重命名 `微信红包收款` 相关文件为 `微信发红包`,同时更新规则逻辑以适配发红包场景。
  • Loading branch information
AnkioTomas committed Dec 28, 2024
1 parent ac1bfcf commit a050c85
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BillType, Currency, RuleObject, toDoubleFloat } from 'common/index.js';
import { BillType, Currency, RuleObject, toFloat } from 'common/index.js';

/**
* 获取规则对象
Expand All @@ -7,23 +7,23 @@ import { BillType, Currency, RuleObject, toDoubleFloat } from 'common/index.js';
*/
export function get(data) {
let json = JSON.parse(data);
if (json.retcode !== 0) {
if (json.type !== 'redPackage' || json.isSend !== 1) {
return null;
}
let amount = toDoubleFloat(json.amount);
let shopItem = json.wishing;
let amount = toFloat(json.cachedPayMoney);
let content = JSON.parse(json.content);
let shopItem = content.msg.appmsg.wcpayinfo.sendertitle;
let shopName = json.hookerUser;
let t = parseInt(json.record[0].receiveTime) * 1000;
return new RuleObject(
BillType.Income,
BillType.Expend,
amount,
shopName,
shopItem,
'零钱',
json.cachedPayTools,
'',
0.0,
Currency['人民币'],
t,
'微信[微信支付-红包收款]'
json.t,
'微信[微信支付-发红包]'
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ const { formatDate } = require('common/index.js');

testAnkioInit(get, __dirname, 'com.tencent.mm');

test('收红包', () =>
testAnkio('收红包', [
test('微信发红包', () =>
testAnkio('微信发红包', [
{
"type": "Income",
"money": 2,
'type': 'Expend',
'money': 15,
"fee": 0,
"shopName": '老爷',
'shopName': '大清宝泉',
"shopItem": '恭喜发财,大吉大利',
"accountNameFrom": '零钱',
"accountNameTo": '',
"currency": 'CNY',
"time": 1727426659000,
"channel": '微信[微信支付-红包收款]',
'time': 1734925199286,
'channel': '微信[微信支付-发红包]'
},
]));
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"type": "redPackage",
"content": "{\"msg\":{\"appmsg\":{\"des\":\"我给你发了一个红包,赶紧去拆!\",\"lowurl\":\"\",\"wcpayinfo\":{\"receivertitle\":\"恭喜发财,大吉大利\",\"paymsgid\":\"1000039801202412237225703898174\",\"sendertitle\":\"恭喜发财,大吉大利\",\"innertype\":\"0\",\"templateid\":\"7a2a165d31da7fce6dd77e05c300028a\",\"url\":\"https:\\/\\/wxapp.tenpay.com\\/mmpayhb\\/wxhb_personalreceive?showwxpaytitle=1&msgtype=1&channelid=1&sendid=1000039801202412237225703898174\",\"receiverdes\":\"领取红包\",\"senderdes\":\"查看红包\",\"iconurl\":\"https:\\/\\/wx.gtimg.com\\/hongbao\\/1800\\/hb.png\",\"sceneid\":\"1002\",\"invalidtime\":\"1735011599\",\"scenetext\":[{\"content\":\"微信红包\"},{\"content\":\"微信红包\"}],\"locallogoicon\":\"c2c_hongbao_icon_cn\",\"nativeurl\":\"wxpay:\\/\\/c2cbizmessagehandler\\/hongbao\\/receivehongbao?msgtype=1&channelid=1&sendid=1000039801202412237225703898174&sendusername=wxid_gn79r6oaxhry11&total_num=1\",\"broaden\":\"\"},\"appid\":\"\",\"sdkver\":\"\",\"type\":\"2001\",\"title\":\"微信红包\",\"thumburl\":\"https:\\/\\/wx.gtimg.com\\/hongbao\\/1800\\/hb.png\",\"url\":\"https:\\/\\/wxapp.tenpay.com\\/mmpayhb\\/wxhb_personalreceive?showwxpaytitle=1&msgtype=1&channelid=1&sendid=1000039801202412237225703898174\"},\"fromusername\":\"wxid_gn79r6oaxhry11\"}}",
"isSend": 1,
"hookerUser": "大清宝泉",
"cachedPayTools": "零钱",
"cachedPayMoney": "¥15.00",
"cachedPayShop": "微信红包",
"t": 1734925199286
}

0 comments on commit a050c85

Please sign in to comment.