import { customerFetch } from './index';

export class Params {
  /** 会员id */
  customerId: number;
  /** 订单状态 1未支付 2已支付 为空时查询的全部 */
  orderState?: string;
  /** 最后一页最后一条订单ID */
  lastOrderId?: number;
  /** 每页条数 */
  pageSize?: number;
}

export const fetchAllOrder = (params: Params) =>
  customerFetch({
    url: '/consumeOrder/pageAllList',
    data: params,
  });

export const fetchPayOrder = (params: Params) =>
  customerFetch({
    url: '/consumeOrder/pageList',
    data: {
      ...params,
      orderState: 1,
    },
  });

type DetailParams = {
  id: number;
};
export const fetchOrderDetail = (data: DetailParams) =>
  customerFetch({
    url: '/consumeOrder/getDetail',
    data: data,
  });

export const fetchOrderDetailAndPay = (data: DetailParams) =>
  customerFetch({
    url: '/consumeOrder/getOrderDetailAndPay',
    data: data,
  });

type DeductionParams = {
  orderId: number;
  payType: string;
  paymentConfId: number;
};
export const fetchDeductionInfo = (data: DeductionParams) =>
  customerFetch({
    url: '/consumeOrder/getDeductionInfo',
    data: data,
  });

type ConfirmpayParams = {
  orderId: number;
  payType: string;
  activeId?: number;
  callType: string;
  paymentConfId: number;
  returnUrl: string;
  [propName: string]: any;
};
export const confirmPay = (data: ConfirmpayParams) =>
  customerFetch({
    url: '/consumeOrder/confirmPay',
    data: data,
  });
