feat(fulfillment): 增加账号商品能力索引与生命周期事件

This commit is contained in:
yml
2026-11-18 19:30:59 +08:00
parent dc95d83b32
commit 667634a8df
35 changed files with 3076 additions and 82 deletions
+4
View File
@@ -1,5 +1,6 @@
import api from './client';
import type {
AccountCommodityStates,
AccountExchangeRecords,
AccountEventPage,
AccountItem,
@@ -113,6 +114,9 @@ export const accountApi = {
// 三个作用域的**官方**兑换记录(点列表那一格时按需拉取,不进列表响应)
exchangeRecords: (id: number) =>
api.get<AccountExchangeRecords, AccountExchangeRecords>(`/accounts/${id}/exchange-records`),
// 账号 × 商品当前能力索引(查询快照,带最后确认时间)
commodities: (id: number, params?: { scope?: string; availability?: string; limit?: number }) =>
api.get<AccountCommodityStates, AccountCommodityStates>(`/accounts/${id}/commodities`, { params }),
// 时间线(倒序分页),event_type 为空表示全部
events: (
id: number,
+47 -2
View File
@@ -160,12 +160,21 @@ export type AccountEventType =
| 'elite_opened'
| 'esports_opened'
| 'assigned'
| 'tag_changed';
| 'tag_changed'
| 'remark_changed'
| 'automation_changed'
| 'task_started'
| 'task_succeeded'
| 'task_failed'
| 'task_stopped'
| 'query_completed'
| 'lease_acquired'
| 'lease_released';
export interface AccountEventItem {
id: number;
event_type: AccountEventType | string;
/** 粗分类:lifecycle / auth / business / ops */
/** 粗分类:lifecycle / auth / business / activity / ops */
category?: string;
occurred_at: string;
title: string;
@@ -187,6 +196,41 @@ export interface AccountEventPage {
page_size: number;
}
export type AccountCommodityAvailability =
| 'available'
| 'limited'
| 'no_stock'
| 'not_open'
| 'not_offered'
| 'expired'
| 'unknown';
export interface AccountCommodityState {
commodity_id: string;
commodity_name: string;
scope: string;
availability: AccountCommodityAvailability;
blocking_reason: string;
raw_status: string;
time_limited: boolean;
available_from: string | null;
available_until: string | null;
schedule: Array<Record<string, unknown>>;
observed_at: string | null;
valid_until: string | null;
next_check_at: string | null;
last_exchange_at: string | null;
exchange_count_365d: number;
fresh: boolean;
source: string;
error_code: string;
}
export interface AccountCommodityStates {
items: AccountCommodityState[];
summary: Record<string, number>;
}
export interface AccountOverviewStats {
recharge_total: number;
exchange_count: number;
@@ -220,6 +264,7 @@ export interface AccountOverview {
points: number | null;
gold_balance: number | null;
exchange_balance: number | null;
commodity_capability?: Record<string, number>;
/** 积分到期时间(一键查询会刷新它) */
points_expire_at: string | null;
game_name: string;