import request from '@/utils/request';

/**
 * 获取支付配置
 */
export const getPaymentConfig = () => {
  return request.get('/edu-app/open/paramConfig/queryByParamNameList', {
    requestType: 'form',
    params: {
      paramNames: 'payment_service_provider,teacher_vip_purchase_list'
    }
  });
};

/**
 * 创建VIP订单
 */
export const createVipOrder = (params: {
  orderType: string;
  paymentType: string;
  paymentChannel?: string;
  paymentCashAmount: number;
  paymentCouponAmount: number;
  goodsInfos: any[];
  orderName: string;
  orderDesc: string;
}) => {
  return request.post('/edu-app/userPaymentOrder/executeOrder', {
    data: params
  });
};

/**
 * 执行支付
 */
export const executePayment = (params: {
  merOrderNo: string;
  paymentChannel: string;
  userId: string | number;
  wxPubAppId?: string;
  code?: string;
}) => {
  return request.post('/edu-app/open/userOrder/executePayment', {
    data: params
  });
};

/**
 * 获取订单详情
 */
export const getOrderDetail = (orderNo: string) => {
  return request.get(`/edu-app/userPaymentOrder/detail/${orderNo}`);
};
