import WidthEllipsis from "@/components/widthEllipsis"
import { CheckCircleOutlined, EyeOutlined, StopOutlined, SwapOutlined } from "@ant-design/icons";
import { Badge, Col, Popconfirm, Row, Statistic } from "antd"
import React from "react"

function columns12(lookHandle: (data: any) => void, exportH5: (data: any) => void, interdictionHandle: (userId: number, status: number) => void) {

    let newArr: { label: string, data: any[] }[] = [
        {
            label: '玩家列表',
            data: [
                { title: '玩家ID', dataIndex: 'id', label: '玩家列表', align: 'center', width: 55 },
                { title: '玩家账号', dataIndex: 'username', label: '玩家列表', align: 'center', width: 120, default: 1, render: (a: string, b: any) => (<WidthEllipsis isCopy value={a} />) },
                { title: '最近游戏角色', dataIndex: 'lastGameRoleName', label: '玩家列表', align: 'center', width: 110, default: 2, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '玩家昵称', dataIndex: 'nickname', label: '玩家列表', align: 'center', width: 120, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '玩家注册IP', dataIndex: 'regIp', label: '玩家列表', align: 'center', width: 100, default: 3, render: (a: string, b: any) => (<WidthEllipsis isCopy value={a} />) },
                { title: '玩家注册时间', dataIndex: 'createTime', label: '玩家列表', align: 'center', width: 140, default: 4, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '注册渠道', dataIndex: 'agentName', label: '玩家列表', align: 'center', width: 120, default: 5, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: 'CP名称', dataIndex: 'cpName', label: '玩家列表', align: 'center', width: 70, default: 6, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '注册游戏', dataIndex: 'gameName', label: '玩家列表', align: 'center', width: 80, default: 7, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '注册游戏应用类型', dataIndex: 'gameCategoryName', label: '玩家列表', align: 'center', width: 80, default: 8, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '归因投放人员', dataIndex: 'pitcherName', label: '玩家列表', align: 'center', width: 60, default: 9, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '归因推广账号', dataIndex: 'accountId', label: '玩家列表', align: 'center', width: 75, default: 10, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '关联游戏名称', dataIndex: 'relationGameName', label: '玩家列表', align: 'center', width: 80, default: 11, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '关联用户ID', dataIndex: 'relationUserId', label: '玩家列表', align: 'center', width: 80, default: 12, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '关联建立时间', dataIndex: 'relationCreateTime', label: '玩家列表', align: 'center', width: 140, default: 13, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '分享用户ID', dataIndex: 'shareUserId', label: '玩家列表', align: 'center', width: 80, default: 14, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '绑定手机', dataIndex: 'mobile', label: '玩家列表', align: 'center', width: 90, default: 15, render: (a: string, b: any) => (<WidthEllipsis value={a || '--'} />) },
                { title: '充值金额', dataIndex: 'rechargeMoney', label: '玩家列表', align: 'center', width: 80, default: 16, render: (a: string, b: any) => (<Statistic value={a || 0} />) },
                { title: '充值次数', dataIndex: 'rechargeCount', label: '玩家列表', align: 'center', width: 45, default: 17, render: (a: string, b: any) => (<Statistic value={a || 0} />) },
                { title: '创角数', dataIndex: 'roleCount', label: '玩家列表', align: 'center', width: 45, default: 18, render: (a: string, b: any) => (<Statistic value={a || 0} />) },
                { title: '最近登录时间', dataIndex: 'updateTime', label: '玩家列表', align: 'center', width: 140, default: 19, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                { title: '最近充值时间', dataIndex: 'lastRechargeTime', label: '玩家列表', align: 'center', width: 140, default: 20, render: (a: string, b: any) => (<WidthEllipsis value={a} />) },
                {
                    title: '注册充值时间差',
                    dataIndex: 'regPayTimeDiff',
                    align: 'center',
                    label: '玩家列表',
                    width: 140,
                    default: 21,
                    render: (a: string, b: any) => {
                        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 a ? <WidthEllipsis value={secondsToDhms(a)} /> : '--'
                    }
                },
                {
                    title: '玩家状态', dataIndex: 'status', label: '玩家列表', align: 'center', width: 70, default: 22,
                    render: (a: any) => {
                        return ({ '3': <Badge status="error" text="冻结" />, '2': <Badge status="success" text="正常" />, '1': <Badge status="warning" text="试玩" /> } as any)[a]
                    }
                },
                { title: '玩家最新染色时间', dataIndex: 'userLastRegTime', label: '玩家列表', align: 'center', width: 140, render: (a: string) => (<WidthEllipsis value={a} />) },
                { title: '玩家最新染色渠道ID', dataIndex: 'userLastRegAgentId', label: '玩家列表', align: 'center', width: 75 },
                { title: '玩家最新染色渠道名字', dataIndex: 'userLastAgentName', label: '玩家列表', align: 'center', width: 110, render: (a: string) => (<WidthEllipsis value={a} />) },
                { title: '玩家最新染色归因投手', dataIndex: 'userLastPitcherName', label: '玩家列表', align: 'center', width: 80, render: (a: string) => (<WidthEllipsis value={a} />) },
            ]
        },
        {
            label: '操作',
            data: [
                {
                    title: '操作',
                    dataIndex: 'cz',
                    align: 'center',
                    width: 155,
                    label: '操作',
                    default: 23,
                    render: (a: string, b: any) => {
                        return <Row justify='center' gutter={[10, 0]}>
                            {b?.gameCategoryId === 6 && <Col><a style={{ fontSize: "12px" }} onClick={() => { exportH5(b) }}><SwapOutlined /> 转端</a></Col>}
                            <Col><a style={{ fontSize: "12px" }} onClick={() => { lookHandle(b.id) }}><EyeOutlined /> 查看</a></Col>
                            <Col>
                                <Popconfirm
                                    title={(b?.status == '1' || b?.status == '2') ? `确定封禁?` : `确定解封?`}
                                    onConfirm={() => { interdictionHandle(b?.id, (b?.status == '1' || b?.status == '2') ? 1 : 0) }}
                                    okText="是"
                                    cancelText="否"
                                >
                                    <a style={{ fontSize: "12px", color: (b?.status == '1' || b?.status == '2') ? 'red' : '#52c41a' }}> {(b?.status == '1' || b?.status == '2') ? <><StopOutlined /> 封禁</> : <><CheckCircleOutlined /> 解封</>}</a>
                                </Popconfirm>
                            </Col>
                        </Row>
                    }
                }
            ]
        }
    ]

    return newArr
}

export default columns12