import request from '@/utils/request';

/**
 * 查询订单列表
 * @param params 查询条件
 */
export async function listGroupsCustomer(params) {
  const res = await request.get('/sylive/groupsCustomer', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 导出订单
 * @param params 查询条件
 */
export async function exportGroupsCustomer(params) {
  const res = await request.get('/sylive/groupsCustomer/export', {
    params
  });
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 导入用户
 * @param file excel文件
 */
export async function importGroupsCustomer(file, activityId) {
  const formData = new FormData();
  formData.append('file', file);
  formData.append('activityId', activityId);
  const res = await request.post('/sylive/groupsCustomer/import', formData);
  if (res.data.code === 0) {
    return res.data.message;
  }
  return Promise.reject(new Error(res.data.message));
}
