/**
 * 营销活动管理 API
 */

import { get, post, put, del } from '@/utils/request';

export interface ActivityQueryParams {
  page?: number;
  pageSize?: number;
  activityName?: string;
  activityType?: number;
  status?: number;
}

export interface ActivityListResponse {
  list: any[];
  total: number;
  pageSize: number;
  currentPage: number;
}

/** 获取活动列表 */
export function getActivityList(params: ActivityQueryParams): Promise<ActivityListResponse> {
  return get('/marketing/activity/list', params);
}

/** 获取活动详情 */
export function getActivityById(id: number): Promise<any> {
  return get(`/marketing/activity/${id}`);
}

/** 创建活动 */
export function createActivity(data: any): Promise<any> {
  return post('/marketing/activity', data);
}

/** 更新活动 */
export function updateActivity(id: number, data: any): Promise<any> {
  return put(`/marketing/activity/${id}`, data);
}

/** 发布活动 */
export function publishActivity(id: number): Promise<any> {
  return put(`/marketing/activity/${id}/publish`);
}

/** 暂停活动 */
export function pauseActivity(id: number): Promise<any> {
  return put(`/marketing/activity/${id}/pause`);
}

/** 恢复活动 */
export function resumeActivity(id: number): Promise<any> {
  return put(`/marketing/activity/${id}/resume`);
}

/** 删除活动 */
export function deleteActivity(id: number): Promise<any> {
  return del(`/marketing/activity/${id}`);
}

/** 获取活动统计 */
export function getActivityStatistics(id: number): Promise<any> {
  return get(`/marketing/activity/${id}/statistics`);
}

/** 获取进行中的活动 */
export function getOngoingActivities(): Promise<any[]> {
  return get('/marketing/activity/ongoing');
}
