
import type msgListQuery from "./msgQuery";
import type msgType from "~/domain/Msg";
import type { ServerList, ServerRes } from '~/service/index'
import httpRequest from "~/service/index";

export function useAll() {
  const apiRoot = "/seller/sellerMessage"

  //获取商城资讯
  async function getNewsList(res: any) {
    return await httpRequest.post<ServerList<any>>(`/user/news/queryNewsArticlePage`, res)
  }
  //商品搜索
  async function selectProductLike(res: any) {
    return await httpRequest.post<any>(`/product/selectProductLike`, res)
  }

  //商品搜索
  async function selectProductHot(res: any) {
    return await httpRequest.post<any>(`/product/selectTitle`, res)
  }

  //商品详情
  async function getProductDetail(id: any) {
    return await httpRequest.post<any>(`/product/findProduct`, { id: id })
  }

  // 加入购物车
  async function saveCart(query: any) {
    return await httpRequest.post<any>(`/cart/saveCart`, query)
  }

  // 商品批量加入购物车
  async function batchCart(query: any) {
    return await httpRequest.post<any>(`/cart/batchCart`, query)
  }

  // 新闻详情
  async function getNewsDetail(query: any) {
    return await httpRequest.post<any>(`/user/news/queryNewsArticle`, query)
  }

  // 获取购物车
  async function getCartList() {
    return await httpRequest.get<any>(`/cart/getCartList`)
  }

  // 获取用户中心统计信息
  async function getUserStatistics() {
    return await httpRequest.get<any>(`/shop/userInfo/getUserStatistics`)
  }

  // 获取订单
  async function getOrderList(query: any) {
    return await httpRequest.post<any>(`/shop/order/getOrdersByCondition`, query)
  }
  // 获取订单详情
  async function getOrderDetail(orderSn: any) {
    return await httpRequest.get<any>(`/shop/order/getHktOrderOderSn?orderSn=` + orderSn)
  }

  // 获取门店信息
  async function getWarehouseMapList(id: any) {
    return await httpRequest.get<any>(`/shop/warehouseMap/getWarehouseMapList?id=` + id)
  }

  //订单详情订单发票
  async function getOrderInvoice(id: any) {
    return await httpRequest.get<any>(`/shop/orderInvoice/getUserInvoice?orderId=` + id)
  }

  //订单取消
  async function cancelOrder(id: any) {
    return await httpRequest.post<any>(`/shop/order/cancelOrder`, { id: id })
  }

  //收藏商品
  async function saveHktFavorites(query: any) {
    return await httpRequest.post<any>(`/shop/favorite/saveHktFavorites`, query)
  }
  //取消收藏商品
  async function deleteFavorites(query: any) {
    return await httpRequest.post<any>(`/shop/favorite/deleteFavorites`, query)
  }

  //删除购物车商品
  async function delCartGood(id: any) {
    return await httpRequest.get<any>(`/cart/deleteCartByGoodId?goodId=` + id)
  }

  //获取收货地址
  async function getUserAddress() {
    return await httpRequest.get<any>(`/shop/address/getUserAddress`)
  }

  //更新地址
  async function updateUserAddress(query: any) {
    return await httpRequest.post<any>(`/shop/address/updateUserAddress`, query)
  }

  //设置默认地址
  async function setDefaultAddress(id: any) {
    return await httpRequest.get<any>(`/shop/address/setDefaultAddress?id=${id}`)
  }

  //获取收藏列表
  async function getCollectList(query: any) {
    return await httpRequest.post<any>(`/shop/favorite/favoritePage`, query)
  }

  //获取发票信息
  async function getUserInvoice() {
    return await httpRequest.get<any>(`/shop/userInvoice/getUserInvoice`)
  }

  //上传营业执照
  async function fileUploadWithPath(query: any) {
    return await httpRequest.post<any>(`/oss/fileUploadWithPath`, query)
  }

  //保存发票信息
  async function updateUserInvoice(query: any) {
    return await httpRequest.post<any>(`/shop/userInvoice/updateUserInvoice`, query)
  }

  //积分列表
  async function UserScorePage(query: any) {
    return await httpRequest.post<any>(`/shop/usersScore/UserScorePage`, query)
  }

  //购物车商品选中更新
  async function updateCart(query: any) {
    return await httpRequest.post<any>(`/cart/updateCart`, query)
  }

  //获取下单的购物车 
  async function calculateGoodsPrice(query: any) {
    return await httpRequest.post<any>(`/shop/order/calculateGoodsPrice`, query)
  }

  //获取下单的购物车 
  async function getHktExpressCompanyList(query: any) {
    return await httpRequest.get<any>(`/shop/expressCompany/getHktExpressCompanyList`, query)
  }

  //提交订单
  async function saveOrder(query: any) {
    return await httpRequest.post<any>(`/shop/order/saveOrder`, query)
  }

  //获取用户未支付的订单
  async function getUserUnPayHktOrder(query: any) {
    return await httpRequest.post<any>(`/shop/order/getUserUnPayHktOrder`, query)
  }

  //消息列表
  async function messagePage(query: any) {
    return await httpRequest.post<any>(`/shop/message/messagePage`, query)
  }

  //消息标记已读
  async function batchMessageIsRead(ids: any) {
    return await httpRequest.get<any>(`/shop/message/batchMessageIsRead?ids=${ids}`)
  }

  //退出登录
  async function userLogout() {
    return await httpRequest.get<any>(`/user/userLogin/userLogout`)
  }

  //发送验证码
  async function sendSMS(mobile: number) { 
    return await httpRequest.get<any>(`/aliyun/sms/sendSMS?mobile=${mobile}`)
  }

  //验证验证码
  async function checkMobileCode(query: any) {
    return await httpRequest.get<any>(`/user/userLogin/checkMobileCode?mobile=${query.mobile}&code=${query.code}`)
  }

  //更新用户信息
  async function updateUser(query: any) {
    return await httpRequest.post<any>(`/shop/userInfo/updateUser`, query)
  }

  //获取用户信息
  async function getUserInfo() {
    return await httpRequest.get<any>(`/shop/userInfo/getUserInfo`)
  }

  // bom匹配查询 
  async function bomQuery(query: any) {
    return await httpRequest.post<any>(`/shop/bom/matchBom`, query)
  }
  //查询bom详情
  async function get_bom_detail(query: any) {
    return await httpRequest.post<any>(`/shop/bom/findBomOrder`, query)
  }

  //修改bom名称
  async function bom_updata_name(query: any) {
    return await httpRequest.post<any>(`/shop/bom/updateBomOrder`, query)
  }

  //bom新增列表
  async function bom_add_list(query: any) {
    return await httpRequest.post<any>(`/detail/productListByBomParam`, query)
  }

  //bom删除
  async function bom_del(query: any) {
    return await httpRequest.post<any>(`/detail/delDetail`, query)
  }

  //查询bom订单
  async function get_bom_order(query: any) {
    return await httpRequest.post<any>(`/shop/bom/queryPage`, query)
  }

  //删除bom订单
  async function del_bom_order(query: any) {
    return await httpRequest.post<any>(`/shop/bom/delBomOrder`, query)
  }


  return {
    getNewsList, selectProductLike, selectProductHot, getProductDetail, saveCart, getNewsDetail, getCartList, getUserStatistics, getOrderList, getOrderDetail, getWarehouseMapList, getOrderInvoice, cancelOrder, saveHktFavorites, deleteFavorites, delCartGood, getUserAddress, updateUserAddress, setDefaultAddress, getCollectList, getUserInvoice, fileUploadWithPath, updateUserInvoice, UserScorePage, updateCart, calculateGoodsPrice, getHktExpressCompanyList, saveOrder, getUserUnPayHktOrder, messagePage, batchMessageIsRead, userLogout, sendSMS, checkMobileCode, updateUser, getUserInfo, bomQuery,get_bom_detail,bom_updata_name,bom_add_list,bom_del,batchCart,get_bom_order,del_bom_order
  }
}
