import { StudentVO } from '@/api/edu/student/types';
import { ContractVO } from '@/api/edu/contract/types';
import { ScheduleVO } from '@/api/edu/schedule/types';
import { InterviewVO } from '@/api/edu/interview/types';
import { ExamVO } from '@/api/edu/exam/types';
import { RewardPunishVO } from '@/api/edu/reward/types';

/** 课时流水 */
export interface HoursLogVO {
  id: number | string;
  logNo: string;
  studentId: number | string;
  contractId: number | string;
  scheduleId: number | string;
  businessType: string;
  direction: string;
  hours: number;
  beforeHours: number;
  afterHours: number;
  rate: number;
  reason: string;
  operatorName: string;
  logTime: string;
}

/** 预警(精简) */
export interface AlertSimpleVO {
  id: number | string;
  alertType: string;
  level: string;
  title: string;
  content: string;
  status: string;
  createTime: string;
}

/** 员工服务关系(精简) */
export interface StaffRelationVO {
  id: number | string;
  staffId: number | string;
  studentId: number | string;
  staffRole: string;
  bindTime: string;
  unbindTime: string;
  isPrimary: string;
  status: string;
}

/** 学生完整生命周期档案 */
export interface StudentProfileVO {
  student: StudentVO;
  totalPurchasedHours: number;
  totalConsumedHours: number;
  totalRemainHours: number;
  totalGiftHours: number;
  totalAmount: number;
  totalPaidAmount: number;
  totalLessonCount: number;
  contracts: ContractVO[];
  schedules: ScheduleVO[];
  hoursLogs: HoursLogVO[];
  alerts: AlertSimpleVO[];
  currentStaff: any[];
  staffHistory: StaffRelationVO[];
  interviews: InterviewVO[];
  exams: ExamVO[];
  rewardPunishes: RewardPunishVO[];
}

/** 课时流水业务类型映射 */
export const hoursBizTypeOptions = [
  { label: '购买', value: 'PURCHASE', dir: '+', elTagType: 'success' },
  { label: '消课', value: 'CONSUME', dir: '-', elTagType: 'warning' },
  { label: '退费', value: 'REFUND', dir: '-', elTagType: 'danger' },
  { label: '转出', value: 'TRANSFER_OUT', dir: '-', elTagType: 'info' },
  { label: '转入', value: 'TRANSFER_IN', dir: '+', elTagType: 'primary' },
  { label: '赠送', value: 'GIFT', dir: '+', elTagType: 'success' },
  { label: '过期', value: 'EXPIRE', dir: '-', elTagType: 'danger' },
  { label: '调整', value: 'ADJUST', dir: '+', elTagType: 'primary' }
];

/** 员工角色映射(学生详情用) */
export const staffRoleMap: Record<string, string> = {
  SALES: '课程顾问',
  HOUSEKEEPER: '管家',
  TUTOR: '辅导老师',
  DOC_WRITER: '文书老师'
};

/** 合同状态/类型映射(详情用) */
export const contractStatusMap: Record<string, { label: string; tag: string }> = {
  '0': { label: '草稿', tag: 'info' },
  '1': { label: '待生效', tag: 'warning' },
  '2': { label: '执行中', tag: 'success' },
  '3': { label: '已结清', tag: 'primary' },
  '4': { label: '已退费', tag: 'danger' },
  '5': { label: '已转课', tag: 'warning' },
  '9': { label: '已作废', tag: 'info' }
};

export const scheduleStatusMap: Record<string, { label: string; tag: string }> = {
  '0': { label: '待上课', tag: 'info' },
  '1': { label: '已签到', tag: 'warning' },
  '2': { label: '已消课', tag: 'success' },
  '3': { label: '请假', tag: 'primary' },
  '4': { label: '已取消', tag: 'info' },
  '5': { label: '旷课', tag: 'danger' }
};
