// 交易相关类型定义

export enum TransactionStatus {
  CREATED = 'created',
  PENDING = 'pending',
  BANK_SUBMITTED = 'bank_submitted',
  SUCCESS = 'success',
  FAILED = 'failed',
  TIMEOUT = 'timeout',
  REVERSED = 'reversed'
}

export enum TransactionType {
  TRANSFER = 'transfer',
  DEPOSIT = 'deposit',
  WITHDRAWAL = 'withdrawal',
  ADJUSTMENT = 'adjustment'
}

export enum TransactionDirection {
  INBOUND = 'inbound',
  OUTBOUND = 'outbound'
}

export interface SystemTransaction {
  id: number
  txnNo: string
  accountId: number
  counterpartyAccountId?: number
  txnType: TransactionType
  direction: TransactionDirection
  amount: number
  status: TransactionStatus
  bankRefNo?: string
  sourceKey?: string
  submittedAt?: string
  remark?: string
  createdAt: string
  confirmedAt?: string
  version: number
}

export interface BankTransaction {
  id: number
  txnNo: string
  bankRefNo: string
  accountNo: string
  counterpartyAccount: string
  counterpartyName: string
  amount: number
  txnType: string
  direction: 'in' | 'out'
  txnTime: string
  remark?: string
  status: string
}

export interface TransactionQuery {
  accountId?: number
  txnType?: TransactionType
  status?: TransactionStatus
  startTime?: string
  endTime?: string
  minAmount?: number
  maxAmount?: number
  page?: number
  pageSize?: number
}

export interface TransactionListResponse {
  items: SystemTransaction[]
  total: number
  page: number
  pageSize: number
}

// 请求类型
export interface CreateTransactionRequest {
  txnType: TransactionType
  fromAccountId?: number
  toAccountId?: number
  amount: number
  remark?: string
  sourceKey?: string
}

export interface TransferRequest {
  fromAccount: string
  toAccount: string
  toAccountName: string
  toBankCode: string
  amount: number
  remark?: string
  businessNo: string
}

export interface TransferResponse {
  success: boolean
  bankRefNo?: string
  errorCode?: string
  errorMessage?: string
}
