import request from "@/utils/request";
import { Order_BaseUrl } from "@/api/config";
const baseURL = Order_BaseUrl + "/pay";
const Api = {
  // h5支付
  h5Pay(data: h5PayRequest) {
    return request<any>({
      url: `${baseURL}/h5Pay`,
      method: "post",
      data
    });
  },
  //反扫
  microPay(data: any) {
    return request<any>({
      url: `${baseURL}/microPay`,
      method: "post",
      data
    });
  },
  //正扫
  scanPay(data: any) {
    return request<any>({
      url: `${baseURL}/scanPay`,
      method: "post",
      data
    });
  },
  //会员支付
  vipPay(data: any) {
    return request<any>({
      url: `${baseURL}/vipPay`,
      method: "post",
      data
    });
  },
  //现金支付
  cashPay(data: any) {
    return request<any>({
      url: `${baseURL}/cashPay`,
      method: "post",
      data
    });
  },
  // 获取店铺订单支付URL
  orderPayUrl(data: any) {
    return request<any>({
      url: `${baseURL}/shopPayApi/orderPayUrl`,
      method: "post",
      data
    });
  },
  //挂账支付
  creditPay(data: any) {
    return request<any>({
      url: `${baseURL}/creditPay`,
      method: "post",
      data
    });
  },
  //查询订单状态
  queryOrderStatus(params: any) {
    return request<any>({
      url: `${baseURL}/queryOrderStatus`,
      method: "get",
      params
    });
  },
};

export default Api;

export interface h5PayRequest {
  /**
   * 支付备注
   */
  buyerRemark?: string;
  checkOrderPay?: CheckOrderPay;
  /**
   * 跳转地址
   */
  returnUrl?: string;
  shopId: number;
  [property: string]: any;
}

/**
* CheckOrderPay
*/
export interface CheckOrderPay {
  /**
   * 用户使用的卡券
   */
  couponList?: number[];
  /**
   * 手动优惠金额
   */
  discountAmount?: number;
  /**
   * 折扣比例(计算时 向上取整保留 两位小数)
   */
  discountRatio?: number;
  /**
   * 满减优惠券抵扣金额
   */
  fullCouponDiscountAmount?: number;
  /**
   * 订单金额
   */
  orderAmount?: number;
  orderId: number;
  /**
   * 订单原金额（包含打包费+餐位费） 不含折扣价格
   */
  originAmount?: number;
  /**
   * 积分抵扣金额(tb_points_basic_setting表)
   */
  pointsDiscountAmount?: number;
  /**
   * 使用的积分数量 (扣除各类折扣 enable_deduction后使用)
   */
  pointsNum?: number;
  /**
   * 商品优惠券抵扣金额
   */
  productCouponDiscountAmount?: number;
  /**
   * 抹零金额 减免多少钱
   */
  roundAmount?: number;
  /**
   * 用餐人数
   */
  seatNum?: number;
  userId?: number;
  [property: string]: any;
}