/**
 * 积分相关类型定义
 */

/**
 * 积分类型
 */
export type PointsType = 'production' | 'management' | 'other'

/**
 * 积分交易类型
 */
export type PointsTransactionType = 'earn' | 'spend' | 'transfer' | 'expire' | 'adjust'

/**
 * 积分账户
 */
export interface PointsAccount {
  id: number
  sub_account_id: number
  points_type: PointsType
  balance: string
  total_earned: string
  total_spent: string
  total_expired: string
  created_at: string
  updated_at: string
}

/**
 * 积分交易记录
 */
export interface PointsTransaction {
  id: number
  txn_no: string
  points_account_id: number
  txn_type: PointsTransactionType
  amount: string
  balance_before: string
  balance_after: string
  related_business_id?: string
  remark?: string
  created_at: string
}

/**
 * 积分获取请求
 */
export interface EarnPointsRequest {
  points_account_id: number
  amount: string
  related_business_id?: string
  remark?: string
}

/**
 * 积分消费请求
 */
export interface SpendPointsRequest {
  points_account_id: number
  amount: string
  related_business_id?: string
  remark?: string
}

/**
 * 积分转移请求
 */
export interface TransferPointsRequest {
  from_account_id: number
  to_account_id: number
  amount: string
  remark?: string
}

/**
 * 积分交易查询参数
 */
export interface PointsTransactionQuery {
  points_account_id?: number
  txn_type?: PointsTransactionType
  start_date?: string
  end_date?: string
  page?: number
  page_size?: number
}

/**
 * 积分规则
 */
export interface PointsRule {
  id: number
  name: string
  points_type: PointsType
  rule_type: string
  config: Record<string, unknown>
  enabled: boolean
  created_at: string
}

/**
 * 积分类型显示名称映射
 */
export const PointsTypeLabels: Record<PointsType, string> = {
  production: '生产积分',
  management: '管理积分',
  other: '其他积分',
}

/**
 * 积分交易类型显示名称映射
 */
export const PointsTransactionTypeLabels: Record<PointsTransactionType, string> = {
  earn: '获取',
  spend: '消费',
  transfer: '转移',
  expire: '过期',
  adjust: '调整',
}

