/**
 * 支付设置相关类型定义
 */

// 支付渠道类型
export type PaymentProviderType = 'wechat' | 'wechat_v2' | 'fuiou'

interface PaymentConfigBase {
  id: number
  name: string
  description: string
  provider_type: PaymentProviderType
  is_active: boolean
  created_at: string
  updated_at: string
}

interface MiniappConfigFields {
  miniapp_app_id: string
  miniapp_app_secret: string
}

interface OfficialAccountConfigFields {
  oa_app_id: string
  oa_app_secret: string
  oa_token: string
  oa_aes_key: string
  oa_oauth_redirect_url: string
}

interface WechatPayConfigFields {
  wx_mch_id: string
  wx_api_v2_key: string
  wx_api_v3_key: string
  wx_notify_url: string
  wx_serial_no: string
  wx_cert_content: string
  wx_key_content: string
}

interface AlipayConfigFields {
  ali_app_id: string
  ali_private_key: string
  ali_public_key: string
  ali_notify_url: string
  ali_return_url: string
  ali_pay_expire_minutes: number
  ali_production: boolean
}

interface FuiouConfigFields {
  fy_api_url: string
  fy_ins_cd: string
  fy_mchnt_cd: string
  fy_term_id: string
  fy_notify_url: string
  fy_private_key: string
  fy_public_key: string
}

type PaymentConfigWritableFields = Partial<
  MiniappConfigFields &
    OfficialAccountConfigFields &
    WechatPayConfigFields &
    AlipayConfigFields &
    FuiouConfigFields
>

// 支付设置
export interface PaymentSettings
  extends PaymentConfigBase,
    MiniappConfigFields,
    OfficialAccountConfigFields,
    WechatPayConfigFields,
    AlipayConfigFields,
    FuiouConfigFields {}

// 查询参数
export interface PaymentSettingsQueryParams {
  page?: number
  page_size?: number
  provider_type?: PaymentProviderType
  is_active?: boolean
}

// 列表响应
export interface PaymentSettingsListResponse {
  items: PaymentSettings[]
  page: number
  size: number
  total: number
  page_size?: number
}

// 创建支付设置请求
export interface CreatePaymentSettingsRequest extends PaymentConfigWritableFields {
  name: string
  provider_type: PaymentProviderType
  description?: string
}

// 更新支付设置请求
export interface UpdatePaymentSettingsRequest extends PaymentConfigWritableFields {
  name?: string
  description?: string
  provider_type?: PaymentProviderType
}
