feat:采购日志

This commit is contained in:
2026-10-31 12:24:00 +08:00
parent a7f8f9c639
commit 8f30e6fe57
17 changed files with 1241 additions and 32 deletions
+69 -1
View File
@@ -660,6 +660,56 @@ export interface RockTokenItem {
updated_at?: string;
}
export interface RockPurchaseResult {
purchased_count: number;
requested_count: number;
planned_count: number;
limit_reason: string;
log_id: number;
message: string;
}
export interface RockPurchaseLog {
id: number;
trigger_type: "auto" | "manual";
status: "running" | "success" | "partial" | "failed" | "skipped";
requested_count: number;
planned_count: number;
claimed_count: number;
imported_count: number;
upstream_available: number;
points_before: number;
unit_cost: number;
max_by_points: number;
max_by_stock: number;
limit_reason: string;
points_source: string;
stage: string;
error_message: string;
package_id?: number;
share_code: string;
duration_ms: number;
started_at: string;
finished_at?: string;
created_at: string;
}
export interface RockPurchaseStage {
id: number;
log_id: number;
seq: number;
stage: string;
method: string;
url: string;
request_body: string;
http_status: number;
response_body: string;
truncated: boolean;
duration_ms: number;
error_message: string;
created_at: string;
}
export const rockApi = {
getConfig: () =>
request.get("/platform/rock/config").then((r) => r.data.data as RockConfig),
@@ -678,7 +728,25 @@ export const rockApi = {
.post("/platform/rock/dashboard/refresh")
.then((r) => r.data.data as RockDashboard),
purchaseTokens: (count = 50) =>
request.post("/platform/rock/purchase", { count }).then((r) => r.data.data),
request
.post("/platform/rock/purchase", { count })
.then((r) => r.data.data as RockPurchaseResult),
listPurchaseLogs: (params?: {
page?: number;
page_size?: number;
trigger_type?: string;
status?: string;
}) =>
request
.get("/platform/rock/purchase-logs", { params })
.then((r) => r.data.data as { list: RockPurchaseLog[]; total: number }),
getPurchaseLog: (id: number) =>
request
.get(`/platform/rock/purchase-logs/${id}`)
.then(
(r) =>
r.data.data as { log: RockPurchaseLog; stages: RockPurchaseStage[] },
),
listTokens: (params?: {
page?: number;
page_size?: number;