import request from '@/config/axios'

// 幸运抽奖-活动 VO
export interface LuckLotteryVO {
  id: number // id
  name: string // 奖品名称
  type: string // 类别（1九宫格 2大转盘 3九宫格升级版 4幸运翻牌）
  factor: string // 抽奖消耗 (1积分 2余额 3下单支付成功 4关注 5订单评价)
  factorNum: number // 获取一次抽奖的条件数量
  desc: string // 活动描述
  image: string // 活动背景图
  attendsUser: boolean // 参与用户(1所有 2部分)
  userLevel: string // 参与用户等级
  userLabel: string // 参与用户标签
  isSvip: boolean // 参与用户是否付费会员
  prizeNum: number // 奖品数量
  startTime: Date // 开始时间
  endTime: Date // 结束时间
  lotteryNumTerm: number // 抽奖次数限制(1每天 2每人)
  lotteryNum: number // 抽奖次数
  spreadNum: number // 关注推广获取抽奖次数
  isAllRecord: boolean // 中奖记录展示
  isPersonalRecord: boolean // 个人中奖纪录展示
  isContent: boolean // 活动规格是否展示
  content: string // 活动文案抽奖协议之类
  sort: number // 排序
  status: string // 状态
}

// 幸运抽奖-活动 API
export const LuckLotteryApi = {
  // 查询幸运抽奖-活动分页
  getLuckLotteryPage: async (params: any) => {
    return await request.get({ url: `/promotion/luck-lottery/page`, params })
  },

  // 查询幸运抽奖-活动详情
  getLuckLottery: async (id: number) => {
    return await request.get({ url: `/promotion/luck-lottery/get?id=` + id })
  },

  // 新增幸运抽奖-活动
  createLuckLottery: async (data: LuckLotteryVO) => {
    return await request.post({ url: `/promotion/luck-lottery/create`, data })
  },

  // 修改幸运抽奖-活动
  updateLuckLottery: async (data: LuckLotteryVO) => {
    return await request.put({ url: `/promotion/luck-lottery/update`, data })
  },

  // 删除幸运抽奖-活动
  deleteLuckLottery: async (id: number) => {
    return await request.delete({ url: `/promotion/luck-lottery/delete?id=` + id })
  },

  // 导出奖品模板 Excel
  exportLotteryPrizeTemplate: async () => {
    return await request.download({ url: `/promotion/luck-prize/import-template` })
  },

  // 批量导入奖品 Excel
  importLotteryPrizeData: async (data: any) => {
    return await request.upload({ url: `/promotion/luck-prize/import`, data })
  },

  // 查询幸运抽奖-奖品分页
  getLuckLotteryPrizePage: async (params: any) => {
    return await request.get({ url: `/promotion/luck-prize/page`, params })
  },

  // 查询幸运抽奖-奖品
  getLuckLotteryPrize: async (id: number) => {
    return await request.get({ url: `/promotion/luck-prize/get?id=${id}` })
  },

  // 新增幸运抽奖-奖品
  createLuckLotteryPrize: async (data: any) => {
    return await request.post({ url: `/promotion/luck-prize/create`, data })
  },

  // 修改幸运抽奖-奖品
  updateLuckLotteryPrize: async (data: any) => {
    return await request.put({ url: `/promotion/luck-prize/update`, data })
  },

  // 删除幸运抽奖-奖品
  deleteLuckLotteryPrize: async (id: number) => {
    return await request.delete({ url: `/promotion/luck-prize/delete?id=` + id })
  },
}