import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { OrderAddressVO, OrderAddressForm, OrderAddressQuery } from '@/api/system/physical/orderAddress/types';

/**
 * 查询用户订单收货地址列表
 * @param query
 * @returns {*}
 */

export const listOrderAddress = (query?: OrderAddressQuery): AxiosPromise<OrderAddressVO[]> => {
  return request({
    url: '/physical/orderAddress/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户订单收货地址详细
 * @param id
 */
export const getOrderAddress = (id: string | number): AxiosPromise<OrderAddressVO> => {
  return request({
    url: '/physical/orderAddress/' + id,
    method: 'get'
  });
};

/**
 * 新增用户订单收货地址
 * @param data
 */
export const addOrderAddress = (data: OrderAddressForm) => {
  return request({
    url: '/physical/orderAddress',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户订单收货地址
 * @param data
 */
export const updateOrderAddress = (data: OrderAddressForm) => {
  return request({
    url: '/physical/orderAddress',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户订单收货地址
 * @param id
 */
export const delOrderAddress = (id: string | number | Array<string | number>) => {
  return request({
    url: '/physical/orderAddress/' + id,
    method: 'delete'
  });
};
/**
 * 查询用户订单收货地址详细
 * @param id
 */
export const selectPhysicalOrderAddress = (orderSn: string | number): AxiosPromise<OrderAddressVO> => {
  return request({
    url: '/physical/orderAddress/selectPhysicalOrderAddress/' + orderSn,
    method: 'get'
  });
};
