import request from "@/utils/request";
// 会员积分

/**
 * 基本设置-获取店铺设置
 * @returns
 */
export function basicSettingGet() {
  let shopId = localStorage.getItem("shopId");
  return request({
    url: `/api/points/basic-setting/${shopId}`,
    method: "get"
  });
}

/**
 * 基本设置-保存
 * @returns
 */
export function basicSettingPost(data) {
  return request({
    url: "/api/points/basic-setting",
    method: "post",
    data
  });
}

/**
 * 商品设置-新增/编辑
 * @returns
 */
export function goodsSettingAdd(data) {
  return request({
    url: "/api/points/goods-setting",
    method: data.id ? "put" : "post",
    data
  });
}

/**
 * 商品设置-删除
 * @returns
 */
export function goodsDelete(id) {
  return request({
    url: `/api/points/goods-setting/${id}`,
    method: "DELETE"
  });
}

/**
 * 商品设置-列表
 * @returns
 */
export function goodsSettingPage(params) {
  let shopId = localStorage.getItem("shopId");
  return request({
    url: `/api/points/goods-setting/page`,
    method: "get",
    params: {
      ...params,
      shopId: shopId
    }
  });
}

/**
 * 兑换记录-列表
 * @returns
 */
export function exchangeRecordPage(params) {
  let shopId = localStorage.getItem("shopId");
  return request({
    url: `/api/points/exchange-record/page`,
    method: "get",
    params: {
      ...params,
      shopId: shopId
    }
  });
}

/**
 * 兑换记录-统计
 * @returns
 */
export function exchangeRecordTotal(params) {
  let shopId = localStorage.getItem("shopId");
  return request({
    url: `/api/points/exchange-record/total`,
    method: "get",
    params: {
      ...params,
      shopId: shopId
    }
  });
}

/**
 * 兑换记录-核销
 * @returns
 */
export function recordCheckout(data) {
  return request({
    url: "/api/points/exchange-record/checkout",
    method: "post",
    data
  });
}
