feat(charge-points): add pricing mode for charge points with validation
feat(pricing): implement tariff management with peak, valley, and flat pricing feat(api): add tariff API for fetching and updating pricing configurations feat(tariff-schema): create database schema for tariff configuration feat(pricing-page): create UI for displaying and managing pricing tiers fix(sidebar): update sidebar to include pricing settings link
This commit is contained in:
@@ -77,6 +77,7 @@ export type ChargePoint = {
|
||||
lastHeartbeatAt: string | null;
|
||||
lastBootNotificationAt: string | null;
|
||||
feePerKwh: number;
|
||||
pricingMode: "fixed" | "tou";
|
||||
connectors: ConnectorSummary[];
|
||||
chargePointStatus: string | null;
|
||||
chargePointErrorCode: string | null;
|
||||
@@ -98,6 +99,7 @@ export type ChargePointDetail = {
|
||||
lastHeartbeatAt: string | null;
|
||||
lastBootNotificationAt: string | null;
|
||||
feePerKwh: number;
|
||||
pricingMode: "fixed" | "tou";
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
connectors: ConnectorDetail[];
|
||||
@@ -121,6 +123,8 @@ export type Transaction = {
|
||||
stopIdTag: string | null;
|
||||
stopReason: string | null;
|
||||
chargeAmount: number | null;
|
||||
electricityFee: number | null;
|
||||
serviceFee: number | null;
|
||||
};
|
||||
|
||||
export type IdTag = {
|
||||
@@ -154,6 +158,29 @@ export type PaginatedTransactions = {
|
||||
totalPages: number;
|
||||
};
|
||||
|
||||
export type PriceTier = "peak" | "valley" | "flat";
|
||||
|
||||
export type TariffSlot = {
|
||||
start: number;
|
||||
end: number;
|
||||
tier: PriceTier;
|
||||
};
|
||||
|
||||
export type TierPricing = {
|
||||
/** 电价(元/kWh) */
|
||||
electricityPrice: number;
|
||||
/** 服务费(元/kWh) */
|
||||
serviceFee: number;
|
||||
};
|
||||
|
||||
export type TariffConfig = {
|
||||
id?: string;
|
||||
slots: TariffSlot[];
|
||||
prices: Record<PriceTier, TierPricing>;
|
||||
createdAt?: string;
|
||||
updatedAt?: string;
|
||||
};
|
||||
|
||||
// ── API functions ──────────────────────────────────────────────────────────
|
||||
|
||||
export type ChartRange = "30d" | "7d" | "24h";
|
||||
@@ -181,6 +208,7 @@ export const api = {
|
||||
chargePointModel?: string;
|
||||
registrationStatus?: "Accepted" | "Pending" | "Rejected";
|
||||
feePerKwh?: number;
|
||||
pricingMode?: "fixed" | "tou";
|
||||
}) =>
|
||||
apiFetch<ChargePoint>("/api/charge-points", {
|
||||
method: "POST",
|
||||
@@ -190,6 +218,7 @@ export const api = {
|
||||
id: string,
|
||||
data: {
|
||||
feePerKwh?: number;
|
||||
pricingMode?: "fixed" | "tou";
|
||||
registrationStatus?: "Accepted" | "Pending" | "Rejected";
|
||||
chargePointVendor?: string;
|
||||
chargePointModel?: string;
|
||||
@@ -287,4 +316,9 @@ export const api = {
|
||||
create: (data: { name: string; email: string; username: string; password: string }) =>
|
||||
apiFetch<{ success: boolean }>("/api/setup", { method: "POST", body: JSON.stringify(data) }),
|
||||
},
|
||||
tariff: {
|
||||
get: () => apiFetch<TariffConfig | null>("/api/tariff"),
|
||||
put: (data: { slots: TariffSlot[]; prices: Record<PriceTier, TierPricing> }) =>
|
||||
apiFetch<TariffConfig>("/api/tariff", { method: "PUT", body: JSON.stringify(data) }),
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user