import BaseStore from '@src/stores/base';
// import * as querystring from 'querystring';

export default class OrderStore extends BaseStore {
  allCheckout() {
    return this.apiGet('/order/checkout/all');
  }

  addCheckout({ productType, productId, service, param, number }) {
    return this.apiPost('/order/checkout/add', { productType, productId, service, param, number });
  }

  removeCheckout(checkoutId) {
    return this.apiDelete('/order/checkout/delete', { checkoutId });
  }

  confirmPay() {
    return this.apiPost('/order/pay/confirm');
  }

  speedPay({ productType, productId, service, param, number }) {
    return this.apiPost('/order/pay/speed', { productType, productId, service, param, number });
  }

  wechatQr(orderId) {
    return this.apiPost('/order/wechat/qr', { orderId });
  }

  wechatJs(orderId) {
    return this.apiPost('/order/wechat/js', { orderId });
  }

  alipayQr(orderId) {
    return this.apiPost('/order/alipay/qr', { orderId });
  }

  query(orderId) {
    return this.apiGet('/order/pay/query', { orderId });
  }

  /**
   * 获取所有已购记录
   * @param {*} param0
   */
  listRecord({ page, size }) {
    return this.apiGet('/my/record/list', { page, size });
  }

  /**
   * 获取订单记录
   * @param {*} id
   */
  getRecord(id) {
    return this.apiGet('/my/record/detail', { id });
  }

  /**
   * 开通服务、课程等
   * @param {*} id
   */
  useRecord(id, isSubscribe) {
    return this.apiPost('/my/record/use', { id, isSubscribe });
  }
}

export const Order = new OrderStore({ key: 'order' });