import { Statistic } from 'antd'
import { ColumnsType } from 'antd/lib/table'
import { SortOrder } from 'antd/lib/table/interface'
import React from 'react'
import style from './index.less'
function columns(props?: { sortOrder?: { columnKey: string, order: SortOrder | undefined } }) {
    let arr: ColumnsType<any> = Array(60).fill('').map((i: string, index: number) => {
        return {
            title: `D${index + 1}`,
            dataIndex: `d${index + 1}`,
            key: `d${index + 1}`,
            render: (a: { amount: number, roi: number, add: number, mult: number }) => {
                if (a?.amount) {
                    return <div className={style.dbox}>
                        <span style={{ color: '#0f538a', fontWeight: 600 }}>充：<span><Statistic value={a?.amount || 0} valueStyle={{ color: '#0f538a', fontWeight: 600 }} /></span></span>
                        <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>增：<span>{(a?.add * 100)?.toFixed(2)}%</span></span>
                        <span style={{ color: '#ff5722', fontWeight: 600 }}>回：<span>{(a?.roi * 100)?.toFixed(2)}%</span></span>
                        <span style={{ color: '#d81b60', fontWeight: 600 }}>倍：<span>{a?.mult}</span></span>
                    </div>
                }
                return '--'
            },
            width: 110
        }
    })
    let newArr: ColumnsType<any> = [
        {
            title: '时间',
            dataIndex: 'dt',
            key: 'dt',
            align: 'center',
            width: 95,
            fixed: 'left',
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'dt' && props?.sortOrder?.order) || undefined,
        },
        {
            title: '小说',
            dataIndex: 'book',
            key: 'book',
            align: 'center',
            width: 70,
            fixed: 'left',
            ellipsis: true,
            render:(str)=>{
                return <a href={`#/dataStatistics/book/payTrend?bookName=${str}`}>{str}</a>
            }
        },
        {
            title: '投放位置',
            dataIndex: 'type',
            key: 'type',
            align: 'center',
            width: 40,
            fixed: 'left',
        },
        {
            title: '当天消耗',
            dataIndex: 'cost',
            key: 'cost',
            width: 110,
            align: 'center',
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'cost' && props?.sortOrder?.order) || undefined,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '首日回收率',
            dataIndex: 'first_roi',
            key: 'first_roi',
            width: 70,
            align: 'center',
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'first_roi' && props?.sortOrder?.order) || undefined,
            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: 'roi7',
            key: 'roi7',
            align: 'center',
            width: 95,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'roi7' && props?.sortOrder?.order) || undefined,
            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: '当天用户30日回本率',
            dataIndex: 'roi30',
            key: 'roi30',
            align: 'center',
            width: 100,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'roi30' && props?.sortOrder?.order) || undefined,
            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: 'roi',
            key: 'roi',
            align: 'center',
            width: 85,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'roi' && props?.sortOrder?.order) || undefined,
            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: 'order_amount',
            key: 'order_amount',
            align: 'center',
            width: 110,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'order_amount' && props?.sortOrder?.order) || undefined,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '毛利额',
            dataIndex: 'profit',
            key: 'profit',
            align: 'center',
            width: 110,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'profit' && props?.sortOrder?.order) || undefined,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '点击率',
            dataIndex: 'click_rate',
            key: 'click_rate',
            align: 'center',
            width: 60,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'click_rate' && props?.sortOrder?.order) || undefined,
            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_rate',
            key: 'follow_rate',
            align: 'center',
            width: 60,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'follow_rate' && props?.sortOrder?.order) || undefined,
            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: 'first_order_rate',
            key: 'first_order_rate',
            align: 'center',
            width: 75,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'first_order_rate' && props?.sortOrder?.order) || undefined,
            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: 'view_count',
            key: 'view_count',
            align: 'center',
            width: 110,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'view_count' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return <Statistic value={a || 0} />
            },
        },
        {
            title: '点击量',
            dataIndex: 'click_count',
            key: 'click_count',
            align: 'center',
            width: 110,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'click_count' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return <Statistic value={a || 0} />
            },
        },
        {
            title: '关注人数',
            dataIndex: 'follow_user',
            key: 'follow_user',
            align: 'center',
            width: 85,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'follow_user' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return <Statistic value={a || 0} />
            },
        },
        {
            title: '新用户累计充值人数',
            dataIndex: 'reg_order_user',
            key: 'reg_order_user',
            align: 'center',
            width: 105,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'reg_order_user' && props?.sortOrder?.order) || undefined,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '首日充值人数',
            dataIndex: 'first_order_user',
            key: 'first_order_user',
            align: 'center',
            width: 80,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'first_order_user' && props?.sortOrder?.order) || undefined,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '关注成本',
            dataIndex: 'follow_cost',
            key: 'follow_cost',
            align: 'center',
            width: 70,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'follow_cost' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return <Statistic value={a || 0} />
            },
        },
        {
            title: '充值成本',
            dataIndex: 'order_cost',
            key: 'order_cost',
            align: 'center',
            width: 70,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'order_cost' && props?.sortOrder?.order) || undefined,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '首日充值成本',
            dataIndex: 'first_order_cost',
            key: 'first_order_cost',
            align: 'center',
            width: 80,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'first_order_cost' && props?.sortOrder?.order) || undefined,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        ...arr,
        {
            title: 'M3',
            dataIndex: 'm3',
            key: 'm3',
            render: (a: { amount: number, roi: number, add: number, mult: number }) => {
                if (a?.amount) {
                    return <div className={style.dbox}>
                        <span style={{ color: '#0f538a', fontWeight: 600 }}>充：<span><Statistic value={a?.amount || 0} valueStyle={{ color: '#0f538a', fontWeight: 600 }} /></span></span>
                        <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>增：<span>{(a?.add * 100)?.toFixed(2)}%</span></span>
                        <span style={{ color: '#ff5722', fontWeight: 600 }}>回：<span>{(a?.roi * 100)?.toFixed(2)}%</span></span>
                        <span style={{ color: '#d81b60', fontWeight: 600 }}>倍：<span>{a?.mult}</span></span>
                    </div>
                }
                return '--'
            },
            width: 130
        },
        {
            title: 'M4',
            dataIndex: 'm4',
            key: 'm4',
            // align: 'center',
            className: 'table_color_bule',
            render: (a: { amount: number, roi: number, add: number, mult: number }) => {
                if (a?.amount) {
                    return <div className={style.dbox}>
                        <span style={{ color: '#0f538a', fontWeight: 600 }}>充：<span><Statistic value={a?.amount || 0} valueStyle={{ color: '#0f538a', fontWeight: 600 }} /></span></span>
                        <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>增：<span>{(a?.add * 100)?.toFixed(2)}%</span></span>
                        <span style={{ color: '#ff5722', fontWeight: 600 }}>回：<span>{(a?.roi * 100)?.toFixed(2)}%</span></span>
                        <span style={{ color: '#d81b60', fontWeight: 600 }}>倍：<span>{a?.mult}</span></span>
                    </div>
                }
                return '--'
            },
            width: 130,
        },
        {
            title: 'M5',
            dataIndex: 'm5',
            key: 'm5',
            // align: 'center',
            className: 'table_color_bule',
            render: (a: { amount: number, roi: number, add: number, mult: number }) => {
                if (a?.amount) {
                    return <div className={style.dbox}>
                        <span style={{ color: '#0f538a', fontWeight: 600 }}>充：<span><Statistic value={a?.amount || 0} valueStyle={{ color: '#0f538a', fontWeight: 600 }} /></span></span>
                        <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>增：<span>{(a?.add * 100)?.toFixed(2)}%</span></span>
                        <span style={{ color: '#ff5722', fontWeight: 600 }}>回：<span>{(a?.roi * 100)?.toFixed(2)}%</span></span>
                        <span style={{ color: '#d81b60', fontWeight: 600 }}>倍：<span>{a?.mult}</span></span>
                    </div>
                }
                return '--'
            },
            width: 130,
        },
    ]
    return newArr
}
export { columns }