import useFetch from '@/Hook/useFetch';
import { request } from 'umi';
import { api } from '@/services/api'
export interface Params {
    pitcher?: string,//投手
    pitcher_id?: number, // 投手ID
    start?: string,//开始时间
    end?: string,//结束时间
    date_range?: string,//过去N天
    page?: number,//页数
    page_size?: number,//一页几个
    order_by?: string,//排序字段
    order?: string,//asc /desc
    user_id?: number, //
    name?: string,
    cost_time_start?: string, //消耗开始时间（格式：2021-10-11）
    cost_time_end?: string, //  消耗结束时间
    order_time_start?: string, // 订单开始时间（格式：2021-10-11）
    order_time_end?: string, // 订单结束时间
    channel?: string[],  // 公众号数组
    cost_year?: string,  // 消耗所在年（格式：2021）
    order_month?: string // 订单所在月份  （格式：2021-11）
}


/**个人概览 */
export async function overview(params: Params) {
    return useFetch({ url: '/data/pitcher_panel/overview', params, method: 'POST' })
}
/**日期汇总 */
export async function daily(params: Params) {
    return useFetch({ url: '/data/pitcher_panel/daily', params, method: 'POST', excelName: '日期汇总' })
}
/**公众号汇总*/
export async function channe(params: Params) {
    return useFetch({ url: '/data/pitcher_panel/channel', params, method: 'POST', excelName: '公众号汇总' })
}
/**广告投放数据*/
export async function channelOverview(params: Params) {
    return useFetch({ url: '/data/channel_stat/overview', params, method: 'POST', excelName: '广告投放数据' })
}
/**今日消耗排行榜*/
export async function bookRank(params: Params) {
    return useFetch({ url: '/data/book/rank', params, method: 'POST', excelName: '今日消耗排行榜' })
}
/**公众号7日复重趋势*/
export async function channelAgainOrderTrend(params: Params) {
    return useFetch({ url: '/data/channel_stat/again_order_trend', params, method: 'POST', excelName: '公众号7日复重趋势' })
}
/**公众号付费粉丝激活数据 */
export async function channelActive(params: Params) {
    return useFetch({ url: '/data/channel_stat/active', params, method: 'POST', excelName: '公众号付费粉丝激活数据' })
}
/**公众号付费趋势表 */
export async function channelOrderTrend(params: Params) {
    return useFetch({ url: '/data/channel_stat/order_trend', params, method: 'POST', excelName: '公众号付费趋势表' })
}
/**公众号付费趋势（含赔付金） */
export async function channelOrderTrendPay(params: Params) {
    return useFetch({ url: '/data/channel_stat/order_trend/pay', params, method: 'POST', excelName: '公众号付费趋势（含赔付金）' })
}
/**设置赔付金 */
export async function setPayApi(params: { date: string, channel: string, pay: number }) {
    return useFetch({ url: '/data/channel_stat/order_trend/pay/pay_cost', params, method: 'POST' })
}

/**公众号总数据 */
export async function channelStatChannel(params: Params) {
    return useFetch({ url: '/data/channel_stat/channel', params, method: 'POST', excelName: '公众号总数据' })
}
/**公众号回收查询 */
export async function getOsoRoiApi(params: Params) {
    return useFetch({ url: '/data/channel_stat/order_status_optional/roi', params, method: 'POST', excelName: '公众号回收查询' })
}
/**投手个人付费趋势 */
export async function pitcherTrend(params: Params) {
    return useFetch({ url: '/data/pitcher/trend', params, method: 'POST', excelName: '投手个人付费趋势' })
}
/**投手回收查询 */
export async function recoveryQueryapi(params: Params) {
    return useFetch({ url: '/data/pitcher_stat/order_status_optional/roi', params, method: 'POST', excelName: '投手回收查询' })
}
/**小说付费趋势 */
export async function bookTrend(params: Params) {
    return useFetch({ url: '/data/book/trend', params, method: 'POST', excelName: '小说付费趋势' })
}
/**小说总数据 */
export async function bookOverview(params: Params) {
    return useFetch({ url: '/data/book/overview', params, method: 'POST', excelName: '小说总数据' })
}
/**投手总数据 */
export async function pitcherOverview(params: Params) {
    return useFetch({ url: '/data/pitcher/overview', params, method: 'POST', excelName: '投手总数据' })
}

/**充值历史 */
export async function getRechargeHisApi(params: Params) {
    return useFetch({ url: '/data/channel_stat/order_status_optional', params, method: 'POST', excelName: '充值历史' })
}
/**充值年 */
export async function getRechargeHisYaerApi(params: Params) {
    return useFetch({ url: '/data/channel_stat/order_status_year', params, method: 'POST', excelName: '充值历史(年)' })
}


/** 整体概况*/
export async function bossSummary(params: Params) {
    return useFetch({ url: '/data/boss_panel/summary', params, method: 'POST', excelName: '整体概况' })
}
/**素材库 */
export async function imageRank(params: Params) {
    return useFetch({ url: '/data/image/rank', params, method: 'POST', excelName: '素材消耗排行' })
}
/**素材消耗排行榜 */
export async function ad_rank(params: Params) {
    return useFetch({ url: '/data/advertisement/ad_rank', params, method: 'POST', excelName: '素材消耗排行榜' })
}
/**投手投放号 */
export async function pitcher_channel(params: Params) {
    return useFetch({ url: '/data/pitcher/channel', params, method: 'POST', excelName: '投手投放号' })
}
/**验证token保持登录 */
export async function refresh() {
    return request(api + '/refresh', {
        method: 'PUT',
    });
}

/**搜索公众号 */
export async function getAccApi(params: Params) {
    return useFetch({ url: '/operate/channel_group/get_channel', params, method: 'POST' })
}
/**获取拥有用户 */
export async function getUserApi(params: Params) {
    return useFetch({ url: '/operate/channel_group/get_pitcher', params, method: 'POST' })
}
/**公众号用户充值查询 */
export async function channel_analysis_select(params: Params) {
    return useFetch({ url: '/data/analysis/channel_analysis_select', params, method: 'POST', excelName: '公众号用户充值查询' })
}
/**公众号用户充值查询详情 */
export async function channel_analysis_select_daily(params: Params) {
    return useFetch({ url: '/data/analysis/channel_analysis_select_daily', params, method: 'POST', excelName: '公众号用户充值查询' })
}



/**========================投放云=========================== */
/**列表*/
export async function data_list(params: Params) {
    let { name, ...param } = params
    return request(api + `/ads/dataMaterial/${name}`, {
        method: 'POST',
        data: param,
    }).then((res) => res.data)
}
/**标签*/
export async function data_label(params: { id: any, labelIds: any, name: 'tagIdea' | 'tagMedia' | 'tagContent' }) {
    return request(api + `/ads/dataMaterial/${params?.name}/${params?.id}/${params?.labelIds}`, {
        method: 'PUT',
    })
}
/**收藏 */
export async function collects_data(params: { contentIds: string, type: number, name: 'ideaCollect' | 'mediaCollect' | 'contentCollect', collect: boolean }) {
    return request(api + `/ads/dataMaterial/${params?.name}/${params?.contentIds}/${params?.collect}`, {
        method: 'PUT',
    })
}