feat(data): add paywall payment APIs

This commit is contained in:
2026-06-18 12:53:06 +08:00
parent 567d3f9184
commit 35c30ac31e
38 changed files with 840 additions and 10 deletions
@@ -13,6 +13,10 @@ export class ChatHistoryResponse {
declare readonly total: number;
declare readonly limit: number;
declare readonly offset: number;
declare readonly isVip: boolean;
declare readonly privateFreeLimit: number;
declare readonly privateUsedToday: number;
declare readonly privateCanViewFree: boolean;
private constructor(input: ChatHistoryResponseInput) {
const data = ChatHistoryResponseSchema.parse(input);
+3
View File
@@ -12,6 +12,9 @@ export class ChatMessage {
declare readonly content: string;
declare readonly id: string;
declare readonly createdAt: string;
declare readonly isPrivate: boolean | null;
declare readonly privateLocked: boolean | null;
declare readonly privateHint: string | null;
private constructor(input: ChatMessageInput) {
const data = ChatMessageSchema.parse(input);
+9 -1
View File
@@ -5,6 +5,7 @@ import {
ChatSendResponseSchema,
type ChatSendResponseInput,
type ChatSendResponseData,
type ChatBlockDetailData,
} from "@/data/schemas/chat/chat_send_response";
export class ChatSendResponse {
@@ -12,13 +13,20 @@ export class ChatSendResponse {
declare readonly reply: string;
declare readonly voiceUrl: string;
declare readonly audioUrl: string;
declare readonly intimidadChange: number;
declare readonly intimacyChange: number;
declare readonly newIntimacy: number;
declare readonly relationshipStage: string;
declare readonly currentMood: string;
declare readonly messageId: string;
declare readonly isGuest: boolean;
declare readonly timestamp: number;
declare readonly blocked: boolean | null;
declare readonly blockReason: string | null;
declare readonly blockDetail: ChatBlockDetailData | null;
declare readonly paywallTriggered: boolean;
declare readonly showUpgrade: boolean;
declare readonly imageType: string | null;
declare readonly imageUrl: string | null;
private constructor(input: ChatSendResponseInput) {
const data = ChatSendResponseSchema.parse(input);
+2
View File
@@ -14,3 +14,5 @@ export * from "./send_message_request";
export * from "./stt_data";
export * from "./sync_message";
export * from "./ui_message";
export * from "./unlock_private_request";
export * from "./unlock_private_response";
@@ -0,0 +1,30 @@
/**
* 私密消息解锁请求 DTO
*/
import {
UnlockPrivateRequestSchema,
type UnlockPrivateRequestData,
type UnlockPrivateRequestInput,
} from "@/data/schemas/chat/unlock_private_request";
export class UnlockPrivateRequest {
declare readonly messageId: string;
private constructor(input: UnlockPrivateRequestInput) {
const data = UnlockPrivateRequestSchema.parse(input);
Object.assign(this, data);
Object.freeze(this);
}
static from(input: UnlockPrivateRequestInput): UnlockPrivateRequest {
return new UnlockPrivateRequest(input);
}
static fromJson(json: unknown): UnlockPrivateRequest {
return UnlockPrivateRequest.from(json as UnlockPrivateRequestInput);
}
toJson(): UnlockPrivateRequestData {
return UnlockPrivateRequestSchema.parse(this);
}
}
@@ -0,0 +1,37 @@
/**
* 私密消息解锁响应 DTO
*/
import {
UnlockPrivateResponseSchema,
type UnlockPrivateReason,
type UnlockPrivateResponseData,
type UnlockPrivateResponseInput,
} from "@/data/schemas/chat/unlock_private_response";
export class UnlockPrivateResponse {
declare readonly unlocked: boolean;
declare readonly content: string | null;
declare readonly showUpgrade: boolean;
declare readonly paywallTriggered: boolean;
declare readonly privateFreeLimit: number;
declare readonly privateUsedToday: number;
declare readonly reason: UnlockPrivateReason;
private constructor(input: UnlockPrivateResponseInput) {
const data = UnlockPrivateResponseSchema.parse(input);
Object.assign(this, data);
Object.freeze(this);
}
static from(input: UnlockPrivateResponseInput): UnlockPrivateResponse {
return new UnlockPrivateResponse(input);
}
static fromJson(json: unknown): UnlockPrivateResponse {
return UnlockPrivateResponse.from(json as UnlockPrivateResponseInput);
}
toJson(): UnlockPrivateResponseData {
return UnlockPrivateResponseSchema.parse(this);
}
}
@@ -0,0 +1,39 @@
/**
* 创建支付订单请求 DTO
*/
import {
CreatePaymentOrderRequestSchema,
type CreatePaymentOrderRequestData,
type CreatePaymentOrderRequestInput,
type PayChannel,
} from "@/data/schemas/payment/create_payment_order_request";
export type { PayChannel };
export class CreatePaymentOrderRequest {
declare readonly planId: string;
declare readonly payChannel: PayChannel;
declare readonly autoRenew: boolean;
private constructor(input: CreatePaymentOrderRequestInput) {
const data = CreatePaymentOrderRequestSchema.parse(input);
Object.assign(this, data);
Object.freeze(this);
}
static from(
input: CreatePaymentOrderRequestInput,
): CreatePaymentOrderRequest {
return new CreatePaymentOrderRequest(input);
}
static fromJson(json: unknown): CreatePaymentOrderRequest {
return CreatePaymentOrderRequest.from(
json as CreatePaymentOrderRequestInput,
);
}
toJson(): CreatePaymentOrderRequestData {
return CreatePaymentOrderRequestSchema.parse(this);
}
}
@@ -0,0 +1,35 @@
/**
* 创建支付订单响应 DTO
*/
import {
CreatePaymentOrderResponseSchema,
type CreatePaymentOrderResponseData,
type CreatePaymentOrderResponseInput,
} from "@/data/schemas/payment/create_payment_order_response";
export class CreatePaymentOrderResponse {
declare readonly orderId: string;
declare readonly payParams: Record<string, unknown>;
private constructor(input: CreatePaymentOrderResponseInput) {
const data = CreatePaymentOrderResponseSchema.parse(input);
Object.assign(this, data);
Object.freeze(this);
}
static from(
input: CreatePaymentOrderResponseInput,
): CreatePaymentOrderResponse {
return new CreatePaymentOrderResponse(input);
}
static fromJson(json: unknown): CreatePaymentOrderResponse {
return CreatePaymentOrderResponse.from(
json as CreatePaymentOrderResponseInput,
);
}
toJson(): CreatePaymentOrderResponseData {
return CreatePaymentOrderResponseSchema.parse(this);
}
}
+11
View File
@@ -0,0 +1,11 @@
/**
* @file Payment DTO barrel.
*/
export * from "./create_payment_order_request";
export * from "./create_payment_order_response";
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";
@@ -0,0 +1,38 @@
/**
* 支付订单状态响应 DTO
*/
import {
PaymentOrderStatusResponseSchema,
type PaymentOrderStatus,
type PaymentOrderStatusResponseData,
type PaymentOrderStatusResponseInput,
} from "@/data/schemas/payment/payment_order_status_response";
export class PaymentOrderStatusResponse {
declare readonly orderId: string;
declare readonly status: PaymentOrderStatus;
declare readonly orderType: string;
declare readonly planId: string;
private constructor(input: PaymentOrderStatusResponseInput) {
const data = PaymentOrderStatusResponseSchema.parse(input);
Object.assign(this, data);
Object.freeze(this);
}
static from(
input: PaymentOrderStatusResponseInput,
): PaymentOrderStatusResponse {
return new PaymentOrderStatusResponse(input);
}
static fromJson(json: unknown): PaymentOrderStatusResponse {
return PaymentOrderStatusResponse.from(
json as PaymentOrderStatusResponseInput,
);
}
toJson(): PaymentOrderStatusResponseData {
return PaymentOrderStatusResponseSchema.parse(this);
}
}
+36
View File
@@ -0,0 +1,36 @@
/**
* 支付套餐 DTO
*/
import {
PaymentPlanSchema,
type PaymentPlanData,
type PaymentPlanInput,
} from "@/data/schemas/payment/payment_plan";
export class PaymentPlan {
declare readonly planId: string;
declare readonly planName: string;
declare readonly orderType: string;
declare readonly amountCents: number;
declare readonly currency: string;
declare readonly vipDays: number | null;
declare readonly dolAmount: number | null;
private constructor(input: PaymentPlanInput) {
const data = PaymentPlanSchema.parse(input);
Object.assign(this, data);
Object.freeze(this);
}
static from(input: PaymentPlanInput): PaymentPlan {
return new PaymentPlan(input);
}
static fromJson(json: unknown): PaymentPlan {
return PaymentPlan.from(json as PaymentPlanInput);
}
toJson(): PaymentPlanData {
return PaymentPlanSchema.parse(this);
}
}
@@ -0,0 +1,36 @@
/**
* 支付套餐列表响应 DTO
*/
import {
PaymentPlansResponseSchema,
type PaymentPlansResponseData,
type PaymentPlansResponseInput,
} from "@/data/schemas/payment/payment_plans_response";
import { PaymentPlan } from "./payment_plan";
export class PaymentPlansResponse {
declare readonly plans: PaymentPlan[];
private constructor(input: PaymentPlansResponseInput) {
const data = PaymentPlansResponseSchema.parse(input);
Object.assign(this, {
plans: data.plans.map((plan) => PaymentPlan.from(plan)),
});
Object.freeze(this);
}
static from(input: PaymentPlansResponseInput): PaymentPlansResponse {
return new PaymentPlansResponse(input);
}
static fromJson(json: unknown): PaymentPlansResponse {
return PaymentPlansResponse.from(json as PaymentPlansResponseInput);
}
toJson(): PaymentPlansResponseData {
return {
plans: this.plans.map((plan) => plan.toJson()),
};
}
}
@@ -0,0 +1,33 @@
/**
* VIP 状态响应 DTO
*/
import {
PaymentVipStatusResponseSchema,
type PaymentVipStatusResponseData,
type PaymentVipStatusResponseInput,
} from "@/data/schemas/payment/payment_vip_status_response";
export class PaymentVipStatusResponse {
declare readonly isVip: boolean;
declare readonly vipExpiresAt: string | null;
private constructor(input: PaymentVipStatusResponseInput) {
const data = PaymentVipStatusResponseSchema.parse(input);
Object.assign(this, data);
Object.freeze(this);
}
static from(input: PaymentVipStatusResponseInput): PaymentVipStatusResponse {
return new PaymentVipStatusResponse(input);
}
static fromJson(json: unknown): PaymentVipStatusResponse {
return PaymentVipStatusResponse.from(
json as PaymentVipStatusResponseInput,
);
}
toJson(): PaymentVipStatusResponseData {
return PaymentVipStatusResponseSchema.parse(this);
}
}
@@ -0,0 +1,33 @@
/**
* 支付 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 };