import { $post } from '@/utils'

export const SELLER_GOODS_UP = (params) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/goods/up', params);
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_GOODS_DOWN = (id = null) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/goods/down', { id });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_GOODS_INFO = (params) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/goods/info', params);
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_ADD_CART = (params) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/add/cart', params);
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_DEL_DOWN = (id = null) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/del/cart', { id });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_CART_COUNT = () => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/cart/count');
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_CART_LIsts = () => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/cart/lists');
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_CART_CONFIRM = (params) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/cart/confirm', params);
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_ORDER_SUBMIT = (params) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/order/submit', params);
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})


export const SELLER_DEL_CART = (id = null) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/del/cart', { id });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})


export const SELLER_ORDER_DETAIL = (orderid = null) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/order/detail', { orderid });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_ORDER_FINISH = (orderid = null) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/order/finish', { orderid });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_ORDER_CANCEL = (orderid = null) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/order/cancel', { orderid });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_ORDER_GETPAY = (orderids = null) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/order/getpay', { orderids });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_SELLER_INFO = (params) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/seller/info', params);
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_APPLY_SELLER = (params) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/apply/seller', params);
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})


export const SELLER_SELLER_DETAIL = (orderid = null) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/seller/detail', { orderid });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})

export const SELLER_SELLER_GETPAY = (orderids = null) => new Promise(async (resolve, reject) => {
  try {
    const res = await $post('/seller/seller/getpay', { orderids });
    const { ret } = res.data
    if (ret == 1) {
      resolve(res.data)
    }
    reject(res.data)
  } catch (error) { }
})


