Twilioapp/src/types/billing.ts
2025-06-29 01:33:41 +08:00

121 lines
3.0 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 用户类型
export enum UserType {
INDIVIDUAL = 'individual', // 普通用户
ENTERPRISE = 'enterprise', // 企业用户
}
// 通话类型
export enum CallType {
VOICE = 'voice', // 语音通话
VIDEO = 'video', // 视频通话
}
// 翻译类型
export enum TranslationType {
TEXT = 'text', // 文字翻译
SIGN_LANGUAGE = 'sign_language', // 手语翻译
HUMAN_INTERPRETER = 'human_interpreter', // 真人翻译
}
// 计费规则
export interface BillingRule {
id: string;
name: string;
callType: CallType;
translationType: TranslationType;
pricePerMinute: number; // 每分钟价格(分)
minimumCharge: number; // 最低收费(分)
userType: UserType;
}
// 用户账户信息
export interface UserAccount {
id: string;
userType: UserType;
balance: number; // 余额(分)
enterpriseContractId?: string; // 企业合同ID
creditLimit?: number; // 信用额度(分)
}
// 预约信息
export interface Appointment {
id: string;
userId: string;
title: string;
description?: string;
scheduledTime: Date;
duration: number; // 预计时长(分钟)
callType: CallType;
translationType: TranslationType;
interpreterIds?: string[]; // 翻译员ID列表
estimatedCost: number; // 预估费用(分)
status: 'scheduled' | 'confirmed' | 'in_progress' | 'completed' | 'cancelled';
createdAt: Date;
updatedAt: Date;
}
// 翻译员信息
export interface Interpreter {
id: string;
name: string;
avatar?: string;
languages: string[]; // 支持的语言
specialties: string[]; // 专业领域
rating: number; // 评分
pricePerMinute: number; // 每分钟价格(分)
availability: {
[key: string]: boolean; // 日期可用性
};
isOnline: boolean;
}
// 通话记录
export interface CallRecord {
id: string;
userId: string;
appointmentId?: string;
callType: CallType;
translationType: TranslationType;
interpreterIds?: string[];
startTime: Date;
endTime?: Date;
duration: number; // 实际时长(分钟)
cost: number; // 实际费用(分)
status: 'in_progress' | 'completed' | 'failed';
billingDetails: {
baseRate: number;
interpreterRate?: number;
totalMinutes: number;
totalCost: number;
};
}
// 充值记录
export interface RechargeRecord {
id: string;
userId: string;
amount: number; // 充值金额(分)
bonus: number; // 赠送金额(分)
paymentMethod: string;
status: 'pending' | 'completed' | 'failed';
createdAt: Date;
completedAt?: Date;
}
// 计费配置
export const BILLING_CONFIG = {
// 默认计费规则
DEFAULT_RATES: {
[CallType.VOICE]: {
[TranslationType.TEXT]: 50, // 0.5元/分钟
},
[CallType.VIDEO]: {
[TranslationType.SIGN_LANGUAGE]: 100, // 1元/分钟
[TranslationType.HUMAN_INTERPRETER]: 200, // 2元/分钟
},
},
// 低余额警告阈值5分钟费用
LOW_BALANCE_THRESHOLD_MINUTES: 5,
// 最低余额阈值1分钟费用
MINIMUM_BALANCE_THRESHOLD_MINUTES: 1,
};