import { ProColumns } from '@ant-design/pro-components';
import { useModel } from '@umijs/max';

export const columns = (): ProColumns<any>[] => {
  let { getEnum } = useModel('global')
  return [
    {
      title: 'openId',
      dataIndex: 'openId',
      align: 'center',
      width: 70,
      ellipsis: true,
      render: (_, row) => {
        return row?.wechatMiniappUser?.openId
      }
    },
    {
      title: '小说名称',
      dataIndex: 'bookName',
      key: 'bookName',
      align: 'center',
      width: 150,
      ellipsis: true,
      render: (a, b) => {
        return b?.bookInfo?.bookName;
      },
    },
    {
      title: '应用名称',
      dataIndex: 'appName',
      key: 'appName',
      width: 120,
      align: 'center',
      ellipsis: true,
      render: (a, b) => {
        return b?.appInfo?.appName;
      },
    },
    {
      title: '分销商名称',
      dataIndex: 'companyName',
      key: 'companyName',
      width: 120,
      align: 'center',
      ellipsis: true,
      render: (a, b) => {
        return b?.distributorInfo?.companyName;
      },
    },
    {
      title: '订单号',
      dataIndex: 'orderId',
      width: 170,
      align: 'center',
      ellipsis: true,
    },
    {
      title: '商户订单号',
      dataIndex: 'merchantOrderId',
      width: 170,
      align: 'center',
      ellipsis: true,
    },
    {
      title: '订单类型',
      dataIndex: 'orderType',
      width: 170,
      align: 'center',
      ellipsis: true,
      valueEnum:getEnum("ORDER_TYPE","map")
    },
    {
      title: '充值金额',
      dataIndex: 'amount',
      width: 170,
      align: 'center',
      ellipsis: true,
      hideInSearch: true,
    },
    {
      title: '实际支付金额',
      dataIndex: 'payAmount',
      width: 170,
      align: 'center',
      ellipsis: true,
      hideInSearch: true,
    },
    {
      title: '支付渠道',
      dataIndex: 'payChannel',
      width: 170,
      align: 'center',
      ellipsis: true,
      hideInSearch: true,
      valueEnum:getEnum("PAY_CHANNEL","map")
    },
    {
      title: '支付状态',
      dataIndex: 'orderStatus',
      width: 170,
      align: 'center',
      ellipsis: true,
      valueEnum:getEnum("ORDER_STATUS","map")
    },
    {
      title: '支付场景',
      dataIndex: 'orderCondition',
      width: 170,
      align: 'center',
      ellipsis: true,
    },
    {
      title: '下单时间',
      dataIndex: 'orderTime',
      width: 170,
      align: 'center',
      ellipsis: true,
      hideInSearch: true,
    },
    {
      title: '支付时间',
      dataIndex: 'payTime',
      width: 170,
      align: 'center',
      ellipsis: true,
      hideInSearch: true,
    },
    {
      title: '归因渠道',
      dataIndex: 'userChannel',
      width: 170,
      align: 'center',
      ellipsis: true,
      valueType: 'select',
      valueEnum: getEnum("USER_CHANNEL", "map"),
      render: (_, row) => {
        let str = getEnum("USER_CHANNEL", "map").get(row?.wechatMiniappUser?.userChannel)
        return str
      }
    },
    // 搜索
    {
      title: '支付金额',
      dataIndex: 'amount',
      valueType: 'digitRange',
      width: 170,
      hideInTable: true,
    },
    {
      title: '下单时间',
      dataIndex: 'orderTime',
      valueType: 'dateRange',
      hideInTable: true,
      fieldProps: {
        style: { width: 250 },
      },
    },
  ];
};
