import { Space, Statistic, Tooltip } from "antd";
import { AnyObject } from "antd/es/_util/type"
import { ColumnsType } from "antd/es/table"
import { QuestionCircleOutlined } from "@ant-design/icons"


export const CorpExternalUserColumns = (): ColumnsType<AnyObject> => {

    return [
        {
            title: '企业名称',
            dataIndex: 'corpName',
            key: 'corpName',
            ellipsis: true,
            width: 150,
        },
        {
            title: <Space>
                <span>主体净值用户数</span>
                <Tooltip title="非重复人数+重复人数+未识别人数">
                    <QuestionCircleOutlined />
                </Tooltip>
            </Space>,
            dataIndex: 'userCount',
            key: 'userCount',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '未识别人数',
            dataIndex: 'qcUuidNullCount',
            key: 'qcUuidNullCount',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '未识别用户数占比',
            dataIndex: 'qcUuidNullCountRate',
            key: 'qcUuidNullCountRate',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic
                value={text ? text * 100 : 0}
                valueStyle={text > 0.1 ? { color: '#cf1322', fontSize: 12 } : { color: '#3f8600', fontSize: 12 }}
                suffix="%"
                precision={4}
            />
        },
        {
            title: <Space>
                <span>重复总人数</span>
                <Tooltip title="重复(2，3，4，5，5+)">
                    <QuestionCircleOutlined />
                </Tooltip>
            </Space>,
            sorter: true,
            dataIndex: 'gtOneRepeatCountTotal',
            key: 'gtOneRepeatCountTotal',
            align: 'center',
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '重复总人数占比',
            dataIndex: 'gtOneRepeatCountTotalRate',
            key: 'gtOneRepeatCountTotalRate',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic
                value={text ? text * 100 : 0}
                valueStyle={text > 0.2 ? { color: '#cf1322', fontSize: 12 } : { color: '#3f8600', fontSize: 12 }}
                suffix="%"
                precision={4}
            />
        },
        {
            title: '非重人数',
            dataIndex: 'oneRepeatCount',
            key: 'oneRepeatCount',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '非重人数比例',
            dataIndex: 'oneRepeatCountRate',
            key: 'oneRepeatCountRate',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic
                value={text ? text * 100 : 0}
                valueStyle={text > 0.5 ? { color: '#cf1322', fontSize: 12 } : { color: '#3f8600', fontSize: 12 }}
                suffix="%"
                precision={4}
            />
        },
        {
            title: '添加2名客服人数',
            dataIndex: 'twoRepeatCount',
            key: 'twoRepeatCount',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '添加2名客服人数比例',
            dataIndex: 'twoRepeatCountRate',
            key: 'twoRepeatCountRate',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic
                value={text ? text * 100 : 0}
                valueStyle={text > 0.1 ? { color: '#cf1322', fontSize: 12 } : { color: '#3f8600', fontSize: 12 }}
                suffix="%"
                precision={4}
            />
        },
        {
            title: '添加3名客服人数',
            dataIndex: 'threeRepeatCount',
            key: 'threeRepeatCount',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '添加3名客服人数比例',
            dataIndex: 'threeRepeatCountRate',
            key: 'threeRepeatCountRate',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic
                value={text ? text * 100 : 0}
                valueStyle={text > 0.09 ? { color: '#cf1322', fontSize: 12 } : { color: '#3f8600', fontSize: 12 }}
                suffix="%"
                precision={4}
            />
        },
        {
            title: '添加4名客服人数',
            dataIndex: 'fourRepeatCount',
            key: 'fourRepeatCount',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '添加4名客服人数比例',
            dataIndex: 'fourRepeatCountRate',
            key: 'fourRepeatCountRate',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic
                value={text ? text * 100 : 0}
                valueStyle={text > 0.08 ? { color: '#cf1322', fontSize: 12 } : { color: '#3f8600', fontSize: 12 }}
                suffix="%"
                precision={4}
            />
        },
        {
            title: '添加5名客服人数',
            dataIndex: 'fiveRepeatCount',
            key: 'fiveRepeatCount',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '添加5名客服人数比例',
            dataIndex: 'fiveRepeatCountRate',
            key: 'fiveRepeatCountRate',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic
                value={text ? text * 100 : 0}
                valueStyle={text > 0.07 ? { color: '#cf1322', fontSize: 12 } : { color: '#3f8600', fontSize: 12 }}
                suffix="%"
                precision={4}
            />
        },
        {
            title: '添加5名客服以上人数',
            dataIndex: 'gtFiveRepeatCount',
            key: 'gtFiveRepeatCount',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '添加5名客服以上人数比例',
            dataIndex: 'gtFiveRepeatCountRate',
            key: 'gtFiveRepeatCountRate',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic
                value={text ? text * 100 : 0}
                valueStyle={text > 0.06 ? { color: '#cf1322', fontSize: 12 } : { color: '#3f8600', fontSize: 12 }}
                suffix="%"
                precision={4}
            />
        },
    ]
}



export const ExternalUserColumns = (): ColumnsType<AnyObject> => {

    return [
        {
            title: '企业名称',
            dataIndex: 'corpName',
            key: 'corpName',
            ellipsis: true,
            width: 150,
        },
        {
            title: '主体净值用户数',
            dataIndex: 'corpExternalUserCount',
            key: 'corpExternalUserCount',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '已识别用户数',
            dataIndex: 'qcUuidCount',
            key: 'qcUuidCount',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '已识别用户数占比',
            dataIndex: 'qcUuidCountRate',
            key: 'qcUuidCountRate',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic
                value={text ? text * 100 : 0}
                valueStyle={text < 0.5 ? { color: '#cf1322', fontSize: 12 } : { color: '#3f8600', fontSize: 12 }}
                suffix="%"
                precision={4}
            />
        },
        {
            title: '未识别用户数',
            dataIndex: 'qcUuidNullCount',
            key: 'qcUuidNullCount',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '未识别粉用户占比',
            dataIndex: 'qcUuidNullCountRate',
            key: 'qcUuidNullCountRate',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic
                value={text ? text * 100 : 0}
                valueStyle={text > 0.2 ? { color: '#cf1322', fontSize: 12 } : { color: '#3f8600', fontSize: 12 }}
                suffix="%"
                precision={4}
            />
        },
        {
            title: '主体用户在集团占比',
            dataIndex: 'corpExternalUserRate',
            key: 'corpExternalUserRate',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic
                value={text ? text * 100 : 0}
                valueStyle={text > 0.2 ? { color: '#cf1322', fontSize: 12 } : { color: '#3f8600', fontSize: 12 }}
                suffix="%"
                precision={4}
            />
        },
        {
            title: '主体客服号数量',
            dataIndex: 'corpUserCount',
            key: 'corpUserCount',
            align: 'center',
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '主体内重粉数',
            dataIndex: 'corpExternalUserRepeatCount',
            key: 'corpExternalUserRepeatCount',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic value={text || 0} valueStyle={{ fontSize: 12 }} />
        },
        {
            title: '主体内重粉率',
            dataIndex: 'corpExternalUserRepeatRate',
            key: 'corpExternalUserRepeatRate',
            align: 'center',
            sorter: true,
            render: (text: any) => <Statistic
                value={text ? text * 100 : 0}
                valueStyle={text > 0.2 ? { color: '#cf1322', fontSize: 12 } : { color: '#3f8600', fontSize: 12 }}
                suffix="%"
                precision={4}
            />
        },
    ]
}