import http from './request'

/** 系统 **/
// 登录微信公众号
export function wxMpJsapiGetJsapiTicket(params: object) {
  return http.request({
    url: '/wx/mp/jsapi/getJsapiTicket',
    method: 'get',
    params: params
  })
}

export function sysLog(id: number) {
  return http.request({
    url: `/sys/user/log/app/info/${id}`,
    method: 'get',
  })
}
// 登录
export function sysLogin(data: object) {
  return http.request({
    url: '/sys/login',
    method: 'post',
    data: data
  })
}

// 公众号快捷登录（通过OAuth code）
export function wxH5QuickLogin(params: { code: string }) {
  return http.request({
    url: '/wx/h5/quickLogin',
    method: 'get',
    params
  })
}

// 当前登录用户绑定微信（通过OAuth code）
export function sysWxBindByCode(params: { code: string }) {
  return http.request({
    url: '/sys/wx/bind',
    method: 'post',
    params
  })
}

export function sysMenuNav() {
  return http.request({
    url: '/sys/menu/nav',
    method: 'get'
  })
}

// 获取用户信息
export function sysUserInfo() {
  return http.request({
    url: '/sys/user/info',
    method: 'get'
  })
}

// 获取研究员和管理层
export function sysUserGetStaffAndManagerList() {
  return http.request({
    url: '/sys/user/getStaffAndManagerList',
    method: 'get'
  })
}

// 获取销售和管理层
export function sysUserGetSaleAndManagerList() {
  return http.request({
    url: '/sys/user/getSaleAndManagerList',
    method: 'get'
  })
}

// 员工列表
export function workStaffLookup() {
  return http.request({
    url: '/work/staff/lookup',
    method: 'get'
  })
}

// 获取全公司
export function sysUserGetCompanyUserList() {
  return http.request({
    url: '/sys/user/getCompanyUserList',
    method: 'get'
  })
}

// 根据类型获取字典
export function sysDicListByType(params: object) {
  return http.request({
    url: '/sys/dic/listByType',
    method: 'get',
    params: params
  })
}

// 根据类型和note获取字典
export function sysDicListByNote(params: object) {
  return http.request({
    url: '/sys/dic/listByNote',
    method: 'get',
    params: params
  })
}

/** 点评 **/
// 点评列表
export function workInboxList(params: object) {
  return http.request({
    url: '/work/inbox/list',
    method: 'get',
    params: params
  })
}

// 点评详情
export function workInboxInfo(inboxId: string) {
  return http.request({
    url: `/work/inbox/info/${inboxId}`,
    method: 'get'
  })
}

/** 会议 **/
// 会议列表
export function workMeetingList(query: string) {
  return http.request({
    url: `/work/meeting/list?${query}`,
    method: 'get'
  })
}

export function workMeetingUpdateOrSave(type: string, data: object) {
  return http.request({
    url: `/work/meeting/${type ? 'update' : 'save'}`,
    method: type ? 'put' : 'post',
    data: data
  })
}

// 会议详情
export function workMeetingInfo(meetingId: string) {
  return http.request({
    url: `/work/meeting/info/${meetingId}`,
    method: 'get'
  })
}

// 删除会议
export function workMeetingDelete(meetingId: string) {
  return http.request(
    {
      url: '/work/meeting/delete',
      method: 'delete',
      data: [meetingId]
    },
    true
  )
}

// 会议可见人员
export function workMeetingUserList(params: object) {
  return http.request({
    url: '/work/meeting/user/list',
    method: 'get',
    params: params
  })
}

// 通过会议id获取会议资料
export function workMeetingGetFileId(params: object) {
  return http.request({
    url: '/work/meeting/getFileId',
    method: 'get',
    params: params
  })
}

// 通过会议id获取参会资料
export function workMeetinGetUserFileMenuId(params: object) {
  return http.request({
    url: '/work/meeting/getUserFileMenuId',
    method: 'get',
    params: params
  })
}

// 反查会议
export function workMeetingLookUp(params: object) {
  return http.request({
    url: '/work/meeting/lookup',
    method: 'get',
    params: params
  })
}

// 参会人员
export function cusUserMeetingLogList(params: object) {
  return http.request({
    url: '/cus/usermeetinglog/list',
    method: 'get',
    params: params
  })
}

