fix(reporting-service): 修复面对面结算数据解包问题

wallet-service 返回 { success, data, timestamp } 包装格式,
getOfflineSettlementSummary 需要用 response.data.data 解包才能获取真正的数据。

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-06 20:23:54 -08:00
parent 4df9895863
commit 9953f0eee5
1 changed files with 107 additions and 2 deletions

View File

@ -94,6 +94,43 @@ export interface AllSystemAccountsLedgerResponse {
}>;
}
// [2026-01-06] 新增:手续费归集账户汇总响应类型
export interface FeeCollectionSummaryResponse {
accountSequence: string;
accountBalance: number;
totalAmount: number;
totalCount: number;
breakdown: Array<{
feeType: string;
amount: number;
count: number;
}>;
byMonth: Array<{
month: string;
amount: number;
count: number;
}>;
}
// [2026-01-06] 新增:手续费归集流水条目
export interface FeeCollectionEntryDTO {
id: string;
feeType: string;
amount: number;
refOrderId: string | null;
memo: string | null;
createdAt: string;
}
// [2026-01-06] 新增:手续费归集流水列表响应
export interface FeeCollectionEntriesResponse {
entries: FeeCollectionEntryDTO[];
total: number;
page: number;
pageSize: number;
totalPages: number;
}
@Injectable()
export class WalletServiceClient {
private readonly logger = new Logger(WalletServiceClient.name);
@ -111,6 +148,7 @@ export class WalletServiceClient {
/**
*
* [2026-01-06] wallet-service { success, data, timestamp }
*/
async getOfflineSettlementSummary(params?: {
startDate?: string;
@ -125,10 +163,11 @@ export class WalletServiceClient {
this.logger.debug(`[getOfflineSettlementSummary] 请求: ${url}`);
const response = await firstValueFrom(
this.httpService.get<OfflineSettlementSummary>(url),
this.httpService.get<{ success: boolean; data: OfflineSettlementSummary; timestamp: string }>(url),
);
return response.data;
// wallet-service 返回 { success, data, timestamp } 包装格式
return response.data.data;
} catch (error) {
this.logger.error(`[getOfflineSettlementSummary] 失败: ${error.message}`);
// 返回默认值,不阻塞报表
@ -220,4 +259,70 @@ export class WalletServiceClient {
};
}
}
// [2026-01-06] 新增:获取手续费归集账户汇总统计
/**
*
* S0000000006
*/
async getFeeCollectionSummary(): Promise<FeeCollectionSummaryResponse> {
try {
const url = `${this.baseUrl}/api/v1/wallets/statistics/fee-collection-summary`;
this.logger.debug(`[getFeeCollectionSummary] 请求: ${url}`);
const response = await firstValueFrom(
this.httpService.get<FeeCollectionSummaryResponse>(url),
);
return response.data;
} catch (error) {
this.logger.error(`[getFeeCollectionSummary] 失败: ${error.message}`);
return {
accountSequence: 'S0000000006',
accountBalance: 0,
totalAmount: 0,
totalCount: 0,
breakdown: [],
byMonth: [],
};
}
}
/**
*
*/
async getFeeCollectionEntries(params?: {
page?: number;
pageSize?: number;
feeType?: string;
startDate?: string;
endDate?: string;
}): Promise<FeeCollectionEntriesResponse> {
try {
const queryParams = new URLSearchParams();
if (params?.page) queryParams.append('page', params.page.toString());
if (params?.pageSize) queryParams.append('pageSize', params.pageSize.toString());
if (params?.feeType) queryParams.append('feeType', params.feeType);
if (params?.startDate) queryParams.append('startDate', params.startDate);
if (params?.endDate) queryParams.append('endDate', params.endDate);
const url = `${this.baseUrl}/api/v1/wallets/statistics/fee-collection-entries?${queryParams.toString()}`;
this.logger.debug(`[getFeeCollectionEntries] 请求: ${url}`);
const response = await firstValueFrom(
this.httpService.get<FeeCollectionEntriesResponse>(url),
);
return response.data;
} catch (error) {
this.logger.error(`[getFeeCollectionEntries] 失败: ${error.message}`);
return {
entries: [],
total: 0,
page: 1,
pageSize: params?.pageSize ?? 50,
totalPages: 0,
};
}
}
}