import request from '../utils/request'

const api = {
  Create: '/Order/CreateOrder',
  Pay: '/Order/Pay',
  Cancel: '/Order/CancelOrder',
  Refund: '/Order/RefundOrder',
  Detail: '/Order/Detail',
  PaymentMethods: '/Order/PaymentMethods',
  GetMyOrder: '/Order/GetMyOrders',
  AdminOrderList: '/Admin/Order/List',
  AdminOrderDetail: '/Admin/Order/Detail',
  AdminRefund: '/Admin/Order/RefundOrder'
}

export function createOrder(parameter) {
  return request({
    url: api.Create,
    method: 'post',
    data: parameter
  })
}

export function payOrder(parameter) {
  return request({
    url: api.Pay,
    method: 'post',
    data: parameter
  })
}

export function orderDeatil(parameter) {
  return request({
    url: api.Detail,
    method: 'get',
    params: parameter
  })
}

export function getPaymentMethods() {
  return request({
    url: api.PaymentMethods,
    method: 'get'
  })
}

export function cancelOrder(parameter) {
  return request({
    url: api.Cancel,
    method: 'post',
    data: parameter
  })
}

export function refundOrder(parameter) {
  return request({
    url: api.Refund,
    method: 'post',
    data: parameter,
    timeout: 60000
  })
}

export function getMyOrder(parameter) {
  return request({
    url: api.GetMyOrder,
    method: 'get',
    params: parameter
  })
}

export function adminOrderList(parameter) {
  return request({
    url: api.AdminOrderList,
    method: 'get',
    params: parameter
  })
}

export function adminOrderDetail(parameter) {
  return request({
    url: api.AdminOrderDetail,
    method: 'get',
    params: parameter
  })
}

export function adminRefundOrder(parameter) {
  return request({
    url: api.AdminRefund,
    method: 'post',
    data: parameter,
    timeout: 60000
  })
}
