// 获取商户应收账款列表
import request from '@/utils/request';
import { wrapTreeNode } from '@/utils/testFormat';

export async function handleGetNestingCOMMODITYTYPETree(params?: any) {

  const data = await request(`/BaseInfo/GetNestingCOMMODITYTYPETree`, {
    method: 'GET',
    params
  });

  if (data.Result_Code !== 100) {
    return {
      data: [],
      current: 1,
      pageSize: 10,
      total: 0,
      success: false
    }
  }
  return  wrapTreeNode(data.Result_Data.List)
}


export async function handleGetCommodityList(params?: any) {

  const data = await request(`/Commodity/GetCommodityList`, {
    method: 'GET',
    params
  });

  if (data.Result_Code !== 100) {
    return {
      data: [],
      current: 1,
      pageSize: 10,
      total: 0,
      success: false
    }
  }
  return  data.Result_Data
}


// 添加或者编辑商品
export async function handleSynchroCOMMODITY(params?: any) {

  const data = await request(`/Commodity/SynchroCOMMODITY`, {
    method: 'POST',
    data: params
  });

  if (data.Result_Code !== 100) {
    return {
      data: [],
      current: 1,
      pageSize: 10,
      total: 0,
      success: false
    }
  }
  return  data
}


// 删除商品

export async function handleDeleteCOMMODITY(params?: any) {

  const data = await request(`/Commodity/DeleteCOMMODITY`, {
    method: 'POST',
    params
  });

  if (data.Result_Code !== 100) {
    return {
      data: [],
      current: 1,
      pageSize: 10,
      total: 0,
      success: false
    }
  }
  return  data
}


// 获取服务区商品业态
export async function handleGetServerpartShopTrade(params?: any) {

  const data = await request(`/BaseInfo/GetServerpartShopTrade`, {
    method: 'GET',
    params
  });

  if (data.Result_Code !== 100) {
    return {
      data: [],
      current: 1,
      pageSize: 10,
      total: 0,
      success: false
    }
  }
  return  data.Result_Data.List
}
