import { http } from '@/utils/http'
import type { Coupon2Type } from '@/types/coupon2'
import type { ListType, ListResponseType } from '@/types/list'
import { parseQueryValues } from '@/utils'

/** 获取商品可用优惠券列表 */
export const getCoupon2ViewmListApi = (params: Partial<Coupon2Type>, page: Partial<ListType>) => {
  return http.get<ListResponseType<Coupon2Type>>('/api/query/list?pagevalue=100', {
    ...page,
    ...parseQueryValues(params),
  })
}

/** 获取优惠券详情 */
export const getCoupon2DetailApi = (params: Partial<Coupon2Type>) => {
  return http.get<Coupon2Type>(
    '/api/query/view?pagevalue=105',
    {
      ...parseQueryValues(params),
    },
    {
      formatData: true,
    },
  )
}

/** 优惠劵审核修改 */
export const getCoupon2ModifyApi = (params: Partial<Coupon2Type>) => {
  return http.get<any>('/api/nlua/call?pagevalue=106', {
    ...params,
  })
}

/** 优惠劵审核_列表 **/
export const getCoupon2AuditListApi = (params: Partial<any>, page: Partial<ListType>) => {
  return http.get<any>('/api/query/list?pagevalue=109', {
    ...page,
    ...parseQueryValues(params),
    'coupon2adddatetime.Sort': '1', // desc
  })
}

/** 优惠劵审核_详情 **/
export const getCoupon2AuditDetailApi = (params: Partial<any>) => {
  return http.get<any>(
    '/api/query/view?pagevalue=110',
    {
      ...parseQueryValues(params),
    },
    {
      formatData: true,
    },
  )
}

/** 优惠劵审核_提交 **/
export const submitCoupon2AuditApi = (params: Partial<any>) => {
  return http.get<any>('/api/nlua/call?pagevalue=111', {
    ...params,
  })
}
