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: { order: number, roi: number, add: number, mult: number }) => {
                if (a?.order) {
                    return <div className={style.dbox}>
                        <span style={{ color: '#2196f3', fontWeight: 600 }}>充：<span><Statistic value={a?.order || 0} valueStyle={{ color: '#2196f3', fontWeight: 600 }} /></span></span>
                        <span style={{ color: '#311b92', 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: 100
        }
    })
    let newArr: ColumnsType<any> = [
        {
            title: '时间',
            dataIndex: 'date',
            key: 'date',
            align: 'center',
            fixed: 'left',
            width: 90,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'date' && props?.sortOrder?.order) || undefined,
        },
        {
            title: '公众号',
            dataIndex: 'channel',
            key: 'channel',
            align: 'center',
            width: 70,
            fixed: 'left',
        },
        {
            title: '投手',
            dataIndex: 'pitcher',
            key: 'pitcher',
            align: 'center',
            width: 50,
            fixed: 'left',
        },
        {
            title: '期数',
            dataIndex: 'stage',
            key: 'stage',
            align: 'center',
            width: 50,
            fixed: 'left',
        },
        {
            title: '主投书',
            dataIndex: 'book',
            key: 'book',
            width: 90,
            align: 'center',
            fixed: 'left',
            ellipsis: true
        },
        {
            title: '首日roi',
            dataIndex: 'first_roi',
            key: 'first_roi',
            width: 70,
            align: 'center',
            fixed: 'left',
            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: '要求首日roi',
            dataIndex: 'require_roi',
            key: 'require_roi',
            align: 'center',
            width: 75,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'require_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: 'require_mult',
            key: 'require_mult',
            align: 'center',
            width: 60,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'require_mult' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '当天消耗',
            dataIndex: 'cost',
            key: 'cost',
            align: 'center',
            width: 110,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'cost' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '当日新用户累计充值',
            dataIndex: 'reg_amount',
            key: 'reg_amount',
            align: 'center',
            width: 110,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'reg_amount' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '首日新用户充值',
            dataIndex: 'first_amount',
            key: 'first_amount',
            align: 'center',
            width: 110,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'first_amount' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return <Statistic value={a || 0} />
            },
        },
        {
            title: '回本率',
            dataIndex: 'roi',
            key: 'roi',
            align: 'center',
            width: 70,
            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: 'expect_profit',
            key: 'expect_profit',
            align: 'center',
            width: 110,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'expect_profit' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return <Statistic value={a || 0} valueStyle={a < 0 ? { color: '#0f990f', fontWeight: 600 } : {}} />
            }
        },
        {
            title: '预期年倍数',
            dataIndex: 'annual_mult',
            key: 'annual_mult',
            align: 'center',
            width: 80,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'annual_mult' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return a
            }
        },
        {
            title: '预期年收益',
            dataIndex: 'annual_expect_profit',
            key: 'annual_expect_profit',
            align: 'center',
            width: 110,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'annual_expect_profit' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return <Statistic value={a || 0} valueStyle={a < 0 ? { color: '#0f990f', fontWeight: 600 } : {}} />
            }
        },
        {
            title: '毛利',
            dataIndex: 'profit',
            key: 'profit',
            align: 'center',
            width: 110,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'profit' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return <Statistic value={a || 0} valueStyle={a < 0 ? { color: '#0f990f', fontWeight: 600 } : {}} />
            }
        },

        {
            title: '新增粉丝数',
            dataIndex: 'new_follow_user',
            key: 'new_follow_user',
            align: 'center',
            width: 90,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'new_follow_user' && props?.sortOrder?.order) || undefined,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '新增粉丝成本',
            dataIndex: 'new_follow_per_cost',
            key: 'new_follow_per_cost',
            align: 'center',
            width: 70,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'new_follow_per_cost' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '充值人数',
            dataIndex: 'order_user',
            key: 'order_user',
            align: 'center',
            width: 90,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'order_user' && props?.sortOrder?.order) || undefined,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '充值次数',
            dataIndex: 'order_count',
            key: 'order_count',
            align: 'center',
            width: 80,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'order_count' && props?.sortOrder?.order) || undefined,
            render: (a: any) => {
                return <Statistic value={a || 0} />
            }
        },
        {
            title: '充值用户成本',
            dataIndex: 'order_user_per_cost',
            key: 'order_user_per_cost',
            align: 'center',
            width: 70,
            sorter: true,
            //sortOrder: (props?.sortOrder?.columnKey === 'order_user_per_cost' && props?.sortOrder?.order) || undefined,
            render: (a: number) => {
                return <Statistic value={a || 0} />
            }
        },
        ...arr,
        {
            title: 'M3',
            dataIndex: 'm3',
            key: 'm3',
            render: (a: { order: number, roi: number, add: number, mult: number }) => {
                if (a?.order) {
                    return <div className={style.dbox}>
                        <span style={{ color: '#2196f3', fontWeight: 600 }}>充：<span><Statistic value={a?.order || 0} valueStyle={{ color: '#2196f3', fontWeight: 600 }} /></span></span>
                        <span style={{ color: '#311b92', 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: 100
        },
        {
            title: 'M4',
            dataIndex: 'm4',
            key: 'm4',
            // align: 'center',
            className: 'table_color_bule',
            render: (a: { order: number, roi: number, add: number, mult: number }) => {
                if (a?.order) {
                    return <div className={style.dbox}>
                        <span style={{ color: '#2196f3', fontWeight: 600 }}>充：<span><Statistic value={a?.order || 0} valueStyle={{ color: '#2196f3', fontWeight: 600 }} /></span></span>
                        <span style={{ color: '#311b92', 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: 100,
        },
        {
            title: 'M5',
            dataIndex: 'm5',
            key: 'm5',
            // align: 'center',
            className: 'table_color_bule',
            render: (a: { order: number, roi: number, add: number, mult: number }) => {
                if (a?.order) {
                    return <div className={style.dbox}>
                        <span style={{ color: '#2196f3', fontWeight: 600 }}>充：<span><Statistic value={a?.order || 0} valueStyle={{ color: '#2196f3', fontWeight: 600 }} /></span></span>
                        <span style={{ color: '#311b92', 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: 100,
        },
    ]
    return newArr
}
export { columns }