// 删除参会人员
export function cusUserMeetingLogDelete(data: object) {
  return http.request(
    {
      url: '/cus/usermeetinglog/delete',
      method: 'delete',
      data: data
    },
    true
  )
}

// 修改或新增参会人员
export function cusUserMeetingLogUpdateOrSave(type: string, data: object) {
  return http.request(
    {
      url: `/cus/usermeetinglog/${type ? 'update' : 'save'}`,
      method: type ? 'put' : 'post',
      data: type ? data : [data]
    },
    !!type
  )
}

// 获取文件列表
export function workFileListByMenuId(params: object) {
  return http.request({
    url: '/work/file/listByMenuId',
    method: 'get',
    params: params
  })
}

/** 报告 **/
// 报告列表
export function stockReportList(query: string, params: object) {
  return http.request({
    url: `/stock/report/list${query}`,
    method: 'get',
    params: params
  })
}

/** 沟通 **/
// 沟通列表
export async function cusLinkList(query: string) {
  const { data } = await http.request({
    url: `/cus/link/list?${query}`,
    method: 'get'
  })
  return data.list.map((ele: any) => {
    ele.sysDay = ele.sysDate.slice(0, 10)
    switch (ele.linkType) {
      case '32':
        ele.tagColor = 'danger-background-color'
        break
      case '34':
        ele.tagColor = 'primary-background-color'
        break
      case '31':
        ele.tagColor = 'success-background-color'
        break
    }
    return ele
  })
}

// 沟通详情
export function cusLinkInfo(linkId: string) {
  return http.request({
    url: `/cus/link/info/${linkId}`,
    method: 'get'
  })
}

// 删除沟通
export function cusLinkDeleteByOne(params: object) {
  return http.request({
    url: '/cus/link/deleteByOne',
    method: 'delete',
    params: params
  })
}

// 修改新增沟通
export function cusLinkUpdateOrSave(type: string, data: object) {
  return http.request({
    url: `/cus/link/${type ? 'update' : 'save'}`,
    method: type ? 'put' : 'post',
    data: type ? data : { cusLinkEntityList: [data] }
  })
}

// 反查机构
export function cusInfoLookUp(params: object) {
  return http.request({
    url: '/cus/info/lookup',
    method: 'get',
    params: params
  })
}

// 新增机构
export function cusInfoSave(data: object) {
  return http.request({
    url: '/cus/info/save',
    method: 'post',
    data: data
  })
}
// 机构列表
export function cusInfoList(params: object) {
  return http.request({
    url: 'cus/info/list',
    method: 'get',
    params
  })
}
export function cusInfoInfo(id: number) {
  return http.request({
    url: `cus/info/info/${id}`,
    method: 'get'
  })
}
export function cusServiceGetByCusId (params: object) {
  return http.request({
    url: '/cus/service/getByCusId',
    method: 'get',
    params
  })
}
export function cusYearList (params: object) {
  return http.request({
    url: '/cus/year/list',
    method: 'get',
    params
  })
}
export function cusAccountList (params: object) {
  return http.request({
    url: '/cus/account/list',
    method: 'get',
    params
  })
}
export function cusMeetingList (params: object) {
  return http.request({
    url: '/cus/usermeetinglog/listByCusId',
    method: 'get',
    params
  })
}
export function cusInfoCountByMonth (params: object) {
  return http.request({
    url: '/cus/info/countByMonth',
    method: 'get',
    params
  })
}

// 交易详情
export function stockCusTradeMyTrade () {
  return http.request({
    url: '/stock/cus/trade/myTrade',
    method: 'get'
  })
}

// 反查联系人
export function cusUserLookUp(params: object) {
  return http.request({
    url: '/cus/user/lookup',
    method: 'get',
    params: params
  })
}

export function cusUserCusPositionList() {
  return http.request({
    url: '/cus/user/cusPositionList',
    method: 'get'
  })
}

export function cusUserSave(data: object) {
  return http.request({
    url: '/cus/user/save',
    method: 'post',
    data: data
  })
}

// 通过机构获取联系人
export function cusUserListByCusId(params: object) {
  return http.request({
    url: '/cus/user/listByCusId',
    method: 'get',
    params: params
  })
}

/* 股票 */
// 股票列表
export function stockStockinfoEventNews(params: object) {
  return http.request({
    url: '/stock/stockinfo/event/news',
    method: 'get',
    params: params
  })
}

