import { timestampToTime } from '@/utils/dateUtil';

export const typeMap = {
  1: '全部玩家',
  2: '指定玩家',
};
export const statusMap = {
  1: '生效',
  2: '作废',
}
export const columns = [
  {
    title: '序号',
    dataIndex: 'id',
    key: 'id',
    width: 60,
  },
  {
    title: '批次名称',
    dataIndex: 'name',
    key: 'name',
    render(row) {
      return row.name;
    },
    width: 120,
  },
  {
    title: '批次编号',
    dataIndex: 'sn',
    key: 'sn',
    width: 150,
  },
  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
    render(row) {
      return typeMap[row.status] ?? `未知`;
    },
    width: 50,
  },
  {
    title: '服务器',
    key: 'server_ids',
    render: (rows, _) => {
      return rows.server_ids;
    },
    width: 80,
  },
  {
    title: '兑换类型',
    dataIndex: 'type_id',
    key: 'type_id',
    render(row) {
      return typeMap[row.type_id] ?? `未知`;
    },
    width: 100,
  },
  {
    title: 'openid',
    dataIndex: 'openid',
    key: 'openid',
    render(row) {
      return row.openid;
    },
    width: 100,
  },
  // {
  //   title: '可用次数',
  //   dataIndex: 'times',
  //   key: 'times',
  //   render(row) {
  //     return row.times;
  //   },
  //   width: 80,
  // },
  // {
  //   title: '已用次数',
  //   dataIndex: 'used',
  //   key: 'used',
  //   render(row) {
  //     return row.used;
  //   },
  //   width: 80,
  // },
  {
    title: '兑换物品',
    dataIndex: 'award',
    key: 'award',
    render(row) {
      return row.award;
    },
    width: 80,
  },
  {
    title: '过期时间',
    dataIndex: 'expired_at',
    key: 'expired_at',
    render: (rows, _) => {
      return timestampToTime(rows.expired_at);
    },
    width: 120,
  },
  {
    title: '生成人',
    dataIndex: 'operator',
    key: 'operator',
    render(row) {
      return row.operator;
    },
    width: 100,
  },
  {
    title: '生成时间',
    dataIndex: 'created_at',
    key: 'created_at',
    render: (rows, _) => {
      return timestampToTime(rows.created_at);
    },
    width: 120,
  },
];


export const redeemCodeListcolumns = [
  {
    title: '序号',
    dataIndex: 'id',
    key: 'id',
    width: 60,
  },
  {
    title: '批次名称',
    dataIndex: 'name',
    key: 'name',
    render(row) {
      return row.name;
    },
    width: 120,
  },
  {
    title: '批次编号',
    dataIndex: 'sn',
    key: 'sn',
    width: 150,
  },
  {
    title: '兑换码',
    dataIndex: 'cdk',
    key: 'cdk',
    render(row) {
      return row.cdk;
    },
    width: 150,
  },
  {
    title: '服务器',
    key: 'server_ids',
    render: (rows, _) => {
      return rows.server_ids;
    },
    width: 80,
  },
  {
    title: '可用次数',
    dataIndex: 'times',
    key: 'times',
    render(row) {
      return row.times;
    },
    width: 80,
  },
  {
    title: '已用次数',
    dataIndex: 'used',
    key: 'used',
    render(row) {
      return row.used;
    },
    width: 80,
  },
  {
    title: '兑换物品',
    dataIndex: 'award',
    key: 'award',
    render(row) {
      return row.award;
    },
    width: 80,
  },
  {
    title: '过期时间',
    dataIndex: 'expired_at',
    key: 'expired_at',
    render: (rows, _) => {
      return timestampToTime(rows.expired_at);
    },
    width: 120,
  },
  {
    title: '生成人',
    dataIndex: 'operator',
    key: 'operator',
    render(row) {
      return row.operator;
    },
    width: 100,
  },
  {
    title: '生成时间',
    dataIndex: 'created_at',
    key: 'created_at',
    render: (rows, _) => {
      return timestampToTime(rows.created_at);
    },
    width: 120,
  },
];