import request from "@/utils/request";

/**
 * 商品列表
 * @returns
 */
export function tbProduct(params) {
  return request({
    url: "/api/tbProduct/list",
    method: "get",
    params
  });
}

/**
 * 删除商品
 * @returns
 */
export function tbProductDelete(data) {
  return request({
    url: "/api/tbProduct",
    method: "delete",
    data
  });
}

/**
 * 商品单位列表
 * @returns
 */
export function tbShopUnit(params) {
  return request({
    url: "/api/tbShopUnit",
    method: "get",
    params
  });
}

/**
 * 店铺基本配置
 * @returns
 */
export function tbShopCurrency(shopId) {
  return request({
    url: `/api/tbShopCurrency/${shopId}`,
    method: "get"
  });
}

/**
 * 修改店铺信息
 * @returns
 */
export function tbShopCurrencyPut(data) {
  return request({
    url: `/api/tbShopCurrency`,
    method: "put",
    data
  });
}

/**
 * 新增单位
 * @returns
 */
export function tbShopUnitPost(data) {
  return request({
    url: `/api/tbShopUnit`,
    method: "post",
    data
  });
}

/**
 * 更改单位
 * @returns
 */
export function tbShopUnitPut(data) {
  return request({
    url: `/api/tbShopUnit`,
    method: "put",
    data
  });
}

/**
 * 删除单位
 * @returns
 */
export function tbShopUnitDelete(data) {
  return request({
    url: `/api/tbShopUnit`,
    method: "delete",
    data
  });
}

/**
 * 店铺基本配置
 * @returns
 */
export function tbShopCurrencyGet(params) {
  return request({
    url: `/api/tbShopUnit`,
    method: "get",
    params
  });
}

/**
 * 商品分类列表
 * @returns
 */
export function tbShopCategoryGet(params) {
  return request({
    url: `/api/tbShopCategory`,
    method: "get",
    params
  });
}

/**
 * 新增、编辑分类/新增、编辑子分类
 * @returns
 */
export function tbShopCategoryPost(data, method = "post") {
  return request({
    url: `/api/tbShopCategory`,
    method: method,
    data
  });
}

/**
 * 删除商品分类
 * @returns
 */
export function tbShopCategoryDelete(data) {
  return request({
    url: `/api/tbShopCategory`,
    method: "delete",
    data
  });
}

/**
 * 规格增加
 * @returns
 */
export function tbProductSpecPost(data) {
  return request({
    url: `/api/tbProductSpec`,
    method: "post",
    data
  });
}

/**
 * 规格列表
 * @returns
 */
export function tbProductSpecGet(params) {
  return request({
    url: `/api/tbProductSpec`,
    method: "get",
    params
  });
}

/**
 * 规格更改
 * @returns
 */
export function tbProductSpecPut(data) {
  return request({
    url: `/api/tbProductSpec`,
    method: "put",
    data
  });
}

/**
 * 删除规格
 * @returns
 */
export function tbProductSpecDelete(data) {
  return request({
    url: `/api/tbProductSpec`,
    method: "DELETE",
    data
  });
}

/**
 * 新增分组
 * @returns
 */
export function tbProductGroupPost(data) {
  return request({
    url: `/api/tbProductGroup`,
    method: "post",
    data
  });
}

/**
 * 更改分组
 * @returns
 */
export function tbProductGroupPut(data) {
  return request({
    url: `/api/tbProductGroup`,
    method: "PUT",
    data
  });
}

/**
 * 商品分组列表
 * @returns
 */
export function tbProductGroupGet(params) {
  return request({
    url: `/api/tbProductGroup`,
    method: "get",
    params
  });
}

/**
 * 商品列表（根据分组中的商品id）
 * @returns
 */
export function productListGet(productGroup) {
  return request({
    url: `/api/tbProductGroup/${productGroup}`,
    method: "get"
  });
}

/**
 * 删除分组
 * @returns
 */
export function tbProductGroupDelete(data) {
  return request({
    url: `/api/tbProductGroup`,
    method: "DELETE",
    data
  });
}

/**
 * 添加商品
 * @returns
 */
export function tbProductPost(data) {
  return request({
    url: `/api/tbProduct`,
    method: "post",
    data
  });
}

/**
 * 添加商品
 * @returns
 */
export function tbProductPut(data) {
  return request({
    url: `/api/tbProduct`,
    method: "put",
    data
  });
}

/**
 * 商品详情（单个商品）
 * product 商品id
 * @returns
 */