export function stockStockinfoEventList(params: object) {
  return http.request({
    url: '/stock/stockinfo/event/list',
    method: 'get',
    params: params
  })
}

// 反查股票
export function stockStockInfoLookUp(params: object) {
  return http.request({
    url: '/stock/stockinfo/lookup',
    method: 'get',
    params: params
  })
}

export function reportEconomyMonthDepositVsM2() {
  return http.request({
    url: '/report/economy/month/depositVsM2',
    method: 'get'
  })
}

export function reportEconomyMonthMarketHSVsDeposit() {
  return http.request({
    url: '/report/economy/month/marketHSVsDeposit',
    method: 'get'
  })
}

export function reportEconomyMonthMarketHSJVsDeposit() {
  return http.request({
    url: '/report/economy/month/marketHSJVsDeposit',
    method: 'get'
  })
}

export function reportEconomyMonthListByItem(params: object) {
  return http.request({
    url: '/report/economy/month/listByItem',
    method: 'get',
    params: params
  })
}

export function stockStockrzrqQueryRzrq() {
  return http.request({
    url: '/stock/stockrzrq/queryRzrq',
    method: 'get'
  })
}

export function stockStockrzrqQueryRzToTotalMarket() {
  return http.request({
    url: '/stock/stockrzrq/queryRzToTotalMarket',
    method: 'get'
  })
}

export function stockStockrzrqQueryRzjme(params: object) {
  return http.request({
    url: 'stock/stockrzrq/queryRzjme',
    method: 'get',
    params: params
  })
}

export function reportEconomyMonthStockShares() {
  return http.request({
    url: '/report/economy/month/stockShares',
    method: 'get'
  })
}

export function reportEconomyMonthStockMarket() {
  return http.request({
    url: '/report/economy/month/stockMarket',
    method: 'get'
  })
}

export function reportEconomyMonthStockAmount() {
  return http.request({
    url: '/report/economy/month/stockAmount',
    method: 'get'
  })
}

export function reportEconomyMonthStockTurnoverRate() {
  return http.request({
    url: '/report/economy/month/stockTurnoverRate',
    method: 'get'
  })
}

export function reportEconomyMonthStockVolume() {
  return http.request({
    url: '/report/economy/month/stockVolume',
    method: 'get'
  })
}

export function reportEconomyMonthNewAccountNum() {
  return http.request({
    url: '/report/economy/month/newAccountNum',
    method: 'get'
  })
}

export function stockStockHsList() {
  return http.request({
    url: '/stock/stockhs/list',
    method: 'get'
  })
}

export function fredInfoList() {
  return http.request({
    url: '/fred/info/list',
    method: 'get'
  })
}

export function fredInfoInfo(id: string) {
  return http.request({
    url: `/fred/info/info/${id}`,
    method: 'get'
  })
}

export function fredDetailQueryAaaAndBbb(params: object) {
  return http.request({
    url: '/fred/detail/query/AaaAndBbb',
    method: 'get',
    params: params
  })
}

export function fredDetailQueryFred(params: object) {
  return http.request({
    url: '/fred/detail/queryFred',
    method: 'get',
    params: params
  })
}

export const indexInfoSeries = (params: object) => {
  return http.request({
    url: '/index/info/series',
    method: 'get',
    params: params
  })
}

export const indexInfo = (id: string) => {
  return http.request({
    url: `/index/info/${id}`,
    method: 'get'
  })
}

export const indexInfoIndexHistChart = (id: string) => {
  return http.request({
    url: `/index/info/indexHistChart/${id}`,
    method: 'get'
  })
}

export function indexFundHisQueryFundHis(params: object) {
  return http.request({
    url: '/index/fund/his/queryFundHis',
    method: 'get',
    params: params
  })
}

export const indexInfoIndustry1Chart = (id: string) => {
  return http.request({
    url: `/index/info/industry1Chart/${id}`,
    method: 'get'
  })
}

export const indexInfoIndustry2Chart = (id: string) => {
  return http.request({
    url: `/index/info/industry2Chart/${id}`,
    method: 'get'
  })
}

export const indexInfoStockGetChart = (params: object)  => {
  return http.request({
    url: '/index/info/stock/getChart',
    method: 'get',
    params: params
  })
}

