import { gameClassifyEnum } from "@/components/QueryForm/const"
import WidthEllipsis from "@/components/widthEllipsis"
import { Statistic } from "antd"
import React from "react"

function columns12(gameType: any) {

    let defaultStart = 19
    let index = 1
    const roiC = Array(29).fill('').map((_item: string) => {
        let data = {
            title: `${index + 1}日ROI`,
            dataIndex: `roiDay${index + 1}`,
            label: '付费数据',
            align: 'center',
            width: 80,
            sorter: true,
            render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
        }
        if (index < 7) {
            data['default'] = defaultStart + index
        }
        index++;
        return data
    })

    let newArr: { label: string, data: any[] }[] = [
        {
            label: '推广账号信息',
            data: [
                {
                    title: '推广账号ID', dataIndex: 'accountId', key: 'accountId', label: '推广账号信息', align: 'center', width: 80, default: 1,
                    render: (a: string, b: any) => {
                        if (b?.accountId === '总计') {
                            return <span>总计</span>
                        }
                        return <WidthEllipsis isCopy value={a} />
                    }
                },
                {
                    title: '投放渠道', dataIndex: 'agentName', key: 'agentName', label: '推广账号信息', align: 'center', width: 70, default: 2,
                    render: (a: string, b: any) => {
                        if (b?.accountId === '总计') {
                            return <span>--</span>
                        }
                        return <WidthEllipsis isCopy value={a} />
                    }
                },
            ]
        },
        {
            label: '业务人员信息',
            data: [
                { title: '投手', dataIndex: 'sysUserName', key: 'sysUserName', label: '业务人员信息', align: 'center', width: 70, default: 3, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
            ]
        },
        {
            label: '推广内容信息',
            data: [
                { title: '推广游戏CP名称', dataIndex: 'cpName', key: 'cpName', label: '推广内容信息', align: 'center', width: 70, default: 4, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '推广游戏名称', dataIndex: 'gameName', key: 'gameName', label: '推广内容信息', align: 'center', width: 70, default: 5, render: (a: string, b: any) => (<WidthEllipsis isCopy value={a} />) },
                {
                    title: '推广游戏应用类型', dataIndex: 'gameType', key: 'gameType', label: '推广内容信息', align: 'center', width: 90, default: 6,
                    render: (a: string) => (<span>{gameClassifyEnum[a]}</span>)
                },
            ]
        },
        {
            label: '消耗',
            data: [
                { title: '消耗', dataIndex: 'cost', key: 'cost', label: '消耗', align: 'center', width: 100, default: 7, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '推广计划数量', dataIndex: 'adPlanCount', key: 'adPlanCount', label: '消耗', align: 'center', width: 90, default: 8, sorter: true },
            ]
        },
        {
            label: '广告曝光数据',
            data: [
                { title: '曝光量', dataIndex: 'viewCount', label: '广告曝光数据', align: 'center', width: 70, default: 9, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '点击量', dataIndex: 'clickCount', label: '广告曝光数据', align: 'center', width: 70, default: 10, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                {
                    title: '点击率', dataIndex: 'clickRate', label: '广告曝光数据', align: 'center', width: 70, sorter: true, default: 11,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                { title: '转化量', dataIndex: 'convertCount', label: '广告曝光数据', align: 'center', width: 70, default: 12, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                {
                    title: '转化率', dataIndex: 'convertRate', label: '广告曝光数据', align: 'center', width: 70, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                { title: '平均转化成本', dataIndex: 'avgConvertCost', label: '广告曝光数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '深度转化量', dataIndex: 'deepConvertCount', label: '广告曝光数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '深度转化成本', dataIndex: 'deepConvertCost', label: '广告曝光数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                {
                    title: '深度转化率', dataIndex: 'deepConvertRate', label: '广告曝光数据', align: 'center', width: 70, default: 13, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                { title: '千次曝光成本', dataIndex: 'thousandViewCost', label: '广告曝光数据', align: 'center', width: 70, default: 14, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '平均点击均价', dataIndex: 'avgClickCost', label: '广告曝光数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '应用下载开始量', dataIndex: 'appDownloadCount', label: '广告曝光数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '应用下载开始成本', dataIndex: 'appDownloadCost', label: '广告曝光数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                {
                    title: '应用下载开始率', dataIndex: 'appDownloadRate', label: '广告曝光数据', align: 'center', width: 70, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                { title: '应用下载完成量', dataIndex: 'downloadFinish', label: '广告曝光数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '应用下载完成成本', dataIndex: 'downloadFinishCost', label: '广告曝光数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                {
                    title: '应用下载完成率', dataIndex: 'downloadFinishRate', label: '广告曝光数据', align: 'center', width: 70, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                { title: '应用安装量', dataIndex: 'appInstallCount', label: '广告曝光数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '应用安装成本', dataIndex: 'appInstallCost', label: '广告曝光数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                {
                    title: '应用安装完成率', dataIndex: 'appInstallRate', label: '广告曝光数据', align: 'center', width: 70, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                { title: '应用激活量', dataIndex: 'appActiveCount', label: '广告曝光数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '应用激活成本', dataIndex: 'appActiveCost', label: '广告曝光数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                {
                    title: '应用激活率', dataIndex: 'appActiveRate', label: '广告曝光数据', align: 'center', width: 70, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
            ]
        },
        {
            label: '用户数据',
            data: [
                { title: '注册人数', dataIndex: 'regUserCount', label: '用户数据', align: 'center', width: 70, default: 15, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '注册成本', dataIndex: 'regCost', label: '用户数据', align: 'center', width: 70, default: 16, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '首日创角人数', dataIndex: 'firstRoleNum', label: '付费数据', align: 'center', width: 90, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '新用户累计创角人数', dataIndex: 'newUserTotalRoleNum', label: '付费数据', align: 'center', width: 90, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '创角人数', dataIndex: 'roleNum', label: '付费数据', align: 'center', width: 90, render: (a: string) => <Statistic value={a || 0} /> },
            ]
        },
        {
            label: '付费数据',
            data: [
                { title: '新用户充值次数', tips: '消耗时间范围内用户，在充值时间内充值次数统计', dataIndex: 'userRechargeCount', label: '付费数据', align: 'center', width: 80, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '新用户充值人数', tips: '消耗时间范围内用户，在充值时间内充值人数统计', dataIndex: 'userRechargeUser', label: '付费数据', align: 'center', width: 80, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '新用户充值金额', tips: '消耗时间范围内用户，在充值时间内充值金额统计', dataIndex: 'userRechargeMoney', label: '付费数据', align: 'center', width: 80, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '首日新用户充值次数', dataIndex: 'firstUserRechargeCount', label: '付费数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '首日新用户充值人数', dataIndex: 'firstUserRechargeUser', label: '付费数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '首日新用户充值金额', dataIndex: 'firstUserRechargeMoney', label: '付费数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '老用户充值次数', dataIndex: 'oldUserRechargeCount', label: '付费数据', align: 'center', width: 70, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '老用户充值人数', dataIndex: 'oldUserRechargeUser', label: '付费数据', align: 'center', width: 70, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '老用户充值金额', dataIndex: 'oldUserRechargeMoney', label: '付费数据', align: 'center', width: 70, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '账面充值次数', dataIndex: 'showRechargeCount', label: '付费数据', align: 'center', width: 70, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '账面充值人数', dataIndex: 'showRechargeUser', label: '付费数据', align: 'center', width: 70, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '账面充值金额', dataIndex: 'showRechargeMoney', label: '付费数据', align: 'center', width: 70, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '新用户累计充值次数', dataIndex: 'newUserRechargeCount', label: '付费数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '新用户累计充值人数', dataIndex: 'newUserRechargeUser', label: '付费数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                { title: '新用户累计充值金额', dataIndex: 'newUserRechargeMoney', label: '付费数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} /> },
                {
                    title: '首日回收率', dataIndex: 'firstRecoveryRate', label: '付费数据', align: 'center', width: 70, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                {
                    title: '回收率', tips: '回收率=新用户充值金额/实际消耗', dataIndex: 'recoveryRate', label: '付费数据', align: 'center', width: 90, default: 17,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                {
                    title: '至今回收率', tips: '至今回收率=新用户累计充值金额/实际消耗', dataIndex: 'todayRecoveryRate', label: '付费数据', align: 'center', width: 95, default: 18, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                {
                    title: '毛利额', dataIndex: 'grossMargin', label: '付费数据', align: 'center', width: 110, default: 19, sorter: true,
                    render: (a: number) => <Statistic value={a || 0} valueStyle={a > 0 ? { color: 'red' } : {}} />
                },
                ...roiC,
                {
                    title: '60日ROI', dataIndex: 'roiDay60', label: '付费数据', align: 'center', width: 80, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 0.9 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                {
                    title: '90日ROI', dataIndex: 'roiDay90', label: '付费数据', align: 'center', width: 80, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                {
                    title: '180日ROI', dataIndex: 'roiDay180', label: '付费数据', align: 'center', width: 80, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                {
                    title: '1年ROI', dataIndex: 'roiYear1', label: '付费数据', align: 'center', width: 80, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                {
                    title: '总ROI', dataIndex: 'roiTotal', label: '付费数据', align: 'center', width: 80, default: 25, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                {
                    title: '首日付费率', dataIndex: 'firstRechargeRate', label: '付费数据', align: 'center', width: 70, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                {
                    title: '新用户付费率', dataIndex: 'userRechargeRate', label: '付费数据', align: 'center', width: 70,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                {
                    title: '当天付费率', dataIndex: 'todayRechargeRate', label: '付费数据', align: 'center', width: 70, sorter: true,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                { title: '新用户付费比', dataIndex: 'newUserRechargeRatio', label: '付费数据', align: 'center', width: 70, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '首日客单价', dataIndex: 'avgFirstUserRecharge', label: '付费数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '新用户客单价', dataIndex: 'avgUserRecharge', label: '付费数据', align: 'center', width: 70, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '当天客单价', dataIndex: 'avgTodayRecharge', label: '付费数据', align: 'center', width: 70, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '账面客单价', dataIndex: 'avgShowUserRecharge', label: '付费数据', align: 'center', width: 70, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '首日充值成本', dataIndex: 'firstRechargeCost', label: '付费数据', align: 'center', width: 90, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '新用户充值成本', dataIndex: 'userRechargeCost', label: '付费数据', align: 'center', width: 90, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '当天充值成本', dataIndex: 'todayRechargeCost', label: '付费数据', align: 'center', width: 90, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '首日充值次数成本', dataIndex: 'firstRechargeCountCost', label: '付费数据', align: 'center', width: 90, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '老用户充值次数成本', dataIndex: 'oldUserRechargeCountCost', label: '付费数据', align: 'center', width: 90, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '账面充值次数成本', dataIndex: 'showRechargeCountCost', label: '付费数据', align: 'center', width: 90, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '新用户累计充值次数成本', dataIndex: 'newUserRechargeCountCost', label: '付费数据', align: 'center', width: 90, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '新用户充值次数成本', dataIndex: 'userRechargeCountCost', label: '付费数据', align: 'center', width: 90, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                // {
                //     title: '复充率', dataIndex: 'repeatRechargeRate', label: '付费数据', align: 'center', width: 70,
                //     render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                // },
                {
                    title: '新用户复充率', tips: '消耗时间范围内注册用户，在充值时间内重复充值（即用户累计充值次数n≥2)。计算公式：新用户复冲率=新用户复充人数/新用户累计充值人数', dataIndex: 'userRepeatRechargeRate', label: '付费数据', align: 'center', width: 80,
                    render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                },
                // {
                //     title: '当天复充率', dataIndex: 'todayRepeatRechargeRate', label: '付费数据', align: 'center', width: 70, sorter: true,
                //     render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
                // },
                { title: '新增注册ARPPU', dataIndex: 'newRegArpu', label: '付费数据', align: 'center', width: 80, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '首日付费ARPPU', dataIndex: 'firstRechargeArpu', label: '付费数据', align: 'center', width: 80, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '新用户付费ARPPU', dataIndex: 'userRechargeArpu', label: '付费数据', align: 'center', width: 80, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '至今付费ARPPU', dataIndex: 'todayRechargeArpu', label: '付费数据', align: 'center', width: 80, sorter: true, render: (a: string) => <Statistic value={a || 0} precision={2} /> },
                { title: '账面ARPPU', dataIndex: 'showRechargeArpu', label: '付费数据', align: 'center', width: 80, render: (a: string) => <Statistic value={a || 0} precision={2} /> }
            ]
        },
        // {
        //     label: '操作',
        //     data: [
        //         {
        //             title: '操作',
        //             dataIndex: 'cz',
        //             label: '操作',
        //             default: 26,
        //             key: 'cz',
        //             align: 'center',
        //             width: 75,
        //             render: (a: number) => {
        //                 return <a>详情</a>
        //             },
        //         }
        //     ]
        // }
    ]

    return newArr
}

export default columns12