ca4bef959f
Adjust all entity types to match actual backend response shapes. String-typed numeric fields (Shop.rating, Shop.commissionValue, WalletTransaction.amount) now correctly typed as strings. Post.linkedOrderId changed from SnowflakeId to number (backend int64). Removed fields absent from backend: Order consumer/player/shopName, Review fromUserAvatar/toUserId, Dispute initiatorId/initiatorName, Post authorRole/quotedPostId, Comment postId, ChatSession readonly/lastMessageAt, ChatMessage senderName/senderAvatar. Added Player.gender field.
214 lines
4.2 KiB
TypeScript
214 lines
4.2 KiB
TypeScript
// All `id` fields come from backend snowflake int64.
|
|
// Frontend stores them as strings to avoid JS number precision issues.
|
|
|
|
export type SnowflakeId = string
|
|
|
|
export type UserRole = "consumer" | "player" | "owner" | "admin"
|
|
export type VerificationStatus = "pending" | "approved" | "rejected"
|
|
|
|
export interface User {
|
|
id: SnowflakeId
|
|
username: string
|
|
nickname: string
|
|
avatar: string
|
|
role: UserRole
|
|
verifiedRoles?: UserRole[]
|
|
verificationStatus?: Partial<Record<UserRole, VerificationStatus>>
|
|
phone?: string
|
|
bio?: string
|
|
createdAt: string
|
|
}
|
|
|
|
export interface Game {
|
|
id: SnowflakeId
|
|
name: string
|
|
icon: string
|
|
category: string
|
|
}
|
|
|
|
export interface PlayerService {
|
|
id: SnowflakeId
|
|
playerId: SnowflakeId
|
|
gameId: SnowflakeId
|
|
gameName: string
|
|
title: string
|
|
description: string
|
|
price: number
|
|
unit: string
|
|
rankRange?: string
|
|
availability: string[]
|
|
}
|
|
|
|
export interface Player {
|
|
id: SnowflakeId
|
|
user: User
|
|
rating: number
|
|
totalOrders: number
|
|
completionRate: number
|
|
status: "available" | "busy" | "offline"
|
|
games: string[]
|
|
services: PlayerService[]
|
|
shopId?: SnowflakeId
|
|
shopName?: string
|
|
gender: boolean
|
|
tags: string[]
|
|
}
|
|
|
|
export interface Shop {
|
|
id: SnowflakeId
|
|
owner: User
|
|
name: string
|
|
banner?: string
|
|
description: string
|
|
rating: string
|
|
totalOrders: number
|
|
playerCount: number
|
|
commissionType: "fixed" | "percentage"
|
|
commissionValue: string
|
|
allowMultiShop: boolean
|
|
allowIndependentOrders: boolean
|
|
dispatchMode: "manual" | "auto"
|
|
announcements: string[]
|
|
templateConfig: ShopTemplateConfig
|
|
}
|
|
|
|
export interface ShopTemplateConfig {
|
|
sections: ShopSection[]
|
|
}
|
|
|
|
export interface ShopSection {
|
|
type: "banner" | "intro" | "services" | "players" | "announcements" | "reviews"
|
|
enabled: boolean
|
|
order: number
|
|
}
|
|
|
|
export type OrderStatus =
|
|
| "pending_payment"
|
|
| "pending_accept"
|
|
| "in_progress"
|
|
| "pending_close"
|
|
| "pending_review"
|
|
| "disputed"
|
|
| "completed"
|
|
| "cancelled"
|
|
|
|
export interface Order {
|
|
id: SnowflakeId
|
|
consumerId: SnowflakeId
|
|
playerId: SnowflakeId
|
|
shopId?: SnowflakeId
|
|
service: PlayerService
|
|
status: OrderStatus
|
|
totalPrice: number
|
|
note?: string
|
|
createdAt: string
|
|
acceptedAt?: string
|
|
completedAt?: string
|
|
}
|
|
|
|
export interface Review {
|
|
id: SnowflakeId
|
|
orderId: SnowflakeId
|
|
fromUserId: SnowflakeId
|
|
fromUserName: string
|
|
rating: number
|
|
content: string
|
|
sealed: boolean
|
|
createdAt: string
|
|
}
|
|
|
|
export interface Dispute {
|
|
id: SnowflakeId
|
|
orderId: SnowflakeId
|
|
reason: string
|
|
evidence: string[]
|
|
status: "open" | "reviewing" | "resolved" | "appealed"
|
|
result?: "full_refund" | "full_payment" | "partial_refund"
|
|
createdAt: string
|
|
}
|
|
|
|
export interface ChatParticipant {
|
|
id: SnowflakeId
|
|
nickname: string
|
|
avatar: string
|
|
}
|
|
|
|
interface BaseChatSession {
|
|
id: SnowflakeId
|
|
participants: ChatParticipant[]
|
|
lastMessage?: string
|
|
unreadCount: number
|
|
}
|
|
|
|
export interface OrderChatSession extends BaseChatSession {
|
|
type: "order"
|
|
orderId: SnowflakeId
|
|
}
|
|
|
|
export interface ConsultationChatSession extends BaseChatSession {
|
|
type: "consultation"
|
|
orderId?: never
|
|
}
|
|
|
|
export type ChatSession = OrderChatSession | ConsultationChatSession
|
|
|
|
export interface ChatMessage {
|
|
id: SnowflakeId
|
|
sessionId: SnowflakeId
|
|
senderId: SnowflakeId
|
|
type: "text" | "image" | "system"
|
|
content: string
|
|
createdAt: string
|
|
}
|
|
|
|
export interface Post {
|
|
id: SnowflakeId
|
|
author: User
|
|
title: string
|
|
content: string
|
|
images: string[]
|
|
tags: string[]
|
|
linkedOrderId?: number
|
|
pinned: boolean
|
|
likeCount: number
|
|
commentCount: number
|
|
liked: boolean
|
|
createdAt: string
|
|
}
|
|
|
|
export interface Comment {
|
|
id: SnowflakeId
|
|
author: User
|
|
content: string
|
|
likeCount: number
|
|
liked: boolean
|
|
createdAt: string
|
|
}
|
|
|
|
export interface Notification {
|
|
id: SnowflakeId
|
|
type: "order" | "community" | "system"
|
|
title: string
|
|
content: string
|
|
read: boolean
|
|
link?: string
|
|
createdAt: string
|
|
}
|
|
|
|
export interface WalletTransaction {
|
|
id: SnowflakeId
|
|
type: "topup" | "payment" | "income" | "withdrawal" | "refund"
|
|
amount: string
|
|
description: string
|
|
orderId?: string
|
|
createdAt: string
|
|
}
|
|
|
|
export interface Favorite {
|
|
id: SnowflakeId
|
|
userId: SnowflakeId
|
|
targetType: "player" | "shop"
|
|
targetId: SnowflakeId
|
|
createdAt: string
|
|
}
|