export function indexFundList(params: object) {
  return http.request({
    url: '/index/fund/list',
    method: 'get',
    params: params
  })
}

export function indexFundGetByEtfCode(params: object) {
  return http.request({
    url: '/index/fund/getByEtfCode',
    method: 'get',
    params: params
  })
}

export function indexFundHisQueryEtfShareHis(params: object) {
  return http.request({
    url: '/index/fund/his/queryEtfShareHis',
    method: 'get',
    params: params
  })
}

export function indexFundDetailDayCoinList(params: object) {
  return http.request({
    url: '/index/fund/detail/day/coinList',
    method: 'get',
    params: params
  })
}

export function indexFundDetailDayList(params: object) {
  return http.request({
    url: '/index/fund/detail/day/list',
    method: 'get',
    params: params
  })
}

export function indexFundDetailQuarterCircleByExchange(params: object) {
  return http.request({
    url: '/index/fund/detail/quarter/circleByExchange',
    method: 'get',
    params: params
  })
}

export function indexFundDetailQuarterHisByExchange(params: object) {
  return http.request({
    url: '/index/fund/detail/quarter/hisByExchange',
    method: 'get',
    params: params
  })
}

export function indexFundDetailQuarterGetChart(params: object) {
  return http.request({
    url: '/index/fund/detail/quarter/getChart',
    method: 'get',
    params: params
  })
}

export function stockAFundList(params: object) {
  return http.request({
    url: '/stock/a/fund/list',
    method: 'get',
    params: params
  })
}

export const stockAFundInfo = (id: string) => {
  return http.request({
    url: `/stock/a/fund/info/${id}`,
    method: 'get'
  })
}

export function stockAFundHisFundHisChart(params: object) {
  return http.request({
    url: '/stock/a/fund/his/fundHis/chart',
    method: 'get',
    params: params
  })
}

export function stockAFundFileList(params: object) {
  return http.request({
    url: '/stock/a/fund/file/list',
    method: 'get',
    params: params
  })
}

export function stockAFundHisFundHisList(params: object) {
  return http.request({
    url: '/stock/a/fund/his/fundHis/list',
    method: 'get',
    params: params
  })
}

export function stockAFundListFund() {
  return http.request({
    url: 'stock/a/fund/listFund',
    method: 'get'
  })
}

export const groupList = (params: string) => {
  return http.request({
    url: `/group/list?${params}`,
    method: 'get'
  })
}

export function groupInfo(id: string) {
  return http.request({
    url: `/group/info/${id}`,
    method: 'get'
  })
}

export function groupHisChartIncomeRate(params: object) {
  return http.request({
    url: '/group/his/chart/incomeRate',
    method: 'get',
    params: params
  })
}

export function groupHoldList (params: object) {
  return http.request({
    url: '/group/holdList',
    method: 'get',
    params
  })
}

export function groupTradeList(params: object) {
  return http.request({
    url: '/group/trade/list',
    method: 'get',
    params: params
  })
}

export function stockEtfDetailLookup(params: object) {
  return http.request({
    url: '/stock/etf/detail/lookup',
    method: 'get',
    params: params
  })
}

// 内部会议
export function workSpeakList(params: object) {
  return http.request({
    url: '/work/speak/list',
    method: 'get',
    params: params
  })
}


// 获取订阅信息
export function getSubscriptionList() {
  return http.request({
    url: '/stock/subscription/config/list',
    method: 'get'
  })
}

export function delSubscription(id: number) {
  return http.request({
    url: '/stock/subscription/config/delete',
    method: 'delete',
    params: {
      id
    }
  })
}

export function saveSubscription(subscriptionItem: string) {
  return http.request({
    url: '/stock/subscription/config/save',
    method: 'post',
    data: {
      subscriptionItem
    }
  })
}

// 重点公司追踪
export function stockCompanyFlowInfoListCompany() {
  return http.request({
    url: '/stock/company/follow/info/listCompany',
    method: 'get'
  })
}

export function stockCompanyFlowInfoList(params: object) {
  return http.request({
    url: '/stock/company/follow/info/list',
    method: 'get',
    params: params
  })
}

export function stockCompanyFlowInfoInfo(id: number) {
  return http.request({
    url: `/stock/company/follow/info/info/${id}`,
    method: 'get'
  })
}
