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


function columns12(onDetail: (data: any) => void): { label: string, fieldSHow?: { label: string, saveField: string, defaultValue: any[], data: any[] }, data: any[] }[] {

    return [
        {
            label: '订单明细',
            data: [
                {
                    title: '日期（订单创建日期）', dataIndex: 'day1', label: '订单明细', align: 'center', width: 85, default: 1,
                    render: (a: string, b: any) => (<WidthEllipsis value={b?.day} />)
                },
                {
                    title: '商户订单号ID', dataIndex: 'orderId', label: '订单明细', align: 'center', width: 120, default: 2,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: 'CP订单号', dataIndex: 'cpOrderId', label: '订单明细', align: 'center', width: 130, default: 3,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '第三方支付订单号', dataIndex: 'merchantOrderNo', label: '订单明细', align: 'center', width: 85, default: 4,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '玩家ID', dataIndex: 'gameUserId', label: '订单明细', align: 'center', width: 65, default: 5,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '玩家账号', dataIndex: 'username', label: '订单明细', align: 'center', width: 95, default: 6,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '玩家注册时间', dataIndex: 'regTime', label: '订单明细', align: 'center', width: 135, default: 7, sorter: true,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '玩家注册渠道', dataIndex: 'agentName', label: '订单明细', align: 'center', width: 70, default: 8,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '玩家注册游戏', dataIndex: 'gameName', label: '订单明细', align: 'center', width: 70, default: 9,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: 'CP名称', dataIndex: 'cpName', label: '订单明细', align: 'center', width: 95, default: 10,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '玩家注册游戏应用类型', dataIndex: 'classify', label: '订单明细', align: 'center', width: 80, default: 11,
                    render: (a: string) => (<span>{gameClassifyEnum[a]}</span>)
                },
                {
                    title: '归因投放人员', dataIndex: 'zxPitcherName', label: '订单明细', align: 'center', width: 65, default: 12,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                // {
                //     title: '归因推广账号', dataIndex: 'accountId', label: '订单明细', align: 'center', width: 80, default: 13,
                //     render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                // },
                // {
                //     title: '归因媒体', dataIndex: 'accountType', label: '订单明细', align: 'center', width: 70, default: 14,
                //     render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                // },
                // {
                //     title: '归因广告', dataIndex: 'adId', label: '订单明细', align: 'center', width: 70, default: 15,
                //     render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                // },
                {
                    title: '玩家充值游戏', dataIndex: 'orderGameName', label: '订单明细', align: 'center', width: 70, default: 13,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '玩家充值游戏应用类型', dataIndex: 'orderGameClassify', label: '订单明细', align: 'center', width: 80, default: 14,
                    render: (a: string, b: any) => (<WidthEllipsis value={gameClassifyEnum[a]} />)
                },
                {
                    title: '充值产品名称', dataIndex: 'productName', label: '订单明细', align: 'center', width: 85, default: 15,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '订单金额', dataIndex: 'amount', label: '订单明细', align: 'center', width: 95, default: 16, sorter: true,
                    render: (a: any, b: any) => <Statistic value={a || 0} valueStyle={b?.day === '总计' ? { color: 'red' } : {}} precision={2} />
                },
                {
                    title: '订单实付金额', dataIndex: 'realAmount', label: '订单明细', align: 'center', width: 95, default: 17, sorter: true,
                    render: (a: any, b: any) => <Statistic value={a || 0} valueStyle={b?.day === '总计' ? { color: 'red' } : {}} precision={2} />
                },
                {
                    title: '购买商品', dataIndex: 'productName', label: '订单明细', align: 'center', width: 95, default: 18,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '支付方式', dataIndex: 'payway', label: '订单明细', align: 'center', width: 65, default: 19,
                    render: (a: string, b: any) => (<WidthEllipsis value={PayType[a]} />)
                },
                {
                    title: '支付场景', dataIndex: 'payScene', label: '订单明细', align: 'center', width: 95, default: 20,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '收款账户', dataIndex: 'payAccountId', label: '订单明细', align: 'center', width: 95, default: 21,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '游戏区服', dataIndex: 'serverName', label: '订单明细', align: 'center', width: 85, default: 22,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '游戏角色', dataIndex: 'roleName', label: '订单明细', align: 'center', width: 85, default: 23,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '角色等级', dataIndex: 'roleLevel', label: '订单明细', align: 'center', width: 50, default: 24,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '角色VIP', dataIndex: 'roleVip', label: '订单明细', align: 'center', width: 45, default: 25,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '操作系统', dataIndex: 'os', label: '订单明细', align: 'center', width: 65, default: 26,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '是否切量', dataIndex: 'orderIsSwitch', label: '订单明细', align: 'center', width: 45, default: 27,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '下单时间', dataIndex: 'orderCreateTime', label: '订单明细', align: 'center', width: 135, default: 28, sorter: true,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '支付时间', dataIndex: 'payTime', label: '订单明细', align: 'center', width: 135, default: 29, sorter: true,
                    render: (a: string, b: any) => (<WidthEllipsis value={a} />)
                },
                {
                    title: '注册充值时间差',
                    dataIndex: 'regPayTimeDiff',
                    align: 'center',
                    width: 140,
                    default: 30,
                    render: (a: string, b: any) => {
                        if (b?.payTime) {
                            let diff = new Date(b.payTime).getTime() - new Date(b.regTime).getTime()
                            function secondsToDhms(seconds: any) {
                                const days = Math.floor(seconds / (3600 * 24));
                                const hours = Math.floor((seconds % (3600 * 24)) / 3600);
                                const minutes = Math.floor((seconds % 3600) / 60);
                                const remainingSeconds = seconds % 60;
                                return `${days ? days + "天" : ''}${hours ? hours + "小时" : ''}${minutes ? minutes + "分" : ''}${remainingSeconds ? remainingSeconds + "秒" : ''}`
                            }
                            return diff ? secondsToDhms(diff / 1000) : '--'
                        } else {
                            return '--'
                        }
                    }
                },
                {
                    title: '最近充值时间距今',
                    dataIndex: 'nowPayTimeDiff',
                    align: 'center',
                    width: 135,
                    default: 31,
                    render: (a: string, b: any) => {
                        if (b?.payTime) {
                            let diff = new Date().getTime() - new Date(b.payTime).getTime()
                            function secondsToDhms(seconds: any) {
                                const days = Math.floor(seconds / (3600 * 24));
                                const hours = Math.floor((seconds % (3600 * 24)) / 3600);
                                const minutes = Math.floor((seconds % 3600) / 60);
                                const remainingSeconds = seconds % 60;
                                return `${days ? days + "天" : ''}${hours ? hours + "小时" : ''}${minutes ? minutes + "分" : ''}${remainingSeconds ? remainingSeconds.toFixed(0) + "秒" : ''}`
                            }
                            return diff ? secondsToDhms(diff / 1000) : '--'
                        } else {
                            return '--'
                        }
                    }
                },
                {
                    title: '支付状态', dataIndex: 'orderStatus', label: '订单明细', align: 'center', width: 85, default: 32,
                    render: (a: string, b: any) => (<WidthEllipsis value={PayStatus[a]} />)
                },
                {
                    title: '是否首充', dataIndex: 'isFirstRecharge', label: '订单明细', align: 'center', width: 45, default: 33,
                    render: (a: any, b: any) => {
                        if (b?.day !== '总计') {
                            return a == 1 ? '是' : '否'
                        }
                        return '--'
                    }
                },
                // {
                //     title: '操作', 
                //     dataIndex: 'cz', 
                //     label: '订单明细', 
                //     align: 'center', 
                //     width: 70, 
                //     default: 34,
                //     render: (a: any, b: any) => {
                //         if (b?.day !== '总计') {
                //             return <a onClick={() => onDetail(b)}>订单详情</a>
                //         }
                //         return '--'

                //     }
                // }
            ]
        },
    ]
}

export default columns12