// 1.1 获取停车场信息：https://kerryprops.atlassian.net/wiki/spaces/TAIC/pages/93323297/1.1
// temporary-parking-service/parking-lots
// https://{kip-service-host}/c/api/temporary-parking-service/parking-lots
// ${window.profileApi}/temporary-parking-service
// import {createAxiosByinterceptors} from '@/api/request';
//
// // 在初始化时，获取到的 window.profileApi 为空，需要执行一下 request() ，才能拿到正确的 api 地址，进行后续的接口请求
// const request = createAxiosByinterceptors({
//   baseURL: `${window.profileApi}/temporary-parking-service`,
// });

export function parkingLots(lbsId) {
  // return window.requestms.get(`/parking-lots/buildings/${buildingsId}`, {
  return window.requestms.get(`/parking-lots/lbs/${lbsId}`, {
    loading: true,
  });
  // return window.requestms.get(`/`, { params, loading: true });
}

// 1.6 查询车辆是否在场及停车费用: https://kerryprops.atlassian.net/wiki/spaces/TAIC/pages/94076936/1.6
// 新接口路径：https://{kip-service-host}/c/api/temporary-parking-service/parking/check-out?vehicleNo={{vehicleNo}}
export function checkOut(vehicleNo, unlicensed) {
  // console.log(212121, vehicleNo);
  // 'https://dev-kip-service-internal.kerryonvip.com/temporary-parking-service/parking/check-out?vehicleNo=浙
  return window.requestms.get(`/parking/check-out?vehicleNo=${vehicleNo}&unlicensed=${unlicensed}`, {
    loading: true,
    headers: {
      buildingId: window.localStorage.getItem('buildingId'),
    },
  });
}

// 1.4 查询订单详情: https://kerryprops.atlassian.net/wiki/spaces/TAIC/pages/94076929/1.4
export function orderInfo(orderId) {
  return window.requestms.get(`/orders/${orderId}`, { loading: true });
}

// 1.5 查询历史停车订单: https://kerryprops.atlassian.net/wiki/spaces/TAIC/pages/94076929/1.5
// 新接口路径：https://{kip-service-host}/c/api/temporary-parking-service/orders?page=1&pageSize=10
export function orders(params) {
  return window.requestms.get(`/orders`, { params, loading: true });
}

// 1.20 用户优惠信息校验
export function calculateDiscount(params) {
  return window.requestms.post(`/parking/calculate-discount`, params, {
    loading: true,
    header: {
      buildingId: window.localStorage.getItem('buildingId'),
    },
  });
}

// 1.13 下单并发起支付
export function ordersAndPrepay(params) {
  return window.requestms.post(`/parking/orders-and-prepay`, params, { loading: true });
}

// 1.23 会员查询无牌车临牌
export function currentUnlicensedPlate() {
  return window.requestms.get(`/parking/current-unlicensed-plate`, { loading: true });
}

// 1.18 无牌车入场
/**
 * 
 * @param params.gateId string 车厂入口道闸编号
 * @returns 
 * {
    "cId": "LDADYzxWoaMAzEEefwefqewqedfjlte313FWp",
    "vehicleNo": "临K00000",
    "createTime": "2022-11-11 22:22:00"
}
 */
export function unlicensedCarCheckIn(params) {
  return window.requestms.post(`/parking/unlicensed-car-check-in`, params, { loading: true });
}

/* 开票相关接口api */

// 未开票列表
export function invoicesNotapplied(params) {
  return window.requestms.get(`/invoices/not-applied`, { params, loading: true });
}

// 已开票列表
export function invoicesCompleted(params) {
  return window.requestms.get(`/invoices/completed`,  { params, loading: true });
}

// 开票详情
export function invoicesDeatil(id) {
  return window.requestms.get(`/invoices/${id}`, { loading: true });
}

// 发票关联的订单支付详情
export function invoicesOrders(invoiceId) {
  return window.requestms.get(`/invoices/${invoiceId}/orders`, { loading: true });
}

// 新增发票抬头
export function invoicesNewtitles(params) {
  return window.requestms.post(`/invoice-titles`, params, { loading: true });
}
// 编辑发票抬头

export function invoicesEdittitles(params, id) {
  return window.requestms.put(`/invoice-titles/${id}`, params, { loading: true });
}

// 删除发票抬头

export function invoicesDeletetitles(id) {
  return window.requestms.delete(`/invoice-titles/${id}`, { loading: true });
}

// 发票抬头列表

export function invoicesDetail(params) {
  return window.requestms.get(`/invoice-titles`, { params, loading: true });
}

// 再次发送发票附件

export function invoicesAgainSandEmail(invoiceId) {
  return window.requestms.get(`/invoices/send-email?invoiceId=${invoiceId}`, { loading: true });
}

// 提交发票申请

export function submitInvoice(params) {
  return window.requestms.post(`/invoices/`,params, { loading: true });

}
// 查询会员默认邮箱信息

export function invoiceEmails() {
  return window.requestms.get(`/invoice-emails/current-user-default-email`, { loading: true });

}



// 1.19 无牌车出场
/**
 * 
 * @param params.gateId string 车厂出口道闸编号
 * @param params.vehicleNo string 临牌
 * @returns {*}
 */
export function unlicensedCarCheckout(vehicleNo, unlicensed, gateId) {
  return window.requestms.post(`/parking/unlicensed-car-checkout`, { vehicleNo, gateId }, { loading: true });
}
// 1.25 车场二维码信息查询（通过CodeID）
/**
 * 
 * @param params.gateId string 车厂入口道闸编号
 * @param params.vehicleNo string 临牌
 * @returns {*}
 */
export function qrCodes(codeId) {
  return window.requestms.get(`qr-codes/code-ids/${codeId}`, { loading: true });
}


// 1.3 纸质优惠劵金额接口
export function paperCoupon(couponCode, vehicleNo) {
  return window.requestms.get(`parking-lots/paper-coupon?couponCode=${couponCode}&vehicleNo=${vehicleNo}`, { loading: true });
}


