import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ErpOrderQuery, ErpOrderVo, ErpOrderForm } from './types';

/**
 * 查询订单列表
 * @param query
 * @Author: Antigravity
 */
export function listOrder(query: ErpOrderQuery): AxiosPromise<ErpOrderVo[]> {
  return request({
    url: '/erp/order/list',
    method: 'get',
    params: query
  });
}

/**
 * 查询订单详细
 * @param rowId
 * @Author: Antigravity
 */
export function getOrder(rowId: string): AxiosPromise<ErpOrderVo> {
  return request({
    url: '/erp/order/' + rowId,
    method: 'get'
  });
}

/**
 * 新增订单
 * @param data
 * @Author: Antigravity
 */
export function addOrder(data: ErpOrderForm) {
  return request({
    url: '/erp/order/add',
    method: 'post',
    data: data
  });
}

/**
 * 审核订单
 * @param data
 * @Author: Antigravity
 */
export function auditOrder(data: any) {
  return request({
    url: '/erp/order/audit',
    method: 'post',
    data: data
  });
}

/**
 * 按状态统计订单数量
 * @Author: Antigravity
 */
export function countOrder(): AxiosPromise<Record<string, number>> {
  return request({
    url: '/erp/order/count',
    method: 'get'
  });
}
