import { ColumnsType } from "antd/lib/table";
import React from "react";
import AstraSupportHour from "./astraSupport‌Hour";
import { Space, Statistic } from "antd";
import AstraGroupHourEle from "./astraGroupHourEle";
import AstraGroupIndexEle from "./astraGroupIndexEle";
import DoubleDelDetails from "./doubleDelDetails";

/** 客服号加粉 */
export const CorpUserDayListTableConfig = (): ColumnsType<never> => {

    return [
        {
            title: '日期',
            dataIndex: 'day',
            key: 'day',
            width: 80,
            ellipsis: true,
            align: 'center',
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: '企业名称',
            dataIndex: 'corpName',
            key: 'corpName',
            width: 100,
            ellipsis: true,
            render(value) {
                return <span style={{ fontSize: 12 }}>{value || '--'}</span>
            },
        },
        {
            title: '企业ID',
            dataIndex: 'corpId',
            key: 'corpId',
            width: 180,
            ellipsis: true,
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: '企业用户名称',
            dataIndex: 'corpUserName',
            key: 'corpUserName',
            width: 100,
            ellipsis: true,
            render(value) {
                return <span style={{ fontSize: 12 }}>{value || '--'}</span>
            },
        },
        {
            title: '企业用户ID',
            dataIndex: 'corpUserId',
            key: 'corpUserId',
            width: 100,
            ellipsis: true,
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: '客服号当前所在部门名称',
            dataIndex: 'localCorpUserDepartment',
            key: 'localCorpUserDepartment',
            width: 120,
            ellipsis: true,
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: '新增用户数',
            dataIndex: 'addUserCount',
            key: 'addUserCount',
            width: 100,
            align: 'right',
            sorter: true,
            render(value) {
                return <span style={{ fontSize: 12, color: (value >= 60 && value < 100) ? 'orange' : value > 100 ? 'red' : '#000000D9' }}>{value}</span>
            },
        },
        {
            title: '退出人数',
            dataIndex: 'outUserCount',
            key: 'outUserCount',
            width: 100,
            align: 'right',
            sorter: true,
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: '当前粉丝总数',
            dataIndex: 'corpExternalUserCount',
            key: 'corpExternalUserCount',
            width: 100,
            align: 'right',
            sorter: true,
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: 'dn双删详情',
            dataIndex: 'dnOutUserCount',
            key: 'dnOutUserCount',
            width: 100,
            align: 'center',
            render(value, record: any) {
                return value && Object.keys(value).length > 0 ? <DoubleDelDetails
                    dnOutUserCount={value}
                    day={record.day}
                    corpName={record.corpName}
                    corpUserName={record.corpUserName}
                /> : '--'
            },
        },
        {
            title: '数据更新时间',
            dataIndex: 'dataTime',
            key: 'dataTime',
            width: 140,
            ellipsis: true,
            align: 'center',
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: '操作',
            dataIndex: 'cz',
            key: 'cz',
            width: 210,
            ellipsis: true,
            render(_, record: any) {
                return <AstraSupportHour
                    corpName={record.corpName}
                    corpUserName={record.corpUserName}
                    data={{
                        corpId: record.corpId,
                        corpUserId: record.corpUserId,
                        day: record.day
                    }}
                />
            },
        }
    ]
}


/** 客服组加粉 */
export const LocalCsgroupDayListTableConfig = (): ColumnsType<never> => {

    return [
        {
            title: '日期',
            dataIndex: 'day',
            key: 'day',
            width: 80,
            ellipsis: true,
            align: 'center',
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: '企业名称',
            dataIndex: 'corpName',
            key: 'corpName',
            width: 100,
            ellipsis: true,
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: '本地客服组名称',
            dataIndex: 'localCsgroupName',
            key: 'localCsgroupName',
            width: 100,
            ellipsis: true,
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: '本地客服组ID',
            dataIndex: 'localCsgroupId',
            key: 'localCsgroupId',
            width: 75,
            ellipsis: true,
            align: 'center',
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },

        {
            title: '消耗',
            dataIndex: 'cost',
            key: 'cost',
            width: 100,
            align: 'right',
            render(value) {
                return <Statistic value={value || 0} />
            },
        },
        {
            title: '加粉次数(广告)',
            dataIndex: 'scanFollowCount',
            key: 'scanFollowCount',
            width: 100,
            align: 'right',
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: '加粉人数(广告)',
            dataIndex: 'scanFollowUserCount',
            key: 'scanFollowUserCount',
            width: 100,
            align: 'right',
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: '加粉人数',
            dataIndex: 'addUserCount',
            key: 'addUserCount',
            width: 100,
            align: 'right',
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: '数据更新时间',
            dataIndex: 'dataTime',
            key: 'dataTime',
            width: 140,
            ellipsis: true,
            align: 'center',
            render(value) {
                return <span style={{ fontSize: 12 }}>{value}</span>
            },
        },
        {
            title: '操作',
            dataIndex: 'cz',
            key: 'cz',
            width: 250,
            ellipsis: true,
            render(_, record: any) {
                return <Space>
                    <AstraGroupHourEle
                        localCsgroupName={record.localCsgroupName}
                        data={{
                            day: record.day,
                            localCsgroupId: record.localCsgroupId
                        }}
                    />
                    <AstraGroupIndexEle
                        localCsgroupName={record.localCsgroupName}
                        data={{
                            day: record.day,
                            localCsgroupId: record.localCsgroupId
                        }}
                    />
                </Space>
            }
        }
    ]
}