import { amountPage, amountExport } from '@/services/finance/index';
import { exportData } from '@/utils/func';

import React, { useRef, useEffect, useState } from 'react';
import { useIntl, useAccess } from '@umijs/max';
import { message, Tag, Select, Button } from 'antd';
import { ActionType, PageContainer, ProTable } from '@ant-design/pro-components';
import { usersPage } from '@/services/user/user';




const LogTableList: React.FC = () => {
    const actionRef = useRef<ActionType>();
    const [shopOption, setShopOption] = useState([]);


    const searchShop = async (value) => {
        const { success, data } = await usersPage({
            userName: value
        });
        data.records.map((i) => {
            i.userName = i.userName + ' ' + i.phone
        })
        setShopOption(data.records)
    }

    const columns = [
        {
            "title": "统计日期",
            "dataIndex": "statsDate",
            valueType: 'dateRange',
            search: {
                transform: (value) => {
                    return {
                        startStatsDate: value[0],
                        endStatsDate: value[1],
                    };
                },
            },
            render: (_, record) => {
                return record?.statsDate
            },
        },
        {
            "title": "活动赠送金额",
            "dataIndex": "point2ActivityAmount",
            "valueType": "text",
            "search": false
        },
        {
            "title": "线下充值2",
            "dataIndex": "point2RechargeAmountDown",
            "valueType": "text",
            "search": false
        },
        {
            "title": "线上充值2",
            "dataIndex": "point2RechargeAmountUp",
            "valueType": "text",
            "search": false
        },
        {
            "title": "线下充值1",
            "dataIndex": "point1RechargeAmountDown",
            "valueType": "text",
            "search": false
        },
        {
            "title": "线上充值1",
            "dataIndex": "point1RechargeAmountUp",
            "valueType": "text",
            "search": false
        },
        {
            "title": "提现金额",
            "dataIndex": "point1ExtractAmount",
            "valueType": "text",
            "search": false
        },
        {
            "title": "提现失败金额",
            "dataIndex": "point1ExtractFailAmount",
            "valueType": "text",
            "search": false
        },
        {
            "title": "基础积分-系统留存",
            "dataIndex": "point1Total",
            "valueType": "text",
            "search": false
        },
        {
            "title": "增值积分-系统留存",
            "dataIndex": "point2Total",
            "valueType": "text",
            "search": false
        },
        {
            "title": "用户积分1-按天",
            "dataIndex": "point1Day",
            "valueType": "text",
            "search": false
        },
        {
            "title": "用户积分2-按天",
            "dataIndex": "point2Day",
            "valueType": "text",
            "search": false
        },
        {
            "title": "用户积分1-累计",
            "dataIndex": "point1TotalDay",
            "valueType": "text",
            "search": false
        },
        {
            "title": "用户积分2-累计",
            "dataIndex": "point2TotalDay",
            "valueType": "text",
            "search": false
        },
        {
            "title": "总积分-系统留存",
            "dataIndex": "pointTotal",
            "valueType": "text",
            "search": false
        },
        {
            "title": "总产出",
            "dataIndex": "totalOutput",
            "valueType": "text",
            "search": false
        },
        {
            "title": "每天产出",
            "dataIndex": "totalOutputDay",
            "valueType": "text",
            "search": false
        },
        {
            "title": "积分差额",
            "dataIndex": "pointDifference",
            "valueType": "text",
            "search": false
        },
        {
            "title": "基础积分-订单产出",
            "dataIndex": "orderPoint1",
            "valueType": "text",
            "search": false
        },
        {
            "title": "增值积分-订单产出",
            "dataIndex": "orderPoint2",
            "valueType": "text",
            "search": false
        },
        {
            "title": "总积分-订单产出",
            "dataIndex": "orderPoint",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-微信支付",
            "dataIndex": "validOrderAmountWx",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-支付宝支付",
            "dataIndex": "validOrderAmountZfb",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-积分支付",
            "dataIndex": "validOrderAmountPoint2",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单总金额",
            "dataIndex": "validOrderAmountTotal",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-微信支付数量",
            "dataIndex": "validOrderNumWx",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-支付宝支付数量",
            "dataIndex": "validOrderNumZfb",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-积分支付数量",
            "dataIndex": "validOrderNumPoint2",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-总数量",
            "dataIndex": "validOrderNumTotal",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-微信支付退单",
            "dataIndex": "invalidOrderAmountWx",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-支付宝支付退单",
            "dataIndex": "invalidOrderAmountZfb",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-积分支付退单",
            "dataIndex": "invalidOrderAmountPoint2",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单总金额退单",
            "dataIndex": "invalidOrderAmountTotal",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-微信支付数量退单",
            "dataIndex": "invalidOrderNumWx",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-支付宝支付数量退单",
            "dataIndex": "invalidOrderNumZfb",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-积分支付数量退单",
            "dataIndex": "invalidOrderNumPoint2",
            "valueType": "text",
            "search": false
        },
        {
            "title": "订单-总数量退单",
            "dataIndex": "invalidOrderNumTotal",
            "valueType": "text",
            "search": false
        },
        {
            "title": "充电桩-未交付数量（总数）7kw",
            "dataIndex": "device7NoDeliverNum",
            "valueType": "text",
            "search": false
        },
        {
            "title": "充电桩-已交付数量（总数）7kw",
            "dataIndex": "device7DeliverNum",
            "valueType": "text",
            "search": false
        },
        {
            "title": "充电桩-赠送数量（统计日期）7kw",
            "dataIndex": "device7GiveNum",
            "valueType": "text",
            "search": false
        },
        {
            "title": "充电桩-数量（统计日期）7kw",
            "dataIndex": "device7Num",
            "valueType": "text",
            "search": false
        },
        {
            "title": "充电桩-基础积分冻结7kw",
            "dataIndex": "device7Point1Freeze",
            "valueType": "text",
            "search": false
        },
        {
            "title": "充电桩-增值积分冻结7kw",
            "dataIndex": "device7Point2Freeze",
            "valueType": "text",
            "search": false
        },
        {
            "title": "充电桩-总冻结7kw",
            "dataIndex": "device7PointFreeze",
            "valueType": "text",
            "search": false
        },
        {
            "title": "充电桩-基础积分7kw",
            "dataIndex": "device7Point1",
            "valueType": "text",
            "search": false
        },
        {
            "title": "充电桩-增值积分7kw",
            "dataIndex": "device7Point2",
            "valueType": "text",
            "search": false
        },
        {
            "title": "充电桩-总积分7kw",
            "dataIndex": "device7Point",
            "valueType": "text",
            "search": false
        },
        {
            "title": "充电桩-平均产出积分=总积分/已交付数量7kw",
            "dataIndex": "device7PointAvg",
            "valueType": "text",
            "search": false
        },
        {
            "title": "分账设备数量",
            "dataIndex": "deviceDivideNum",
            "valueType": "text",
            "search": false
        }
    ]
        ;

    return (
        <PageContainer>
            <div style={{ width: '100%', float: 'right' }}>
                <ProTable
                    actionRef={actionRef}
                    rowKey="id"
                    key="logList"
                    search={{
                        labelWidth: 120,
                    }}
                    pagination={{ defaultPageSize: 10 }}
                    scroll={{ x: 6500 }}
                    toolBarRender={() => [
                        <Button type="primary" onClick={async () => {
                            let _res = await amountExport({})
                            exportData(_res, '统计记录')
                        }}>导出</Button>,
                    ]}
                    request={async (params, sorter, filter) => {
                        let { data } = await amountPage(params)
                        return {
                            data: data?.records || [],
                            total: data?.total,
                        };
                    }}
                    columns={columns}
                />
            </div>
        </PageContainer>
    );
};

export default LogTableList;