export function tbProductGetDetail(product) {
  return request({
    url: `/api/tbProduct/${product}`,
    method: "get"
  });
}

/**
 * 店铺列表
 * @returns
 */
export function tbShopInfo(params) {
  return request({
    url: `/api/tbShopInfo`,
    method: "get",
    params
  });
}

/**
 * 增加激活码
 * @returns
 */
export function tbMerchantRegisterPost(data) {
  return request({
    url: `/api/tbMerchantRegister`,
    method: "post",
    data
  });
}

/**
 * 激活码列表
 * @returns
 */
export function tbMerchantRegisterList(data) {
  return request({
    url: `/api/tbMerchantRegister/list`,
    method: "post",
    data
  });
}

/**
 * 增加/编辑店铺
 * @returns
 */
export function tbShopInfoPost(data, method = "post") {
  return request({
    url: `/api/tbShopInfo`,
    method: method,
    data
  });
}

/**
 * 详情（配置三方支付）
 * @returns
 */
export function tbMerchantThirdApply(shopId) {
  return request({
    url: `/api/tbMerchantThirdApply/${shopId}`,
    method: "get"
  });
}

/**
 * 修改第三方配置
 * @returns
 */
export function tbMerchantThirdApplyPut(data) {
  return request({
    url: `/api/tbMerchantThirdApply`,
    method: "put",
    data
  });
}

/**
 * 设置热销商品
 * @returns
 */
export function tbProductIsHot(params) {
  return request({
    url: `/api/tbProduct/isHot`,
    method: "get",
    params
  });
}

/**
 * 增加/编辑优惠券
 * @returns
 */
export function tbMerchantCoupon(data, method = "post") {
  return request({
    url: `/api/tbMerchantCoupon`,
    method: method,
    data
  });
}

/**
 * 设置热销商品
 * @returns
 */
export function tbMerchantCouponGet(params) {
  return request({
    url: `/api/tbMerchantCoupon`,
    method: "get",
    params
  });
}

/**
 * 设置热销商品
 * @returns
 */
export function geocode(params) {
  return request({
    url: `/api/geocode`,
    method: "get",
    params
  });
}

/**
 * 新增、修改活动
 * @returns
 */
export function modityActivate(data) {
  return request({
    url: `/shop/storage/modityActivate`,
    method: "post",
    data
  });
}

/**
 * 新增、修改活动   新的！
 * @returns
 */
export function storageupActivate(data) {
  return request({
    url: `/shop/storage/upActivate`,
    method: "post",
    data
  });
}
/**
 * 活动列表
 * @returns
 */
export function findActivate(params) {
  return request({
    url: `/shop/storage/findActivate`,
    method: "get",
    params
  });
}
// 获取店铺会员二维码
export function getwxacode(data) {
  return request({
    url: `/shop/storage/getwxacode`,
    method: "post",
    data
  });
}
/**
 * 商家用户列表
 * @returns
 */
export function queryAllShopUser(params) {
  return request({
    url: `/api/tbShopUser/queryAllShopUser`,
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      ...params
    }
  });
}
/**
 * 查询商家用户概述信息
 * @returns
 */
export function queryAllShopInfo(params) {
  return request({
    url: `/api/tbShopUser/summary`,
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      ...params
    }
  });
}

/**
 * 修改商品排序
 * @returns
 */
export function upProSort(data) {
  return request({
    url: `/api/tbProduct/upProSort`,
    method: "post",
    data
  });
}

/**
 * 修改分组排序
 * @returns
 */
export function upGroupSort(data) {
  return request({
    url: `/api/tbProductGroup/upGroupSort`,
    method: "post",
    data
  });
}

/**
 * 修改分类排序
 * @returns
 */
export function upCategorySort(data) {
  return request({
    url: `/api/tbShopCategory/upCategorySort`,
    method: "post",
    data
  });
}

/**
 * 查询店铺充值记录
 * @returns
 */
export function tbShopUserRecharge(params) {
  return request({
    url: `/api/tbShopUser/recharge`,
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      ...params
    }
  });
}

/**
 * 导出充值记录
 * @returns
 */
export function downloadTableRecharge(data) {
  return request({
    url: `/api/tbShopUser/recharge/download`,
    method: "post",
    data: {
      shopId: localStorage.getItem("shopId"),
      ...data
    },
    responseType: "blob"
  });
}

/**
 * 员工列表
 * @returns
 */
