import http from './http.js'
const request=http.request


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

/**
 * 获取店铺数据
 * @returns
 */
export function getShopInfo(params) {
    return request({
        url: `/api/tbShopInfo/${params}`,
        method: 'get',
        params: {
       
        }
    })
}

/**
 * 更改店铺信息
 * @returns
 */
export function editShopInfo(data) {
    return request({
        url: `/api/tbShopInfo`,
        method: 'put',
        data:{
          // shopId: uni.getStorageSync('shopId'),
          ...data
        }
    })
}


/**
 * 获取店铺图片
 * @returns
 */
export function getShopExtend(params) {
    return request({
        url: `/tbShopExtend`,
        method: 'get',
        params:{
          shopId: uni.getStorageSync('shopId'),
        }
    })
}

/**
 * 获取店铺图片
 * @returns
 */
export function editShopExtend(data) {
   return request({
       url: `/tbShopExtend`,
       method: 'put',
       data:{
         shopId: uni.getStorageSync('shopId'),
         ...data
       }
   })
}
/**
 * 商品列表
 * @returns
 */
export function tbProduct(params) {
  return request({
    url: "/api/tbProduct",
    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:{
		sort:'id',
		shopId: uni.getStorageSync("shopId"),
		...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 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: uni.getStorageSync("shopId"),
      ...params
    }
  });
}
/**
 * 查询商家用户概述信息
 * @returns
 */
export function queryAllShopInfo(params) {
  return request({
    url: `/api/tbShopUser/summary`,
    method: "get",
    params: {
      shopId: uni.getStorageSync("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: uni.getStorageSync("shopId"),
      ...params
    }
  });
}

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

/**
 * 员工列表
 * @returns
 */
export function tbPlussShopStaffGet(params) {
  return request({
    url: `/api/tbPlussShopStaff`,
    method: "get",
    params: {
      shopId: uni.getStorageSync("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: uni.getStorageSync("shopId"),
      ...data
    }
  });
}

/**
 * 通过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
  });
}

/**
 * 员工删除
 * @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
  });
}

//新增

// 查询员工是否拥有权限
export function $hasPermission(params) {
  return request({
    url: '/api/tbShopPermission/hasPermission',
    method: "get",
    params:{
		userId: uni.getStorageSync("shopUserId"),
		...params
	}
  });
}

