// 活动服务 - 优惠券等
import { post, postL } from './http';

const apis = {
  COUPON_LIST_VALID: '/api/coupon/listValidCoupon',
  COUPON_BATCH_RECEIVE: '/api/coupon/batchReceive',
};

// 获取可领优惠券列表
export interface CouponItem {
  id: string;
  amount: number;
  fullAmount: number;
  endTime: string;
  name?: string;
}

export const listValidCoupon = async (scene: string, targetObj?: any) => {
  const res = await post<CouponItem[]>(apis.COUPON_LIST_VALID, { scene, targetObj });
  return res.success && res.data ? res.data : [];
};

// 一键领取优惠券
export const batchReceiveCoupon = async (ids: string[]) => {
  const res = await postL<any>(apis.COUPON_BATCH_RECEIVE, { ids });
  return res.success;
};
