-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea23cff
commit 5be0e91
Showing
6 changed files
with
258 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 86 additions & 24 deletions
110
src/rule/app/com.eg.android.AlipayGphone/支付宝账单列表/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,92 @@ | ||
import {BillType} from "../../../utils/BillType"; | ||
import {RuleObject} from "../../../utils/RuleObject"; | ||
import {Currency} from "../../../utils/Currency"; | ||
import {stripHtml} from "../../../utils/Html"; | ||
|
||
import {BillType} from "../../../../utils/BillType"; | ||
import {RuleObject} from "../../../../utils/RuleObject"; | ||
import {Currency} from "../../../../utils/Currency"; | ||
|
||
export function get(data) { | ||
data = JSON.parse(data) | ||
let pl = JSON.parse(data[0].pl) | ||
var dataItems = JSON.parse(pl.templateJson) | ||
data = JSON.parse(data); | ||
var extension = data.extension; | ||
var fields = data.fields; | ||
|
||
var result = { | ||
type: 0, | ||
money: 0, | ||
shopName: "", | ||
shopItem: "", | ||
accountNameFrom: "", | ||
accountNameTo: "", | ||
fee:0, | ||
currency:Currency["人民币"], | ||
time: Number(extension.gmtBizCreateTime), | ||
channel:"" | ||
}; | ||
|
||
for (var i = 0; i < fields.length; i++) { | ||
var element = fields[i]; | ||
if (!element.value) { | ||
continue; // 跳过这个元素,继续处理下一个 | ||
} | ||
var elementValue = JSON.parse(element.value); | ||
|
||
if (element.templateId === "BLDetailTitle") { | ||
result.shopName = elementValue.content; | ||
} else if (element.templateId === "BLDetailPrice") { | ||
result.money = parseFloat(elementValue.amount.replace(/[+-]/, "")); | ||
var type = elementValue.amount.replace(/\d+\.\d{0,2}/, ""); | ||
switch (type) { | ||
case "+": | ||
result.type = BillType.Income; | ||
break; | ||
case "-": | ||
result.type = BillType.Expend; | ||
break; | ||
default: | ||
result.type = BillType.Transfer; | ||
} | ||
} else if (element.templateId === "BLDetailCommon"||element.templateId === "BLH5ProductInfo") { | ||
if (/商品说明|转账备注/.test(elementValue.title)) { | ||
result.shopItem = elementValue.data[0].content; | ||
} | ||
} | ||
} | ||
|
||
switch (extension.bizType) { | ||
case "CHARGE": | ||
result.accountNameFrom="余额" | ||
result.channel = "支付宝收钱码经营版信用卡收钱服务费"; | ||
break; | ||
case "TRADE": | ||
result.accountNameFrom="余额" | ||
result.channel = "支付宝收款码收款"; | ||
break; | ||
case "D_TRANSFER": | ||
result.accountNameFrom="余额" | ||
result.channel = "支付宝转账收款"; | ||
break; | ||
case "YEB": | ||
result.accountNameFrom="余额" | ||
result.accountNameTo = "余额宝"; | ||
result.channel = "支付宝余额转到余额宝"; | ||
break; | ||
case "MINITRANS": | ||
result.type = BillType.Income; | ||
result.accountNameFrom = "余额宝"; | ||
result.channel = "支付宝余额宝收益发放"; | ||
break; | ||
default: | ||
return null; | ||
} | ||
|
||
return new RuleObject( | ||
BillType.Income, | ||
parseFloat(dataItems.statusLine1Text.replace("元","")), | ||
stripHtml(dataItems.subtitle), | ||
dataItems.title, | ||
"支付宝余额", | ||
"", | ||
0, | ||
Currency['人民币'], | ||
data[0].mct, | ||
"支付宝账单列表") | ||
} | ||
export function app(){ | ||
return "com.eg.android.AlipayGphone" | ||
} | ||
result.type, | ||
result.money, | ||
result.shopName, | ||
result.shopItem, | ||
result.accountNameFrom, | ||
result.accountNameTo, | ||
result.fee, | ||
result.currency, | ||
result.time, | ||
result.channel); | ||
|
||
export function name(){ | ||
return "支付宝账单列表" | ||
} | ||
|
135 changes: 123 additions & 12 deletions
135
src/rule/app/com.eg.android.AlipayGphone/支付宝账单列表/main.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,135 @@ | ||
const { get } = require('./main'); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
|
||
|
||
test("支付宝红包", () => { | ||
const data = ` | ||
[{"mk":231259160230200016,"st":1,"isSc":0,"appId":"","mct":1702972951000,"pl":"{\\"amount\\":1,\\"bizType\\":\\"CROWD_COMMON_CASH\\",\\"count\\":1,\\"couponId\\":\\"202312190206302237474865670087913825\\",\\"flashShow\\":false,\\"gmtClientShow\\":1702972950000,\\"gmtModified\\":1702972950000,\\"iconUrl\\":\\"http:\\/\\/tfs.alipayobjects.com\\/images\\/partner\\/TB1C2W7c.iHDuNkUQcjXXXh_pXa_160X160\\",\\"id\\":\\"2088032022319723_202312190206302237474865670087913825_CROWD_COMMON_CASH_receive\\",\\"linkUrl\\":\\"alipays:\\/\\/platformapi\\/startapp?appId=2021001168603174&startMultApp=YES&appClearTop=false&page=pages%2Fred-packet-result%2Findex%3FcrowdNo%3D202312190206302237474865670087913825%26pageType%3DOTHER_DETAIL&bizType=CROWD_COMMON_CASH&crowdNo=202312190206302237474865670087913825\\",\\"redDot\\":false,\\"resourceType\\":\\"receive\\",\\"sortLevel\\":0,\\"state\\":\\"receiver_received\\",\\"templateCode\\":\\"001\\",\\"templateJson\\":\\"{\\\\\\"statusLine2Color\\\\\\":\\\\\\"#A5A5A5\\\\\\",\\\\\\"subtitle\\\\\\":\\\\\\"来自<font color=\\\\\\\\\\\\\\"#333333\\\\\\\\\\\\\\">从前慢<\\/font>\\\\\\",\\\\\\"statusLine1Color\\\\\\":\\\\\\"#333333\\\\\\",\\\\\\"statusLine2Text\\\\\\":\\\\\\"已领取\\\\\\",\\\\\\"title\\\\\\":\\\\\\"普通红包\\\\\\",\\\\\\"statusLine1Text\\\\\\":\\\\\\"0.01元\\\\\\"}\\",\\"userId\\":\\"2088032022319723\\",\\"visible\\":true}"}] | ||
` | ||
|
||
test("支付宝收款码收款", () => { | ||
const dataFilePath = path.join(__dirname, 'tests', '支付宝收款码收款.txt'); | ||
// 使用readFileSync来同步读取文件内容 | ||
const data = fs.readFileSync(dataFilePath, 'utf8') | ||
let result = get(data); | ||
|
||
expect(result).toEqual({ | ||
type: 1, | ||
money: 0.01, | ||
fee: 0, | ||
shopName: '来自从前慢', | ||
shopItem: '普通红包', | ||
accountNameFrom: '支付宝余额', | ||
shopName: '**江', | ||
shopItem: '商品', | ||
accountNameFrom: '余额', | ||
accountNameTo: '', | ||
currency: 'CNY', | ||
time: 1702972951000, | ||
channel: '支付宝红包' | ||
time: 1703055625000, | ||
channel: '支付宝收款码收款' | ||
}); | ||
}); | ||
|
||
test("支付宝收钱码服务费", () => { | ||
const dataFilePath = path.join(__dirname, 'tests', '支付宝收钱码服务费.txt'); | ||
// 使用readFileSync来同步读取文件内容 | ||
const data = fs.readFileSync(dataFilePath, 'utf8') | ||
|
||
let result = get(data); | ||
|
||
expect(result).toEqual({ | ||
type: 0, | ||
money: 9.50, | ||
fee: 0, | ||
shopName: "支付宝(中国)网络技术有限公司", | ||
shopItem: "收钱码经营版信用卡收钱服务费[2024011022001425671431559132]", | ||
accountNameFrom: "余额", | ||
accountNameTo: "", | ||
currency: "CNY", | ||
time: 1704854659000, | ||
channel: "支付宝收钱码经营版信用卡收钱服务费" | ||
}); | ||
}); | ||
|
||
|
||
|
||
test("支付宝转账收款", () => { | ||
const dataFilePath = path.join(__dirname, 'tests', '支付宝转账收款.txt'); | ||
// 使用readFileSync来同步读取文件内容 | ||
const data = fs.readFileSync(dataFilePath, 'utf8') | ||
|
||
let result = get(data); | ||
|
||
expect(result).toEqual({ | ||
type: 1, // 0为支出,1为收入,2为转账 | ||
money: 0.01, | ||
fee: 0, | ||
shopName: "从前慢", | ||
shopItem: "转账", | ||
accountNameFrom: "余额", | ||
accountNameTo: "", | ||
currency: "CNY", | ||
time: 1710075615000, | ||
channel: "支付宝转账收款" | ||
}); | ||
}) | ||
}); | ||
|
||
test("支付宝余额转到余额宝", () => { | ||
|
||
var data = [] | ||
|
||
for (let i = 1; i < 3; i++) { | ||
const dataFilePath = path.join(__dirname, 'tests',`支付宝余额转到余额宝${i}.txt`); | ||
|
||
data.push(fs.readFileSync(dataFilePath, 'utf8')); | ||
} | ||
|
||
|
||
|
||
const expectResult = [ | ||
{ | ||
type: 2, | ||
money: 0.01, | ||
fee: 0, | ||
shopName: "余额宝", | ||
shopItem: "转账收款到余额宝", | ||
accountNameFrom: "余额", | ||
accountNameTo: "余额宝", | ||
currency: "CNY", | ||
time: 1710046787000, | ||
channel: "支付宝余额转到余额宝" | ||
}, | ||
{ | ||
type: 2, | ||
money: 0.01, | ||
fee: 0, | ||
shopName: "余额宝", | ||
shopItem: "转账收款到余额宝", | ||
accountNameFrom: "余额", | ||
accountNameTo: "余额宝", | ||
currency: "CNY", | ||
time: 1710075624000, | ||
channel: "支付宝余额转到余额宝" | ||
} | ||
] | ||
|
||
for (const index in data) { | ||
let result = get(data[index]); | ||
expect(result).toEqual(expectResult[index]); | ||
} | ||
|
||
|
||
}); | ||
|
||
test("余额宝收益发放", () => { | ||
const dataFilePath = path.join(__dirname, 'tests', '余额宝收益发放.txt'); | ||
// 使用readFileSync来同步读取文件内容 | ||
const data = fs.readFileSync(dataFilePath, 'utf8') | ||
|
||
let result = get(data); | ||
|
||
expect(result).toEqual({ | ||
type: 1, | ||
money: 0.01, | ||
fee: 0, | ||
shopName: "长城基金管理有限公司", | ||
shopItem: "余额宝-2024.03.25-收益发放", | ||
accountNameFrom: "余额宝", | ||
accountNameTo: "", | ||
currency: "CNY", | ||
time: 1711393834000, | ||
channel: "支付宝余额宝收益发放" | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.