refactor(payment): remove unused WebSocket event DTO and related schemas
This commit is contained in:
@@ -26,7 +26,8 @@ export function PwaInstallOverlay() {
|
||||
let mounted = true;
|
||||
|
||||
const init = async () => {
|
||||
const isDev = AppEnvUtil.isDevelopment();
|
||||
// const isDev = AppEnvUtil.isDevelopment();
|
||||
const isDev = false;
|
||||
const shouldShowDialog = await shouldShowPwaInstallDialog(isDev);
|
||||
if (!shouldShowDialog) return;
|
||||
|
||||
|
||||
@@ -8,4 +8,3 @@ export * from "./payment_order_status_response";
|
||||
export * from "./payment_plan";
|
||||
export * from "./payment_plans_response";
|
||||
export * from "./payment_vip_status_response";
|
||||
export * from "./payment_websocket_event";
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
/**
|
||||
* 支付 WebSocket 事件 DTO
|
||||
*/
|
||||
import {
|
||||
PaymentWebSocketEventSchema,
|
||||
type PaymentWebSocketEventData,
|
||||
type PaymentWebSocketEventInput,
|
||||
} from "@/data/schemas/payment/payment_websocket_event";
|
||||
|
||||
export class PaymentWebSocketEvent {
|
||||
declare readonly type: PaymentWebSocketEventData["type"];
|
||||
declare readonly orderId: string;
|
||||
|
||||
private constructor(input: PaymentWebSocketEventInput) {
|
||||
const data = PaymentWebSocketEventSchema.parse(input);
|
||||
Object.assign(this, data);
|
||||
Object.freeze(this);
|
||||
}
|
||||
|
||||
static from(input: PaymentWebSocketEventInput): PaymentWebSocketEvent {
|
||||
return new PaymentWebSocketEvent(input);
|
||||
}
|
||||
|
||||
static fromJson(json: unknown): PaymentWebSocketEvent {
|
||||
return PaymentWebSocketEvent.from(json as PaymentWebSocketEventInput);
|
||||
}
|
||||
|
||||
toJson(): PaymentWebSocketEventData {
|
||||
return PaymentWebSocketEventSchema.parse(this);
|
||||
}
|
||||
}
|
||||
|
||||
export type { PaymentWebSocketEventData };
|
||||
@@ -8,4 +8,3 @@ export * from "./payment_order_status_response";
|
||||
export * from "./payment_plan";
|
||||
export * from "./payment_plans_response";
|
||||
export * from "./payment_vip_status_response";
|
||||
export * from "./payment_websocket_event";
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
/**
|
||||
* 支付 WebSocket 事件
|
||||
*/
|
||||
import { z } from "zod";
|
||||
|
||||
export const PaymentSuccessVipEventSchema = z.object({
|
||||
type: z.literal("payment_success"),
|
||||
orderId: z.string(),
|
||||
payType: z.literal("vip"),
|
||||
planName: z.string(),
|
||||
vipExpiresAt: z.string().nullable(),
|
||||
});
|
||||
|
||||
export const PaymentSuccessDolEventSchema = z.object({
|
||||
type: z.literal("payment_success"),
|
||||
orderId: z.string(),
|
||||
payType: z.literal("dol"),
|
||||
planName: z.string(),
|
||||
dolAmount: z.number(),
|
||||
dolBalance: z.number(),
|
||||
});
|
||||
|
||||
export const PaymentFailedEventSchema = z.object({
|
||||
type: z.literal("payment_failed"),
|
||||
orderId: z.string(),
|
||||
info: z.string(),
|
||||
});
|
||||
|
||||
export const PaymentSuccessEventSchema = z.discriminatedUnion("payType", [
|
||||
PaymentSuccessVipEventSchema,
|
||||
PaymentSuccessDolEventSchema,
|
||||
]);
|
||||
|
||||
export const PaymentWebSocketEventSchema = z.union([
|
||||
PaymentSuccessEventSchema,
|
||||
PaymentFailedEventSchema,
|
||||
]);
|
||||
|
||||
export type PaymentSuccessVipEventData = z.output<
|
||||
typeof PaymentSuccessVipEventSchema
|
||||
>;
|
||||
export type PaymentSuccessDolEventData = z.output<
|
||||
typeof PaymentSuccessDolEventSchema
|
||||
>;
|
||||
export type PaymentFailedEventData = z.output<typeof PaymentFailedEventSchema>;
|
||||
export type PaymentSuccessEventData = z.output<typeof PaymentSuccessEventSchema>;
|
||||
export type PaymentWebSocketEventInput = z.input<
|
||||
typeof PaymentWebSocketEventSchema
|
||||
>;
|
||||
export type PaymentWebSocketEventData = z.output<
|
||||
typeof PaymentWebSocketEventSchema
|
||||
>;
|
||||
Reference in New Issue
Block a user