import { Statistic, Tooltip } from 'antd'
import { ColumnsType } from 'antd/lib/table'
import React from 'react'
import { Link } from 'umi'
function columns() {
    let newArr: ColumnsType<any> = [
        {
            title: '公众号名称',
            dataIndex: 'channel',
            key: 'channel',
            align: 'center',
            width: 75,
            fixed: 'left',
        },
        {
            title: '投手',
            dataIndex: 'pitcher',
            key: 'pitcher',
            align: 'center',
            width: 50,
            fixed: 'left',
        },
        {
            title: '期数',
            dataIndex: 'stage',
            key: 'stage',
            align: 'center',
            width: 60,
            fixed: 'left',
        },
        {
            title: '状态',
            dataIndex: 'state',
            key: 'state',
            align: 'center',
            width: 40,
        },
        {
            title: '投放位置',
            dataIndex: 'location',
            key: 'location',
            align: 'center',
            width: 40,
        },
        {
            title: '最早消耗日期',
            dataIndex: 'start',
            key: 'start',
            align: 'center',
            width: 70,
            sorter:true,
        },
        {
            title: '最晚消耗日期',
            dataIndex: 'end',
            key: 'end',
            align: 'center',
            width: 70,
            sorter:true,
        },
        {
            title: '累计消耗',
            dataIndex: 'total_cost',
            key: 'total_cost',
            align: 'center',
            width: 80,
            sorter:true,
            render: (a: string) => {
                return <Statistic  value={a || 0} />
            }
        },
        {
            title: '累计充值',
            dataIndex: 'total_amount',
            key: 'total_amount',
            align: 'center',
            width: 80,
            sorter:true,
            render: (a: string) => {
                return <Statistic  value={a || 0} />
            }
        },
        {
            title: '总毛利额',
            dataIndex: 'profit',
            key: 'profit',
            align: 'center',
            width: 80,
            sorter:true,
            render: (a: number) => {
                return <Statistic value={a || 0} valueStyle={a < 0 ? { color: '#0f990f', fontWeight: 600 } : {}} />
            }
        },
        {
            title: '回本率',
            dataIndex: 'roi',
            key: 'roi',
            align: 'center',
            width: 70,
            sorter:true,
            render: (a: number) => {
                a = a ? parseFloat((a * 100).toFixed(2)) : 0
                return <span style={a <= 8 ? { color: '#0f990f', fontWeight: 600 } : a >= 100 ? { color: 'red', fontWeight: 600 } : {}}> {a + '%'}</span >
            },
        },
        {
            title: '总关注人数',
            dataIndex: 'follow_user',
            key: 'follow_user',
            align: 'center',
            width: 70,
            sorter:true,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '平均关注人数成本',
            dataIndex: 'follow_per_cost',
            key: 'follow_per_cost',
            align: 'center',
            width: 90,
            sorter:true,
            render: (a: string) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '总充值人数',
            dataIndex: 'order_user',
            key: 'order_user',
            align: 'center',
            width: 90,
            sorter:true,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '充值转化比率',
            dataIndex: 'order_tran_rate',
            key: 'order_tran_rate',
            align: 'center',
            width: 90,
            sorter:true,
            render: (a: number) => {
                return a ?  (a * 100)?.toFixed(2) + '%' : '0%'
            }
        },
        {
            title: '充值转化成本',
            dataIndex: 'order_tran_cost',
            key: 'order_tran_cost',
            align: 'center',
            width:90,
            sorter:true,
            render: (a: string) => {
                return <Statistic  value={a || 0} />
            }
        },
        {
            title: '今日充值',
            dataIndex: 'td_amount',
            key: 'td_amount',
            align: 'center',
            width: 110,
            sorter: true,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '昨日充值',
            dataIndex: 'yd_amount',
            key: 'yd_amount',
            align: 'center',
            width: 110,
            sorter: true,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '前日充值',
            dataIndex: 'byd_amount',
            key: 'byd_amount',
            align: 'center',
            width: 110,
            sorter: true,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '操作',
            dataIndex: 'action',
            key: 'action',
            align: 'center',
            width: 40,
            render: (a: any, b: { channel: string }) => {
                return <Link to={`/dataStatistics/weChat/advertising?channel=${b.channel}`}>进入</Link>
            }
        },
    ]
    return newArr
}
export { columns }