import { wrapTreeNode } from "@/utils/format"
import request from "@/utils/request"

// 拿到盘存信息的数据
export async function handleGetCHECKCOMMODITYList(params: any) {
    const data = await request(`/SaleStore/GetCHECKCOMMODITYList`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data.List
}


// 获取进销存统计报表列表
export async function handleGetINSALES_STATISTICList(params: any) {
    const data = await request(`/SaleStore/GetINSALES_STATISTICList`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data.List
}

// 获取进销存统计报表明细
export async function handleGetINSALES_STATISTICDetail(params: any) {
    const data = await request(`/SaleStore/GetINSALES_STATISTICDetail`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data
}


// 商品明细
export async function handleGetGetCOMMODITYDetail(params: any) {
    const data = await request(`/Commodity/GetCOMMODITYDetail`, {
        method: 'GET',
        params: { ...params }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data
}


//获取门店接收信息列表
export async function handleGetRECEIVESERVERPARTList(params: any) {
    const data = await request(`/SaleStore/GetRECEIVESERVERPARTList`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data.List
}


//获取门店接收信息明细
export async function handleGetRECEIVESERVERPARTDetail(params: any) {
    const data = await request(`/SaleStore/GetRECEIVESERVERPARTDetail`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data
}

//获取门店入库详情列表
export async function handleGetRECEIVEDETAILSERVERPARTList(params: any) {
    const data = await request(`/SaleStore/GetRECEIVEDETAILSERVERPARTList`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data.List
}

// 查询门店实时库存数据
export async function handleGetInventoryList(params: any) {
    const data = await request(`/SaleStore/GetInventoryList`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data
}


// 获取进销存一品多码报表
export async function handleGetMultiCodeStatisticsList(params: any) {
    const data = await request(`/SaleStore/GetMultiCodeStatisticsList`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data.List
}


// 查询门店实时库存数据
export async function handleGetShopInventoryList(params: any) {
    const data = await request(`/SaleStore/GetShopInventoryList`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data.List
}


// 获取进销存类别报表
export async function handleGetTypeStatisticsList(params: any) {
    const data = await request(`/SaleStore/GetTypeStatisticsList`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data.List
}

// 获取项目流程表列表
export async function handleGetSALESTOREPROINSTList(params: any) {
    const data = await request(`/SaleStore/GetSALESTOREPROINSTList`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data.List
}


// 获取退货表列表
export async function handleGetBACKCOMMODITYList(params: any) {
    const data = await request(`/SaleStore/GetBACKCOMMODITYList`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data.List
}


// 获取商户信息表列表
export async function handleGetMERCHANTSList(params: any) {
    const data = await request(`/SaleStore/GetMERCHANTSList`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data.List
}

// 入库退货统计表
export async function handleGetStorageBackSummary(params: any) {
    const data = await request(`/SaleStore/GetStorageBackSummary`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return wrapTreeNode(data.Result_Data.List)
}


// 查询商品实时进销存明细数据
export async function handleGetCommodityInSaleList(params: any) {
    const data = await request(`/SaleStore/GetCommodityInSaleList`, {
        method: 'POST',
        data: { ...params, requestEncryption: true }
    })
    if (data.Result_Code !== 100) {
        return []
    }
    return data.Result_Data.List
}