/**
 * 文件职责：营销中心营销日历 API 与 DTO 定义。
 */
import { requestClient } from '#/api/request';

/** 总览查询参数。 */
export interface MarketingCalendarOverviewQuery {
  month: number;
  storeId: string;
  year: number;
}

/** 日期头。 */
export interface MarketingCalendarDayDto {
  day: number;
  isToday: boolean;
  isWeekend: boolean;
}

/** 图例。 */
export interface MarketingCalendarLegendDto {
  color: string;
  label: string;
  type: string;
}

/** 顶部统计。 */
export interface MarketingCalendarStatsDto {
  estimatedDiscountAmount: number;
  maxConcurrentCount: number;
  ongoingCount: number;
  totalActivityCount: number;
}

/** 活动条。 */
export interface MarketingCalendarActivityBarDto {
  barId: string;
  endDay: number;
  isDimmed: boolean;
  isMilestone: boolean;
  label: string;
  startDay: number;
}

/** 详情字段。 */
export interface MarketingCalendarDetailFieldDto {
  label: string;
  value: string;
}

/** 活动详情。 */
export interface MarketingCalendarActivityDetailDto {
  description: string;
  fields: MarketingCalendarDetailFieldDto[];
  moduleName: string;
}

/** 活动。 */
export interface MarketingCalendarActivityDto {
  activityId: string;
  bars: MarketingCalendarActivityBarDto[];
  calendarType: string;
  color: string;
  detail: MarketingCalendarActivityDetailDto;
  displayStatus: string;
  endDate: string;
  estimatedDiscountAmount: number;
  isDimmed: boolean;
  name: string;
  sourceId: string;
  sourceType: string;
  startDate: string;
  summary: string;
}

/** 冲突活动摘要。 */
export interface MarketingCalendarConflictActivityDto {
  activityId: string;
  calendarType: string;
  color: string;
  displayStatus: string;
  name: string;
  summary: string;
}

/** 冲突区间。 */
export interface MarketingCalendarConflictDto {
  activities: MarketingCalendarConflictActivityDto[];
  activityCount: number;
  activityIds: string[];
  conflictId: string;
  endDay: number;
  maxConcurrentCount: number;
  startDay: number;
}

/** 冲突横幅。 */
export interface MarketingCalendarConflictBannerDto {
  activityCount: number;
  conflictCount: number;
  conflictId: string;
  endDay: number;
  maxConcurrentCount: number;
  startDay: number;
}

/** 营销日历总览。 */
export interface MarketingCalendarOverviewDto {
  activities: MarketingCalendarActivityDto[];
  conflictBanner: MarketingCalendarConflictBannerDto | null;
  conflicts: MarketingCalendarConflictDto[];
  days: MarketingCalendarDayDto[];
  legends: MarketingCalendarLegendDto[];
  month: string;
  monthEndDate: string;
  monthStartDate: string;
  monthValue: number;
  stats: MarketingCalendarStatsDto;
  todayDay: number;
  year: number;
}

/** 查询营销日历总览。 */
export async function getMarketingCalendarOverviewApi(
  params: MarketingCalendarOverviewQuery,
) {
  return requestClient.get<MarketingCalendarOverviewDto>(
    '/marketing/calendar/overview',
    {
      params,
    },
  );
}
