From e06ec845db4755fecfc669e15dea14584e6f19b7 Mon Sep 17 00:00:00 2001 From: ankio Date: Mon, 30 Sep 2024 13:36:16 +0800 Subject: [PATCH] =?UTF-8?q?:sparkles:=20(rule):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=AE=9D=E8=BF=98=E6=AC=BE=E9=80=9A=E7=9F=A5?= =?UTF-8?q?=E8=A7=84=E5=88=99=20#334?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加支付宝还款通知规则,可以识别支付宝发出的还款成功通知,提取还款金额、付款方式、还款目标等信息,并将其解析成规范的账单数据。 该规则基于支付宝通知的结构,并使用测试用例进行验证,确保其准确性和可靠性。 --- .../main.js" | 27 +++++++++++++++++++ .../main.test.js" | 20 ++++++++++++++ ...0\346\254\276\351\200\232\347\237\245.txt" | 1 + src/rule/tests.txt | 2 +- src/utils/AliTools.js | 3 +++ 5 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 "src/rule/com.eg.android.AlipayGphone/app/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245/main.js" create mode 100644 "src/rule/com.eg.android.AlipayGphone/app/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245/main.test.js" create mode 100644 "src/rule/com.eg.android.AlipayGphone/app/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245/tests/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245.txt" diff --git "a/src/rule/com.eg.android.AlipayGphone/app/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245/main.js" "b/src/rule/com.eg.android.AlipayGphone/app/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245/main.js" new file mode 100644 index 0000000..5e85de0 --- /dev/null +++ "b/src/rule/com.eg.android.AlipayGphone/app/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245/main.js" @@ -0,0 +1,27 @@ +import { AliTools, BillType, RuleObject, toFloat } from 'common/index.js'; + +function transaction(content,t){ + + let obj = new RuleObject(BillType.Transfer); + + obj.money = toFloat(content.money); + + obj.time = t; + + AliTools.handleContentItems(content.content, obj); + + obj.channel = '支付宝[还款成功]'; + + return obj; +} + +export function get(data) { + let json = JSON.parse(data)[0]; + let pl = JSON.parse(json.pl); + let t = json.mct; + if (pl.title.indexOf('还款成功') === -1) { + return null; + } + let content = JSON.parse(pl.content); + return transaction(content,t); +} diff --git "a/src/rule/com.eg.android.AlipayGphone/app/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245/main.test.js" "b/src/rule/com.eg.android.AlipayGphone/app/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245/main.test.js" new file mode 100644 index 0000000..982bc9d --- /dev/null +++ "b/src/rule/com.eg.android.AlipayGphone/app/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245/main.test.js" @@ -0,0 +1,20 @@ +const { get } = require('./main'); +const { testAnkio, testAnkioInit } = require('../../../../tests/TestUtils'); + + +testAnkioInit(get, __dirname, 'com.eg.android.AlipayGphone'); +test('支付宝还款通知', () => + testAnkio('支付宝还款通知', [ + { + "type": "Transfer", + "money": 722.59, + "fee": 0, + "shopName": '', + "shopItem": '', + "accountNameFrom": '工商银行储蓄卡(1862)', + "accountNameTo": '借呗', + "currency": 'CNY', + "time": 1727222744000, + "channel": '支付宝[还款成功]', + }, + ])); diff --git "a/src/rule/com.eg.android.AlipayGphone/app/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245/tests/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245.txt" "b/src/rule/com.eg.android.AlipayGphone/app/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245/tests/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245.txt" new file mode 100644 index 0000000..d4f1f2b --- /dev/null +++ "b/src/rule/com.eg.android.AlipayGphone/app/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245/tests/\346\224\257\344\273\230\345\256\235\350\277\230\346\254\276\351\200\232\347\237\245.txt" @@ -0,0 +1 @@ +[{"mk":240965080544200004,"st":1,"isSc":0,"appId":"","mct":1727222744000,"pl":"{\"templateType\":\"BN\",\"commandType\":\"UPDATE\",\"withPushNfc\":\"Y\",\"expireLink\":\"\",\"msgType\":\"TODO\",\"icon\":\"https://gw.alipayobjects.com/mdn/rms_f96971/afts/img/A*leNcS41oUu0AAAAAAAAAAABkARQnAQ\",\"link\":\"alipays://platformapi/startapp?appId\u003d20000003\u0026actionType\u003dtoBillDetails\u0026tradeNO\u003d2024092510199318550201010000220064000950\u0026bizType\u003dPCL_JIEBEI?tagid\u003dMB_SEND_PH\",\"businessId\":\"PAY_HELPER_CARD_2088912794116224\",\"msgId\":\"4e2902b595a85dad56301b234fd96b6f00622\",\"templateCode\":\"00059_00094_zfzs001\",\"templateId\":\"WALLET-BILL@BLPaymentHelper\",\"title\":\"还款成功\",\"content\":\"{\\\"status\\\":\\\"还款成功\\\",\\\"date\\\":\\\"09月25日\\\",\\\"amountTip\\\":\\\"\\\",\\\"money\\\":\\\"722.59\\\",\\\"unit\\\":\\\"元\\\",\\\"infoTip\\\":\\\"\\\",\\\"failTip\\\":\\\"\\\",\\\"goto\\\":\\\"alipays://platformapi/startapp?appId\u003d20000003\u0026actionType\u003dtoBillDetails\u0026tradeNO\u003d2024092510199318550201010000220064000950\u0026bizType\u003dPCL_JIEBEI\\\",\\\"content\\\":[{\\\"title\\\":\\\"付款方式:\\\",\\\"content\\\":\\\"工商银行储蓄卡(1862)\\\"},{\\\"title\\\":\\\"还款到:\\\",\\\"content\\\":\\\"借呗\\\"}],\\\"ad\\\":[],\\\"actions\\\":[{\\\"name\\\":\\\"\\\",\\\"url\\\":\\\"\\\"},{\\\"name\\\":\\\"查看详情\\\",\\\"url\\\":\\\"alipays://platformapi/startapp?appId\u003d20000003\u0026actionType\u003dtoBillDetails\u0026tradeNO\u003d2024092510199318550201010000220064000950\u0026bizType\u003dPCL_JIEBEI\\\"}]}\",\"linkName\":\"\",\"bizName\":\"支付助手\",\"msgCategory\":\"bill\",\"scm\":\"27.gotone.card.4e2902b595a85dad56301b234fd96b6f00622.MB_SEND_PH.null.payment_assist.10090.10099.2019062521000502094325.9991746\",\"assistInfo\":\"{\\\"showInFriendTab\\\":false,\\\"icon\\\":\\\"https://gw.alipayobjects.com/mdn/rms_f96971/afts/img/A*ZapXT6AjvG0AAAAAAAAAAABkARQnAQ\\\",\\\"reminderType\\\":\\\"point\\\",\\\"hiddenMsgHeader\\\":false,\\\"title\\\":\\\"支付助手\\\",\\\"reminderTypeModifyEnable\\\":false,\\\"assistId\\\":\\\"payment_assist\\\",\\\"desc\\\":\\\"支付宝资金变动通知\\\"}\",\"ih\":\"{\\\"extInfo\\\":{},\\\"iid\\\":\\\"105\\\",\\\"ioty\\\":\\\"aor\\\",\\\"itemBasicInfo\\\":{\\\"dn\\\":\\\"服务提醒\\\",\\\"ic\\\":\\\"https://gw.alipayobjects.com/zos/bmw-prod/b96c31e0-64ba-4cbb-9a64-73ff17d701fd.webp\\\",\\\"lk\\\":\\\"alipays://platformapi/startapp?appId\u003d20000235\u0026source\u003dfriendTab\\\"},\\\"itemUserRelation\\\":{\\\"ilf\\\":\\\"N\\\",\\\"uc\\\":{\\\"top\\\":\\\"0\\\",\\\"notDisturb\\\":\\\"1\\\"},\\\"version\\\":0},\\\"ity\\\":\\\"105\\\",\\\"moty\\\":\\\"u\\\",\\\"msgInfo\\\":{\\\"bm\\\":\\\"还款成功¥722.59 \\\",\\\"cmid\\\":\\\"4e2902b595a85dad56301b234fd96b6f00622\\\",\\\"lmt\\\":1727222744026,\\\"msrid\\\":\\\"00059_00094_zfzs001\\\",\\\"ncs\\\":\\\"N\\\",\\\"rps\\\":\\\"num\\\",\\\"sam\\\":\\\"Y\\\",\\\"ssrid\\\":\\\"PAY_HELPER_CARD_2088912794116224\\\",\\\"urn\\\":1}}\",\"bizMonitor\":\"{\\\"serviceCode\\\":\\\"MB_SEND_PH\\\",\\\"bizName\\\":\\\"\\\",\\\"createTime\\\":1727222744132,\\\"businessId\\\":\\\"PAY_HELPER_CARD_2088912794116224\\\",\\\"messageId\\\":\\\"4e2902b595a85dad56301b234fd96b6f00622\\\",\\\"messageTitle\\\":\\\"还款成功\\\",\\\"templateId\\\":\\\"WALLET-BILL@BLPaymentHelper\\\",\\\"status\\\":\\\"\\\"}\",\"languageType\":\"zh-Hans\",\"subscribeConfig\":\"0\",\"gmtCreate\":1727222744026,\"gmtValid\":2038262744019,\"operate\":\"SEND\",\"templateName\":\"支付助手\",\"homePageTitle\":\"还款成功¥722.59 \",\"status\":\"\",\"extraInfo\":\"{\\\"topSubContent\\\":\\\"还款成功\\\",\\\"preValue\\\":\\\"¥\\\",\\\"languageType\\\":\\\"zh-Hans\\\",\\\"isPaymentMsg\\\":true,\\\"assistName2\\\":\\\"还款到\\\",\\\"assistName3\\\":\\\"\\\",\\\"assistName1\\\":\\\"付款方式\\\",\\\"templateId\\\":\\\"WALLET-FWC@remindNumber\\\",\\\"content\\\":\\\"722.59\\\",\\\"linkName\\\":\\\"\\\",\\\"assistMsg3\\\":\\\"\\\",\\\"sceneExt2\\\":{\\\"sceneUrl\\\":\\\"alipays://platformapi/startapp?appId\u003d20000003\u0026actionType\u003dtoBillDetails\u0026tradeNO\u003d2024092510199318550201010000220064000950\u0026bizType\u003dPCL_JIEBEI\\\",\\\"sceneType\\\":\\\"nativeApp\\\",\\\"sceneName\\\":\\\"借呗\\\",\\\"sceneIcon\\\":\\\"https://gw.alipayobjects.com/mdn/rms_2ed5a2/afts/img/A*bL1QRrzsqukAAAAAAAAAAAAAARQnAQ\\\"},\\\"assistMsg2\\\":\\\"借呗\\\",\\\"assistMsg1\\\":\\\"工商银行储蓄卡(1862)\\\",\\\"assistName4\\\":\\\"\\\",\\\"assistMsg5\\\":\\\"\\\",\\\"assistMsg4\\\":\\\"\\\",\\\"assistName5\\\":\\\"\\\",\\\"buttonLink\\\":\\\"\\\",\\\"cardAdInfo\\\":{\\\"p116\\\":{\\\"bizMonitor\\\":{\\\"marketingUniqueId\\\":\\\"MU37a97fbd8c444066bb7cb39b1a937ba0\\\",\\\"outBizId\\\":\\\"LIFE_MSG_TEXT|AMTT_drm|-\\\",\\\"marketingRuleId\\\":\\\"MR41b88eb9d64442b09a87a890d6848fc3\\\",\\\"style\\\":\\\"actionLine2\\\",\\\"marketingItemId\\\":\\\"MI501400035beb4580a6f92e161f06d081\\\"},\\\"expireTime\\\":1758758744104,\\\"marketingUniqueId\\\":\\\"MU37a97fbd8c444066bb7cb39b1a937ba0\\\",\\\"minClientVersion\\\":\\\"10.1.98\\\",\\\"recommendTemplateId\\\":\\\"actionLine2\\\",\\\"viewInfo\\\":{\\\"btnName\\\":\\\"支付奖励\\\",\\\"actionType\\\":\\\"link\\\",\\\"tagIcon\\\":\\\"https://mdn.alipayobjects.com/huamei_cke3ep/afts/img/A*s1xhTYe-_PQAAAAAAAAAAAAADk1-AQ/original\\\",\\\"tagColor\\\":\\\"#FF6011\\\",\\\"actionUrl\\\":\\\"alipays://platformapi/startapp?appId\u003d68687805\u0026url\u003dhttps%3A%2F%2Frender.alipay.com%2Fp%2Fyuyan%2F180020380000000023%2Fhome-page.html%3Fsource%3Ddzyyxiaoxi%26chInfo%3Ddzyyxiaoxi\\\",\\\"tag\\\":\\\"限时领1积分\\\"}}}}\"}"}] diff --git a/src/rule/tests.txt b/src/rule/tests.txt index 5af1097..d4f1f2b 100644 --- a/src/rule/tests.txt +++ b/src/rule/tests.txt @@ -1 +1 @@ -{"mMap":{"tableName":"AppMessage","description":"交易时间:2024年09月22日19:56\n交易类型:(尾号8057)银联快捷\n交易金额:(人民币)13.78元","source":"中国邮政储蓄银行","arg":"msgId","type":5,"appId":"","msgId":557329,"title":"交易提醒"}} +[{"mk":240965080544200004,"st":1,"isSc":0,"appId":"","mct":1727222744000,"pl":"{\"templateType\":\"BN\",\"commandType\":\"UPDATE\",\"withPushNfc\":\"Y\",\"expireLink\":\"\",\"msgType\":\"TODO\",\"icon\":\"https://gw.alipayobjects.com/mdn/rms_f96971/afts/img/A*leNcS41oUu0AAAAAAAAAAABkARQnAQ\",\"link\":\"alipays://platformapi/startapp?appId\u003d20000003\u0026actionType\u003dtoBillDetails\u0026tradeNO\u003d2024092510199318550201010000220064000950\u0026bizType\u003dPCL_JIEBEI?tagid\u003dMB_SEND_PH\",\"businessId\":\"PAY_HELPER_CARD_2088912794116224\",\"msgId\":\"4e2902b595a85dad56301b234fd96b6f00622\",\"templateCode\":\"00059_00094_zfzs001\",\"templateId\":\"WALLET-BILL@BLPaymentHelper\",\"title\":\"还款成功\",\"content\":\"{\\\"status\\\":\\\"还款成功\\\",\\\"date\\\":\\\"09月25日\\\",\\\"amountTip\\\":\\\"\\\",\\\"money\\\":\\\"722.59\\\",\\\"unit\\\":\\\"元\\\",\\\"infoTip\\\":\\\"\\\",\\\"failTip\\\":\\\"\\\",\\\"goto\\\":\\\"alipays://platformapi/startapp?appId\u003d20000003\u0026actionType\u003dtoBillDetails\u0026tradeNO\u003d2024092510199318550201010000220064000950\u0026bizType\u003dPCL_JIEBEI\\\",\\\"content\\\":[{\\\"title\\\":\\\"付款方式:\\\",\\\"content\\\":\\\"工商银行储蓄卡(1862)\\\"},{\\\"title\\\":\\\"还款到:\\\",\\\"content\\\":\\\"借呗\\\"}],\\\"ad\\\":[],\\\"actions\\\":[{\\\"name\\\":\\\"\\\",\\\"url\\\":\\\"\\\"},{\\\"name\\\":\\\"查看详情\\\",\\\"url\\\":\\\"alipays://platformapi/startapp?appId\u003d20000003\u0026actionType\u003dtoBillDetails\u0026tradeNO\u003d2024092510199318550201010000220064000950\u0026bizType\u003dPCL_JIEBEI\\\"}]}\",\"linkName\":\"\",\"bizName\":\"支付助手\",\"msgCategory\":\"bill\",\"scm\":\"27.gotone.card.4e2902b595a85dad56301b234fd96b6f00622.MB_SEND_PH.null.payment_assist.10090.10099.2019062521000502094325.9991746\",\"assistInfo\":\"{\\\"showInFriendTab\\\":false,\\\"icon\\\":\\\"https://gw.alipayobjects.com/mdn/rms_f96971/afts/img/A*ZapXT6AjvG0AAAAAAAAAAABkARQnAQ\\\",\\\"reminderType\\\":\\\"point\\\",\\\"hiddenMsgHeader\\\":false,\\\"title\\\":\\\"支付助手\\\",\\\"reminderTypeModifyEnable\\\":false,\\\"assistId\\\":\\\"payment_assist\\\",\\\"desc\\\":\\\"支付宝资金变动通知\\\"}\",\"ih\":\"{\\\"extInfo\\\":{},\\\"iid\\\":\\\"105\\\",\\\"ioty\\\":\\\"aor\\\",\\\"itemBasicInfo\\\":{\\\"dn\\\":\\\"服务提醒\\\",\\\"ic\\\":\\\"https://gw.alipayobjects.com/zos/bmw-prod/b96c31e0-64ba-4cbb-9a64-73ff17d701fd.webp\\\",\\\"lk\\\":\\\"alipays://platformapi/startapp?appId\u003d20000235\u0026source\u003dfriendTab\\\"},\\\"itemUserRelation\\\":{\\\"ilf\\\":\\\"N\\\",\\\"uc\\\":{\\\"top\\\":\\\"0\\\",\\\"notDisturb\\\":\\\"1\\\"},\\\"version\\\":0},\\\"ity\\\":\\\"105\\\",\\\"moty\\\":\\\"u\\\",\\\"msgInfo\\\":{\\\"bm\\\":\\\"还款成功¥722.59 \\\",\\\"cmid\\\":\\\"4e2902b595a85dad56301b234fd96b6f00622\\\",\\\"lmt\\\":1727222744026,\\\"msrid\\\":\\\"00059_00094_zfzs001\\\",\\\"ncs\\\":\\\"N\\\",\\\"rps\\\":\\\"num\\\",\\\"sam\\\":\\\"Y\\\",\\\"ssrid\\\":\\\"PAY_HELPER_CARD_2088912794116224\\\",\\\"urn\\\":1}}\",\"bizMonitor\":\"{\\\"serviceCode\\\":\\\"MB_SEND_PH\\\",\\\"bizName\\\":\\\"\\\",\\\"createTime\\\":1727222744132,\\\"businessId\\\":\\\"PAY_HELPER_CARD_2088912794116224\\\",\\\"messageId\\\":\\\"4e2902b595a85dad56301b234fd96b6f00622\\\",\\\"messageTitle\\\":\\\"还款成功\\\",\\\"templateId\\\":\\\"WALLET-BILL@BLPaymentHelper\\\",\\\"status\\\":\\\"\\\"}\",\"languageType\":\"zh-Hans\",\"subscribeConfig\":\"0\",\"gmtCreate\":1727222744026,\"gmtValid\":2038262744019,\"operate\":\"SEND\",\"templateName\":\"支付助手\",\"homePageTitle\":\"还款成功¥722.59 \",\"status\":\"\",\"extraInfo\":\"{\\\"topSubContent\\\":\\\"还款成功\\\",\\\"preValue\\\":\\\"¥\\\",\\\"languageType\\\":\\\"zh-Hans\\\",\\\"isPaymentMsg\\\":true,\\\"assistName2\\\":\\\"还款到\\\",\\\"assistName3\\\":\\\"\\\",\\\"assistName1\\\":\\\"付款方式\\\",\\\"templateId\\\":\\\"WALLET-FWC@remindNumber\\\",\\\"content\\\":\\\"722.59\\\",\\\"linkName\\\":\\\"\\\",\\\"assistMsg3\\\":\\\"\\\",\\\"sceneExt2\\\":{\\\"sceneUrl\\\":\\\"alipays://platformapi/startapp?appId\u003d20000003\u0026actionType\u003dtoBillDetails\u0026tradeNO\u003d2024092510199318550201010000220064000950\u0026bizType\u003dPCL_JIEBEI\\\",\\\"sceneType\\\":\\\"nativeApp\\\",\\\"sceneName\\\":\\\"借呗\\\",\\\"sceneIcon\\\":\\\"https://gw.alipayobjects.com/mdn/rms_2ed5a2/afts/img/A*bL1QRrzsqukAAAAAAAAAAAAAARQnAQ\\\"},\\\"assistMsg2\\\":\\\"借呗\\\",\\\"assistMsg1\\\":\\\"工商银行储蓄卡(1862)\\\",\\\"assistName4\\\":\\\"\\\",\\\"assistMsg5\\\":\\\"\\\",\\\"assistMsg4\\\":\\\"\\\",\\\"assistName5\\\":\\\"\\\",\\\"buttonLink\\\":\\\"\\\",\\\"cardAdInfo\\\":{\\\"p116\\\":{\\\"bizMonitor\\\":{\\\"marketingUniqueId\\\":\\\"MU37a97fbd8c444066bb7cb39b1a937ba0\\\",\\\"outBizId\\\":\\\"LIFE_MSG_TEXT|AMTT_drm|-\\\",\\\"marketingRuleId\\\":\\\"MR41b88eb9d64442b09a87a890d6848fc3\\\",\\\"style\\\":\\\"actionLine2\\\",\\\"marketingItemId\\\":\\\"MI501400035beb4580a6f92e161f06d081\\\"},\\\"expireTime\\\":1758758744104,\\\"marketingUniqueId\\\":\\\"MU37a97fbd8c444066bb7cb39b1a937ba0\\\",\\\"minClientVersion\\\":\\\"10.1.98\\\",\\\"recommendTemplateId\\\":\\\"actionLine2\\\",\\\"viewInfo\\\":{\\\"btnName\\\":\\\"支付奖励\\\",\\\"actionType\\\":\\\"link\\\",\\\"tagIcon\\\":\\\"https://mdn.alipayobjects.com/huamei_cke3ep/afts/img/A*s1xhTYe-_PQAAAAAAAAAAAAADk1-AQ/original\\\",\\\"tagColor\\\":\\\"#FF6011\\\",\\\"actionUrl\\\":\\\"alipays://platformapi/startapp?appId\u003d68687805\u0026url\u003dhttps%3A%2F%2Frender.alipay.com%2Fp%2Fyuyan%2F180020380000000023%2Fhome-page.html%3Fsource%3Ddzyyxiaoxi%26chInfo%3Ddzyyxiaoxi\\\",\\\"tag\\\":\\\"限时领1积分\\\"}}}}\"}"}] diff --git a/src/utils/AliTools.js b/src/utils/AliTools.js index 4ea20f0..5c02a31 100644 --- a/src/utils/AliTools.js +++ b/src/utils/AliTools.js @@ -33,6 +33,9 @@ export const AliTools = { case '转账备注:': result.shopItem = item.content; break; + case '还款到:': + result.accountNameTo = item.content; + break; } }); },