export type ProductType = 'course' | 'event' | 'data' | 'agent' | 'expert' | 'consulting' | 'membership'
export type MembershipLevel = 0 | 1 | 2
export type LoginProvider = 'phone' | 'wechat'

export interface UserProfile {
  id: string
  name: string
  phone?: string
  passportNo?: string
  wechatId?: string
  wechatBound?: boolean
  authProvider: LoginProvider
  onboardingCompleted: boolean
  contactPhone?: string
  email?: string
  organization?: string
  title?: string
  city?: string
  address?: string
  industry?: string
  invoiceTitle?: string
  taxNumber?: string
  invoiceEmail?: string
  expertApplicationStatus?: string
  expertProfileStatus?: string
  membershipLevel: MembershipLevel
  membershipStatus?: 'registered' | 'active' | 'expiring' | 'expired'
  membershipExpiresAt?: string | null
  membershipDaysLeft?: number | null
}

export interface ServiceProduct {
  id: string
  type: ProductType
  title: string
  subtitle: string
  summary: string
  price: number
  cover: string
  status?: string
  location?: string
  startsAt?: string
  duration?: string
  category?: string
  tags?: string[]
  mode?: 'online' | 'offline'
}

export interface CartItem {
  id: string
  type: ProductType
  title: string
  price: number
  subtitle: string
  cover: string
  expertBookingId?: string
  dataServiceRequestId?: string
  consultingRequestId?: string
  billingCycle?: 'monthly' | 'yearly'
}

export interface OrderRecord extends CartItem {
  orderNo: string
  settlementNo: string
  amount: number
  paidAmount: number
  purchasedAt: string
  productStatus: string
  invoiceStatus?: 'pending' | 'processing' | 'issued' | 'rejected' | 'failed' | ''
  invoiceApplication?: {
    id: string
    invoiceNo: string
    title: string
    taxNumber?: string
    email: string
    amount: number
    status: 'pending' | 'processing' | 'issued' | 'rejected' | 'failed'
    providerInvoiceId?: string
    fileUrl?: string
    failureReason?: string
    adminNote?: string
    issuedAt?: string
    createdAt: string
    updatedAt: string
  } | null
}

export interface DeliveryTask {
  id: string
  orderNo: string
  productId: string
  title: string
  type: ProductType
  status: string
  statusText: string
  currentStep: number
  steps: string[]
  progressNote?: string
  resultSummary?: string
  updatedAt: string
}

export interface ConsultingRequest {
  id: string
  title: string
  submittedAt: string
  status: '待受理' | '沟通中' | '已完成'
  company: string
  city: string
  industry: string
  stage: string
  urgency: string
  requirement: string
}

export interface DataServiceRequest {
  id: string
  requestNo: string
  status: string
  currentStep: number
  dataTopic: string
  serviceType: string
  requirement: string
  expectedResult: string
  quotedTitle?: string
  quotedAmount: number
  deliverableFileUrl?: string
  deliverableFileName?: string
  resultSummary?: string
  updatedAt: string
}

export interface Booking {
  id: string
  expertName: string
  expertTitle: string
  photo: string
  date: string
  time: string
  status: '待同意' | '预约中' | '已完成'
  meetingSoon?: boolean
  note: string
}

export interface Enrollment {
  id: string
  productId: string
  title: string
  cover: string
  status: string
  time?: string
  location?: string
  description?: string
}

export interface NewsArticle {
  id: string
  slug?: string
  title: string
  categoryCode?: string
  category: string
  summary: string
  date: string
  content?: string
  coverUrl?: string
  authorName?: string
  publishedAt?: string | null
  relatedArticleIds?: string[]
}

export interface ConsultingDirection {
  id: string
  slug: string
  title: string
  summary: string
  description: string
  note: string
  imageUrl: string
  scenarios: string[]
  sortOrder: number
  status: 'published' | 'hidden'
}

export interface ConsultingSite {
  content: {
    heroTitle: string
    heroDescription: string
    heroExplanation: string
    heroImageUrl: string
    directionTitle: string
    directionDescription: string
    casesTitle: string
    casesDescription: string
    stepsTitle: string
    stepsDescription: string
  }
  directions: ConsultingDirection[]
  cases: Array<{
    id: string
    type: string
    title: string
    summary: string
    imageUrl: string
    sortOrder: number
    status: 'published' | 'hidden'
  }>
  steps: Array<{
    id: string
    title: string
    description: string
    sortOrder: number
    status: 'published' | 'hidden'
  }>
  optionSets?: Array<{
    code: string
    name: string
    description?: string
    sortOrder: number
    status: 'active' | 'disabled'
    options: Array<{
      code: string
      label: string
      description?: string
      sortOrder: number
      status: 'active' | 'disabled'
    }>
  }>
}
