公司介绍 财务数据

This commit is contained in:
Sakurasan
2026-07-06 19:44:40 +08:00
parent cffdea5407
commit 83c88ee945
7 changed files with 1498 additions and 5 deletions
+133
View File
@@ -288,6 +288,139 @@ export async function fetchStockFundFlow(code: string, name?: string, days: numb
}
}
// ---- 公司概况 ----
export interface CompanyProfile {
code: string;
name: string;
fullName: string;
englishName: string;
boardType: string;
industry: string;
exchange: string;
industryDetail: string;
chairman: string;
generalManager: string;
secretary: string;
phone: string;
email: string;
fax: string;
website: string;
officeAddress: string;
registeredAddress: string;
region: string;
postalCode: string;
registeredCapital: string;
unifiedCreditCode: string;
employees: string;
managementCount: string;
lawFirm: string;
auditor: string;
businessScope: string;
companyProfile: string;
establishmentDate: string;
listingDate: string;
listingPrice: string;
issuePriceEarningsRatio: string;
issueAmount: string;
netProceeds: string;
issueMethod: string;
}
/**
* 获取公司概况
*/
export async function fetchCompanyProfile(code: string): Promise<CompanyProfile | null> {
const baseUrl = getApiBaseUrl();
const url = `${baseUrl}/api/stock/profile?code=${code}`;
try {
const resp = await fetch(url);
if (!resp.ok) return null;
const result = await resp.json();
return result.data || null;
} catch (err) {
console.error("[stock-api] 获取公司概况失败:", err);
return null;
}
}
// ---- 经营分析(收入构成)----
export interface BusinessSegmentItem {
itemName: string;
income: number | null;
cost: number | null;
profit: number | null;
grossRatio: number | null;
incomeRatio: number | null;
profitRatio: number | null;
costRatio: number | null;
}
export interface BusinessSegmentPeriod {
reportName: string;
items: BusinessSegmentItem[];
}
export interface BusinessSegmentsResponse {
data: BusinessSegmentPeriod[];
count: number;
code: string;
name: string;
byType: string;
}
type SegmentType = "product" | "industry" | "region";
/**
* 获取主营构成(收入构成)
*/
export async function fetchBusinessSegments(code: string, byType: SegmentType = "product", years: number = 3): Promise<BusinessSegmentsResponse | null> {
const baseUrl = getApiBaseUrl();
const url = `${baseUrl}/api/stock/business-segments?code=${code}&by_type=${byType}&years=${years}`;
try {
const resp = await fetch(url);
if (!resp.ok) return null;
return await resp.json();
} catch (err) {
console.error("[stock-api] 获取主营构成失败:", err);
return null;
}
}
// ---- 财务指标 ----
export interface FinancialReportItem {
reportDate: string;
reportType: string;
reportDateName: string;
noticeDate: string;
indicators: Record<string, number | string | boolean>;
}
export interface FinancialDataResponse {
data: FinancialReportItem[];
count: number;
code: string;
name: string;
}
/**
* 获取财务指标数据
*/
export async function fetchFinancialData(code: string, years: number = 5): Promise<FinancialDataResponse | null> {
const baseUrl = getApiBaseUrl();
const url = `${baseUrl}/api/stock/financial?code=${code}&years=${years}`;
try {
const resp = await fetch(url);
if (!resp.ok) return null;
return await resp.json();
} catch (err) {
console.error("[stock-api] 获取财务数据失败:", err);
return null;
}
}
// ---- 板块数据 ----
export interface SectorItem {