export function tbPlussShopStaffGet(params) {
  return request({
    url: `/api/tbPlussShopStaff`,
    method: "get",
    params: {
      shopId: localStorage.getItem("shopId"),
      ...params
    }
  });
}

/**
 * 角色列表
 * @returns
 */
export function rolesGet() {
  return request({
    url: `/api/roles`,
    method: "get"
  });
}

/**
 * 增加员工
 * @returns
 */
export function tbPlussShopStaff(data) {
  return request({
    url: `/api/tbPlussShopStaff`,
    method: data.id ? "put" : "post",
    data: {
      shopId: localStorage.getItem("shopId"),
      ...data
    }
  });
}

export function tbShopPermissionlist(params) {
  return request({
    url: `/api/tbShopPermission/list`,
    method: "get",
    params
  });
}

export function getHasPermission(params) {
  return request({
    url: `/api/tbShopPermission/hasPermission`,
    method: "get",
    params
  });
}

/**
 * 通过id获取员工信息
 * @returns
 */
export function tbPlussShopStaffDetail(id) {
  return request({
    url: `/api/tbPlussShopStaff/${id}`,
    method: "get"
  });
}

/**
 * 更改员工状态
 * @returns
 */
export function updateStatus(data) {
  return request({
    url: `/api/tbPlussShopStaff/updateStatus`,
    method: "put",
    data
  });
}
// 叫号记录
export function callRecord(params) {
  return request({
    url: `/callTable/callRecord`,
    method: "get",
    params
  });
}
export function callTablecall(data) {
  return request({
    url: `/callTable/call`,
    method: "post",
    data
  });
}
// 删除桌型
export function callTabledelete(data) {
  return request({
    url: `/callTable`,
    method: "delete",
    data
  });
}
export function callTablepost(data) {
  return request({
    url: "/callTable",
    method: "post",
    data
  });
}
// 桌型列表
export function callTable(params) {
  return request({
    url: `/callTable`,
    method: "get",
    params
  });
}
// 修改桌号
export function callTabledataput(data) {
  return request({
    url: `/callTable`,
    method: "put",
    data
  });
}
// 叫号列表
export function callTablequeue(params) {
  return request({
    url: "/callTable/queue",
    method: "get",
    params
  });
}
// 取消叫号
export function callTableput(data) {
  return request({
    url: `/callTable/updateState`,
    method: "put",
    data
  });
}
export function callTabletakeNumber(data) {
  return request({
    url: "/callTable/takeNumber",
    method: "post",
    data: {
      ...data
    }
  });
}
// 叫号配置获取
export function callTableconfig(params) {
  return request({
    url: "/callTable/config",
    method: "get",
    params
  });
}
// 叫号配置修改
export function callTableconfigput(data) {
  return request({
    url: `/callTable/config`,
    method: "put",
    data
  });
}
/**
 * 员工删除
 * @returns
 */
export function shopStaffDelete(data) {
  return request({
    url: `/api/tbPlussShopStaff`,
    method: "delete",
    data
  });
}

//增减余额
export function midfiyAccount(data) {
  return request({
    url: `/api/tbShopUser/midfiyAccount`,
    method: "post",
    data
  });
}
// 编辑用户
export function tbShopUseredit(data) {
  return request({
    url: `/api/tbShopUser`,
    method: "put",
    data
  });
}
// 通过活动id获取赠送商品列表
export function activate(id) {
  return request({
    url: `shop/storage/activate/${id}`,
    method: "get"
  });
}

// 通过活动id获取赠送商品列表
export function queryShopUserFlow(params) {
  return request({
    url: `/api/tbShopUser/queryShopUserFlow`,
    method: "get",
    params
  });
}

// 商品列表 V2
export function tbProductListV2(data) {
  return request({
    url: `/api/tbProduct/list/v2`,
    method: "post",
    data
  });
}

// 修改商品相关(快捷接口）
export function updateProductData(data) {
  return request({
    url: `/api/stock/updateProductData`,
    method: "post",
    data
  });
}

// 商品库存统计列表 统计
export function tbProductStockDetailStockCount(data) {
  return request({
    url: `/api/tbProductStockDetail/stock/count`,
    method: "post",
    data
  });
}

// 商品库存记录列表
export function tbProductStockDetailStock(data) {
  return request({
    url: `/api/tbProductStockDetail/stock`,
    method: "post",
    data
  });
}

// 商品库存记录列表
export function stockWarnLine(data) {
  return request({
    url: `/api/stock/warnLine`,
    method: "PUT",
    data
  });
}
