-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathusage-subscription.js
More file actions
42 lines (39 loc) · 1.3 KB
/
Copy pathusage-subscription.js
File metadata and controls
42 lines (39 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
({
request: {
url: "https://api.commandcode.ai/alpha/billing/subscriptions",
method: "GET",
headers: {
"Authorization": "Bearer {{apiKey}}"
}
},
extractor: function(response) {
if (response.success && response.data) {
const sub = response.data;
const planId = sub.planId;
const periodEnd = new Date(sub.currentPeriodEnd);
const now = new Date();
const daysLeft = Math.ceil((periodEnd - now) / (1000 * 60 * 60 * 24));
// ⚠️ 手动维护:planId 到月度额度的映射
const planCredits = {
"individual-goat": 70,
"individual-pro": 30,
"individual-pro-v1": 80,
"individual-provider": 15,
"individual-max": 150,
"individual-ultra": 300,
"teams-pro": 40
};
const monthlyCap = planCredits[planId] || 0;
const planName = planId ? planId.replace("individual-", "").toUpperCase() : "Unknown";
return {
isValid: true,
remaining: daysLeft,
total: 30,
unit: "days",
planName: planName,
extra: "套餐: " + planName + " (" + monthlyCap + " credits/月)\n到期: " + daysLeft + " 天后 (" + sub.currentPeriodEnd.split("T")[0] + ")"
};
}
return { isValid: false, invalidMessage: "查询失败" };
}
})