import request from '@/utils/request';
import { EnterpriseInfo, ShippingAddress, InvoiceInfo } from './types';

// ==================== 企业信息管理 ====================

/**
 * 查询当前企业信息
 */
export function getEnterpriseInfo() {
  return request({
    url: '/customer/enterprise/info',
    method: 'get'
  });
}

/**
 * 修改当前企业信息
 */
export function updateEnterpriseInfo(data: EnterpriseInfo) {
  return request({
    url: '/customer/enterprise/updateEnterprise',
    method: 'put',
    data: data
  });
}

/**
 * 修改密码
 */
export function changePwd(data: any) {
  return request({
    url: '/system/psSysUser/changePwd', // 密码修改
    method: 'put',
    data: data
  });
}

// ==================== 收货地址管理 ====================

/**
 * 查询收货地址列表
 */
export function getAddressList(params?: any) {
  return request({
    url: '/customer/address/list',
    method: 'get',
    params: params
  });
}

/**
 * 查询收货地址详情
 */
export function getAddressInfo(id: number) {
  return request({
    url: `/customer/address/${id}`,
    method: 'get'
  });
}

/**
 * 新增收货地址
 */
export function addAddress(data: ShippingAddress) {
  return request({
    url: '/customer/address',
    method: 'post',
    data: data
  });
}

/**
 * 修改收货地址
 */
export function updateAddress(data: ShippingAddress) {
  return request({
    url: '/customer/address',
    method: 'put',
    data: data
  });
}

/**
 * 删除收货地址
 */
export function deleteAddress(ids: number[]) {
  return request({
    url: `/customer/address/${ids.join(',')}`,
    method: 'delete'
  });
}

/**
 * 设置默认地址
 */
export function setDefaultAddress(data: { id: number }) {
  return request({
    url: '/customer/address/default',
    method: 'put',
    data: data
  });
}

// ==================== 发票信息管理 ====================

/**
 * 查询发票信息列表
 */
export function getInvoiceList(params?: any) {
  return request({
    url: '/customer/pcInvoice/list',
    method: 'get',
    params: params
  });
}

/**
 * 查询发票信息详情
 */
export function getInvoiceInfo(id: number) {
  return request({
    url: `/customer/pcInvoice/invoice/${id}`,
    method: 'get'
  });
}

/**
 * 新增发票信息
 */
export function addInvoice(data: InvoiceInfo) {
  return request({
    url: '/customer/pcInvoice',
    method: 'post',
    data: data
  });
}

/**
 * 修改发票信息
 */
export function updateInvoice(data: InvoiceInfo) {
  return request({
    url: '/customer/pcInvoice',
    method: 'put',
    data: data
  });
}

/**
 * 删除发票信息
 */
export function deleteInvoice(ids: number[]) {
  return request({
    url: `/customer/pcInvoice/${ids.join(',')}`,
    method: 'delete'
  });
}

/**
 * 查询行业类别列表
 */

export function getIndustryCategoryList(params?: any) {
  return request({
    url: '/customer/pcIndustryCategory/list',
    method: 'get',
    params: params
  });
}

/**
 * 查询行业类别列表
 */

export function getEnterpriseScaleList(params?: any) {
  return request({
    url: '/customer/pcEnterpriseScale/list',
    method: 'get',
    params: params
  });
}
