// 提款记录mock数据
export const withdrawMockData = {
  // 提款记录列表
  list: [
    {
      id: 1,
      order_no: 'WD202501150001',
      username: 'john_doe',
      phone: '13800138001',
      withdraw_type: 'bank',
      withdraw_type_text: '银行卡',
      withdraw_channel: 'BKASH',
      withdraw_channel_text: 'BKASH',
      currency: 'BDT',
      amount: 5000,
      status: 'processing',
      status_text: '处理中',
      bank_name: 'Dutch Bangla Bank',
      account_name: 'John Doe',
      account_number: '1234567890123456',
      create_time: '2025-01-15 10:30:00',
      success_time: '',
      user_id: 1001,
      // 详情页面额外字段
      fee: 50,
      actual_amount: 4950,
      bank_code: 'DBBL',
      branch_name: 'Dhaka Main Branch',
      account_balance: '15,000',
      profit_balance: '8,000',
      withdraw_balance: '7,000',
    },
    {
      id: 2,
      order_no: 'WD202501150002',
      username: 'jane_smith',
      phone: '13800138002',
      withdraw_type: 'mobile',
      withdraw_type_text: '手机钱包',
      withdraw_channel: 'NAGAD',
      withdraw_channel_text: 'NAGAD',
      currency: 'BDT',
      amount: 3000,
      status: 'success',
      status_text: '提款成功',
      bank_name: 'NAGAD',
      account_name: 'Jane Smith',
      account_number: '01712345678',
      create_time: '2025-01-15 09:15:00',
      success_time: '2025-01-15 09:45:30',
      user_id: 1002,
      // 详情页面额外字段
      fee: 30,
      actual_amount: 2970,
      bank_code: 'NAGAD',
      branch_name: '--',
      account_balance: '12,000',
      profit_balance: '5,000',
      withdraw_balance: '7,000',
    },
    {
      id: 3,
      order_no: 'WD202501150003',
      username: 'mike_wilson',
      phone: '13800138003',
      withdraw_type: 'bank',
      withdraw_type_text: '银行卡',
      withdraw_channel: 'BKASH',
      withdraw_channel_text: 'BKASH',
      currency: 'BDT',
      amount: 2000,
      status: 'failed',
      status_text: '提款失败',
      bank_name: 'Islami Bank Bangladesh',
      account_name: 'Mike Wilson',
      account_number: '9876543210987654',
      create_time: '2025-01-15 08:45:00',
      success_time: '',
      user_id: 1003,
      // 详情页面额外字段
      fee: 20,
      actual_amount: 1980,
      bank_code: 'IBBL',
      branch_name: 'Chittagong Branch',
      account_balance: '8,000',
      profit_balance: '3,000',
      withdraw_balance: '5,000',
    },
    {
      id: 4,
      order_no: 'WD202501150004',
      username: 'sarah_johnson',
      phone: '13800138004',
      withdraw_type: 'mobile',
      withdraw_type_text: '手机钱包',
      withdraw_channel: 'ROCKET',
      withdraw_channel_text: 'ROCKET',
      currency: 'BDT',
      amount: 7500,
      status: 'success',
      status_text: '提款成功',
      bank_name: 'ROCKET',
      account_name: 'Sarah Johnson',
      account_number: '01987654321',
      create_time: '2025-01-15 07:20:00',
      success_time: '2025-01-15 08:15:45',
      user_id: 1004,
      // 详情页面额外字段
      fee: 75,
      actual_amount: 7425,
      bank_code: 'ROCKET',
      branch_name: '--',
      account_balance: '20,000',
      profit_balance: '12,000',
      withdraw_balance: '8,000',
    },
    {
      id: 5,
      order_no: 'WD202501150005',
      username: 'david_brown',
      phone: '13800138005',
      withdraw_type: 'bank',
      withdraw_type_text: '银行卡',
      withdraw_channel: 'BKASH',
      withdraw_channel_text: 'BKASH',
      currency: 'BDT',
      amount: 4000,
      status: 'processing',
      status_text: '处理中',
      bank_name: 'Standard Chartered Bank',
      account_name: 'David Brown',
      account_number: '5432109876543210',
      create_time: '2025-01-15 06:10:00',
      success_time: '',
      user_id: 1005,
      // 详情页面额外字段
      fee: 40,
      actual_amount: 3960,
      bank_code: 'SCB',
      branch_name: 'Gulshan Branch',
      account_balance: '18,000',
      profit_balance: '10,000',
      withdraw_balance: '8,000',
    },
  ],

  // 状态统计
  statusCount: {
    all: 5,
    processing: 2,
    success: 2,
    failed: 1,
  },

  // 分页查询方法
  getList: (params) => {
    let filteredList = [...withdrawMockData.list];

    // 搜索过滤
    if (params.username) {
      filteredList = filteredList.filter((item) =>
        item.username.toLowerCase().includes(params.username.toLowerCase()),
      );
    }

    if (params.phone) {
      filteredList = filteredList.filter((item) => item.phone.includes(params.phone));
    }

    if (params.order_no) {
      filteredList = filteredList.filter((item) =>
        item.order_no.toLowerCase().includes(params.order_no.toLowerCase()),
      );
    }

    if (params.status && params.status !== 'all') {
      filteredList = filteredList.filter((item) => item.status === params.status);
    }

    // 时间范围过滤
    if (params.start_time && params.end_time) {
      filteredList = filteredList.filter((item) => {
        const createTime = new Date(item.create_time);
        const startTime = new Date(params.start_time);
        const endTime = new Date(params.end_time);
        return createTime >= startTime && createTime <= endTime;
      });
    }

    // 分页
    const page = parseInt(params.page) || 1;
    const listRows = parseInt(params.size) || 10;
    const total = filteredList.length;
    const start = (page - 1) * listRows;
    const end = start + listRows;
    const data = filteredList.slice(start, end);

    return {
      error: 0,
      msg: '获取成功',
      data: {
        data: data,
        current_page: page,
        per_page: listRows,
        total: total,
        last_page: Math.ceil(total / listRows),
      },
    };
  },

  // 获取详情
  getDetail: (id) => {
    const item = withdrawMockData.list.find((item) => item.id == id);
    return item
      ? { error: 0, msg: '获取成功', data: { ...item } }
      : { error: 1, msg: '记录不存在', data: null };
  },

  // 导出记录
  export: (params) => {
    // 模拟导出功能
    return {
      error: 0,
      msg: '导出成功',
      data: {
        download_url: 'https://example.com/export/withdraw_records.xlsx',
        filename: `提款记录_${new Date().toISOString().slice(0, 10)}.xlsx`,
      },
    };
  },
};
