import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { StoreVO, StoreForm, StoreQuery, StoreStatusVO, SysStorePageBo, StoreOrderQuery, StoreOrderVO, StoreDispatchVO, StoreRenewForm, StoreBanForm, StoreEnableForm } from '@/api/system/store/types';

/**
 * 查询门店管理列表
 * @param query
 * @returns {*}
 */

export const listStore = (query?: SysStorePageBo): AxiosPromise<StoreVO[]> => {
  return request({
    url: '/system/store/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询门店管理详细
 * @param id
 */
export const getStore = (id: string | number): AxiosPromise<StoreVO> => {
  return request({
    url: '/system/store/' + id,
    method: 'get'
  });
};

/**
 * 新增门店管理
 * @param data
 */
export const addStore = (data: StoreForm) => {
  return request({
    url: '/system/store',
    method: 'post',
    data: data
  });
};

/**
 * 修改门店管理
 * @param data
 */
export const updateStore = (data: StoreForm) => {
  return request({
    url: '/system/store',
    method: 'put',
    data: data
  });
};

/**
 * 删除门店管理
 * @param id
 */
export const delStore = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/store/' + id,
    method: 'delete'
  });
};

/**
 * 获取状态列表
 */
export const listStoreStatus = (): AxiosPromise<StoreStatusVO[]> => {
  return request({
    url: '/system/store/listStatus',
    method: 'get'
  });
};

/**
 * 下单时查询门店列表
 * @param query
 * @returns {*}
 */
export const listStoreOnOrder = (query?: StoreOrderQuery): AxiosPromise<{ total: number, rows: StoreOrderVO[] }> => {
  return request({
    url: '/system/store/listOnOrder',
    method: 'get',
    params: query
  });
};

/**
 * 调度时查询门店列表
 * @param query
 */
export const listStoreOnDispatch = (query?: { site?: string | number }): AxiosPromise<StoreDispatchVO[]> => {
  return request({
    url: '/system/store/listOnDispatch',
    method: 'get',
    params: query
  });
};

/**
 * 门店续期
 * @param data
 */
export const renewStore = (data: StoreRenewForm) => {
  return request({
    url: '/system/store/renew',
    method: 'put',
    data: data
  });
};

/**
 * 门店禁用
 * @param data
 */
export const banStore = (data: StoreBanForm) => {
  return request({
    url: '/system/store/ban',
    method: 'put',
    data: data
  });
};

/**
 * 门店启用
 * @param data
 */
export const enableStore = (data: StoreEnableForm) => {
  return request({
    url: '/system/store/enable',
    method: 'put',
    data: data
  });
};

