import { httpDelete, httpGet, httpPost, httpPut } from '../../utils/http'
import {
  ResPageData,
  Designer,
  AgentTask,
  ReportInfo,
  FollowUp,
  DesignerBasicInfo,
  DesignerEvent,
  DesignerFamilyInfo,
  AgentPoint,
} from '@designer-hub/app/src/core/libs/models'
/**
 * 通过ID获取用户信息
 */
export const getUserInfoById = (id: string | number) =>
  httpGet<
    Partial<{
      mobile: string
      status: string
      nickname: string
      avatar: string
      name: string
      sex: string
      areaId: number
      areaName: string
      birthday: string
      mark: string
      tagIds: string
      levelId: number
      groupId: number
      id: number
      registerIp: string
      loginIp: string
      loginDate: string
      createTime: string
      point: number
      totalPoint: number
      tagNames: string
      levelName: string
      groupName: string
      experience: number
    }>
  >('/app-api/member/user/getByUserId', { id })
/**
 * 获取设计师信息
 */
// export const getDesignerInfo = (userId: number) =>
//   httpGet<Designer>('/app-api/member/designer/getDesignerInfo', { userId })
/**
 * 获取设计师基本信息
 */
export const getDesignerBasicInfo = (userId: number) =>
  httpGet<DesignerBasicInfo>('/app-api/member/stylist-basic-info/get', { userId })
/**
 * 更新设计师基本信息
 */
export const updateDesignerBasicInfo = (data: Partial<DesignerBasicInfo>) =>
  httpPut('/app-api/member/stylist-basic-info/update', data)
/**
 * 获取设计师家庭信息
 */
export const getDesignerFamilyInfo = (query = {}) =>
  httpGet<ResPageData<DesignerFamilyInfo>>('/app-api/member/stylist-family/list', query)
/**
 * 保存设计师家庭信息
 */
export const saveDesignerFamilyInfo = (data: Partial<DesignerFamilyInfo>) =>
  httpPost('/app-api/member/stylist-family/save', data)
/**
 * 获取设计师额外事件
 */
export const getDesignerExtraEvents = (query = {}) =>
  httpGet<ResPageData<DesignerEvent>>('/app-api/member/stylist-extra-events/pageInfo', query)
/**
 * /app-api/member/stylist-extra-events/getStudyAndActivity 获取设计师学习和活动
 */
export const getDesignerActivityEvents = (userId: number) =>
  httpGet<{
    [key in 'study' | 'activity' | 'extraEventsQuantity']:
      | { type: number; quantity: number }[]
      | number
  }>('/app-api/member/stylist-extra-events/getStudyAndActivity', { userId })
/**
 * 设计师列表
 */
export const getDesigners = (query = {}) =>
  httpGet<ResPageData<Designer>>('/app-api/member/app-broker/pageStylist', query)
/**
 * 任务列表
 */
export const getTasks = (query = {}) =>
  httpGet<ResPageData<AgentTask>>('/app-api/member/task/page', query)
/**
 * 关系报备
 */
export const getReportInfoPage = (query = {}) =>
  httpGet<ResPageData<ReportInfo>>('/app-api/member/report-info/page', query)
/**
 * 删除关系报备
 */
export const deleteReportInfo = (id: number) =>
  httpDelete(`/app-api/member/report-info/delete`, { id })
/**
 * 创建设计师跟进
 */
export const createFollowUp = (data: Partial<FollowUp>) =>
  httpPost('/app-api/member/stylist-follow-up/create', data)
/**
 * 获取设计师跟进列表
 */
export const getFollowUpPage = (query = {}) =>
  httpGet<ResPageData<FollowUp & { followTypeName: string; brokerName: string }>>(
    '/app-api/member/stylist-follow-up/page',
    query,
  )
/**
 * 更新设计师跟进
 */
export const updateFollowUp = (data: Partial<FollowUp>) =>
  httpPut('/app-api/member/stylist-follow-up/update', data)
/**
 * /app-api/member/user-auth-info/focus 重点跟进或取消
 */
export const focusOrCancel = (data: { brokerId: number; userId: number }) =>
  httpPost('/app-api/member/user-auth-info/focus', data)
/**
 * /app-api/member/task/points_flow 积分流水
 */
export const getPointsFlow = (query = {}) =>
  httpGet<ResPageData<AgentPoint>>('/app-api/member/task/points_flow', query)
/**
 * /app-api/member/points-details/pageAllByYear/2024?pageNo=1&pageSize=10&stylistId=287&year=2024 设计师积分详情
 */
export const getPointsDetails = (query: { year?: string } = {}) =>
  httpGet<
    ResPageData<{
      id: number
      pointsType: string
      typeName: string
      pointsCategory: string
      categoryName: string
      sourceId: number
      name: string
      pointsStauts: string
      points: number
      orderMoney: string
      materialsId: number
      materialsBrand: string
      stylistId: number
      brokerId: number
      stylistName: string
      brokerName: string
      generateTime: string
      verifyTime: string
      completeTime: string
      turnDownTime: string
      cancelTime: string
      cancelReason: string
      turnDownReason: string
      remark: string
      couponId: number
      orderNo: string
      createTime: string
    }>
  >(`/app-api/member/points-details/pageAllByYear/${query.year}`, query)
