import type { LegacyPageResult } from '#/api/legacy/system';

import { requestClient } from '#/api/request';

const SPECIFIED_GIFT_WEEKLY_RANK_BASE =
  '/go/resident-activity/specified-gift-weekly-rank';
const SIGN_IN_REWARD_BASE = '/go/resident-activity/sign-in-reward';
const ROOM_TURNOVER_REWARD_BASE =
  '/go/resident-activity/room-turnover-reward';
const CP_BASE = '/resident-activity/cp';
const VIP_BASE = '/go/resident-activity/vip';
const RECHARGE_REWARD_BASE = '/go/resident-activity/recharge-reward';
const FIRST_RECHARGE_REWARD_BASE =
  '/go/resident-activity/first-recharge-reward';
const TASK_CENTER_BASE = '/go/resident-activity/task-center';
const VOICE_ROOM_RED_PACKET_BASE = '/go/resident-activity/voice-room-red-packet';
const VOICE_ROOM_ROCKET_BASE = '/go/resident-activity/voice-room-rocket';
const WHEEL_BASE = '/go/resident-activity/wheel';
const SMASH_GOLDEN_EGG_BASE = '/go/resident-activity/smash-golden-egg';

export async function getResidentInviteConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>('/resident-activity/invite/config', {
    params: { sysOrigin },
  });
}

export async function saveResidentInviteConfig(data: Record<string, any>) {
  return requestClient.post('/resident-activity/invite/config/save', data);
}

export async function pageResidentInviteInviter(params: Record<string, any>) {
  return requestClient.get<LegacyPageResult<Record<string, any>>>(
    '/resident-activity/invite/inviter/page',
    { params },
  );
}

export async function pageResidentInviteInvitee(params: Record<string, any>) {
  return requestClient.get<LegacyPageResult<Record<string, any>>>(
    '/resident-activity/invite/invitee/page',
    { params },
  );
}

export async function getResidentRegisterRewardConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>('/resident-activity/register-reward/config', {
    params: { sysOrigin },
  });
}

export async function saveResidentRegisterRewardConfig(data: Record<string, any>) {
  return requestClient.post('/resident-activity/register-reward/config/save', data);
}

export async function resetResidentRegisterRewardConfig(sysOrigin: string) {
  return requestClient.post('/resident-activity/register-reward/config/reset', {}, {
    params: { sysOrigin },
  });
}

export async function getResidentCpConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>(`${CP_BASE}/config`, {
    params: { sysOrigin },
  });
}

export async function saveResidentCpConfig(data: Record<string, any>) {
  return requestClient.post<Record<string, any>>(`${CP_BASE}/config/save`, data);
}

export async function pageResidentRegisterRewardDailyRecords(
  params: Record<string, any>,
) {
  return requestClient.get<Record<string, any>>(
    '/go/resident-activity/register-reward/daily-record/page',
    { params },
  );
}

export async function getResidentSignInRewardConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>(`${SIGN_IN_REWARD_BASE}/config`, {
    params: { sysOrigin },
  });
}

export async function saveResidentSignInRewardConfig(data: Record<string, any>) {
  return requestClient.post(`${SIGN_IN_REWARD_BASE}/config/save`, data);
}

export async function pageResidentSignInRewardRecords(params: Record<string, any>) {
  return requestClient.get<Record<string, any>>(`${SIGN_IN_REWARD_BASE}/record/page`, {
    params,
  });
}

export async function getResidentVipConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>(`${VIP_BASE}/config`, {
    params: { sysOrigin },
  });
}

export async function saveResidentVipConfig(data: Record<string, any>) {
  return requestClient.post<Record<string, any>>(`${VIP_BASE}/config/save`, data);
}

export async function pageResidentVipOrders(params: Record<string, any>) {
  return requestClient.get<Record<string, any>>(`${VIP_BASE}/order/page`, {
    params,
  });
}

export async function pageResidentVipUserStates(params: Record<string, any>) {
  return requestClient.get<Record<string, any>>(`${VIP_BASE}/user-state/page`, {
    params,
  });
}

export async function getResidentWheelConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>(`${WHEEL_BASE}/config`, {
    params: { sysOrigin },
  });
}

export async function saveResidentWheelConfig(data: Record<string, any>) {
  return requestClient.post<Record<string, any>>(`${WHEEL_BASE}/config/save`, data);
}

export async function saveResidentWheelCategoryConfig(data: Record<string, any>) {
  return requestClient.post<Record<string, any>>(
    `${WHEEL_BASE}/config/category/save`,
    data,
  );
}

export async function pageResidentWheelDrawRecords(params: Record<string, any>) {
  return requestClient.get<Record<string, any>>(`${WHEEL_BASE}/record/page`, {
    params,
  });
}

export async function retryResidentWheelDrawRecord(id: number | string) {
  return requestClient.post<Record<string, any>>(`${WHEEL_BASE}/record/retry`, {
    id,
  });
}

export async function getResidentSmashGoldenEggConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>(`${SMASH_GOLDEN_EGG_BASE}/config`, {
    params: { sysOrigin },
  });
}

export async function saveResidentSmashGoldenEggConfig(data: Record<string, any>) {
  return requestClient.post<Record<string, any>>(
    `${SMASH_GOLDEN_EGG_BASE}/config/save`,
    data,
  );
}

export async function pageResidentSmashGoldenEggDrawRecords(
  params: Record<string, any>,
) {
  return requestClient.get<Record<string, any>>(
    `${SMASH_GOLDEN_EGG_BASE}/draw-record/page`,
    { params },
  );
}

export async function getResidentRechargeRewardConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>(`${RECHARGE_REWARD_BASE}/config`, {
    params: { sysOrigin },
  });
}

export async function saveResidentRechargeRewardConfig(data: Record<string, any>) {
  return requestClient.post<Record<string, any>>(
    `${RECHARGE_REWARD_BASE}/config/save`,
    data,
  );
}

export async function pageResidentRechargeRewardClaimRecords(
  params: Record<string, any>,
) {
  return requestClient.get<Record<string, any>>(
    `${RECHARGE_REWARD_BASE}/claim-record/page`,
    { params },
  );
}

export async function getResidentFirstRechargeRewardConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>(
    `${FIRST_RECHARGE_REWARD_BASE}/config`,
    { params: { sysOrigin } },
  );
}

export async function saveResidentFirstRechargeRewardConfig(
  data: Record<string, any>,
) {
  return requestClient.post<Record<string, any>>(
    `${FIRST_RECHARGE_REWARD_BASE}/config/save`,
    data,
  );
}

export async function pageResidentFirstRechargeRewardGrantRecords(
  params: Record<string, any>,
) {
  return requestClient.get<Record<string, any>>(
    `${FIRST_RECHARGE_REWARD_BASE}/grant-record/page`,
    { params },
  );
}

export async function getResidentDailyTaskConfig(
  sysOrigin: string,
  taskCategory = 'DAILY',
) {
  return requestClient.get<Record<string, any>>(`${TASK_CENTER_BASE}/config`, {
    params: { sysOrigin, taskCategory },
  });
}

export async function saveResidentDailyTaskConfig(data: Record<string, any>) {
  return requestClient.post<Record<string, any>>(`${TASK_CENTER_BASE}/config/save`, {
    ...data,
    taskCategory: data.taskCategory || 'DAILY',
  });
}

export async function pageResidentDailyTaskClaimRecords(
  params: Record<string, any>,
) {
  return requestClient.get<Record<string, any>>(
    `${TASK_CENTER_BASE}/claim-record/page`,
    { params: { ...params, taskCategory: params.taskCategory || 'DAILY' } },
  );
}

export async function getVoiceRoomRedPacketConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>(`${VOICE_ROOM_RED_PACKET_BASE}/config`, {
    params: { sysOrigin },
  });
}

export async function saveVoiceRoomRedPacketConfig(data: Record<string, any>) {
  return requestClient.post<Record<string, any>>(
    `${VOICE_ROOM_RED_PACKET_BASE}/config/save`,
    data,
  );
}

export async function pageVoiceRoomRedPacketRecords(params: Record<string, any>) {
  return requestClient.get<Record<string, any>>(`${VOICE_ROOM_RED_PACKET_BASE}/records`, {
    params,
  });
}

export async function retryVoiceRoomRedPacketRefund(packetNo: string) {
  return requestClient.post<Record<string, any>>(
    `${VOICE_ROOM_RED_PACKET_BASE}/refund/retry`,
    { packetNo },
  );
}

export async function getVoiceRoomRocketConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>(`${VOICE_ROOM_ROCKET_BASE}/config`, {
    params: { sysOrigin },
  });
}

export async function saveVoiceRoomRocketConfig(data: Record<string, any>) {
  return requestClient.post<Record<string, any>>(
    `${VOICE_ROOM_ROCKET_BASE}/config/save`,
    data,
  );
}

export async function getVoiceRoomRocketLevelConfigs(sysOrigin: string) {
  return requestClient.get<Array<Record<string, any>>>(
    `${VOICE_ROOM_ROCKET_BASE}/level-configs`,
    { params: { sysOrigin } },
  );
}

export async function saveVoiceRoomRocketLevelConfigs(data: Record<string, any>) {
  return requestClient.post<Array<Record<string, any>>>(
    `${VOICE_ROOM_ROCKET_BASE}/level-configs/save`,
    data,
  );
}

export async function getVoiceRoomRocketRewardConfigs(params: Record<string, any>) {
  return requestClient.get<Array<Record<string, any>>>(
    `${VOICE_ROOM_ROCKET_BASE}/reward-configs`,
    { params },
  );
}

export async function saveVoiceRoomRocketRewardConfigs(data: Record<string, any>) {
  return requestClient.post<Array<Record<string, any>>>(
    `${VOICE_ROOM_ROCKET_BASE}/reward-configs/save`,
    data,
  );
}

export async function pageVoiceRoomRocketLaunchRecords(params: Record<string, any>) {
  return requestClient.get<Record<string, any>>(
    `${VOICE_ROOM_ROCKET_BASE}/launch-records`,
    { params },
  );
}

export async function pageVoiceRoomRocketRewardRecords(params: Record<string, any>) {
  return requestClient.get<Record<string, any>>(
    `${VOICE_ROOM_ROCKET_BASE}/reward-records`,
    { params },
  );
}

export async function retryVoiceRoomRocketRewardRecord(id: number | string) {
  return requestClient.post<Record<string, any>>(
    `${VOICE_ROOM_ROCKET_BASE}/reward-records/retry`,
    { id },
  );
}

export async function pageSpecifiedGiftWeeklyRankConfigs(params: Record<string, any>) {
  return requestClient.get<LegacyPageResult<Record<string, any>>>(
    `${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/config/page`,
    { params },
  );
}

export async function getSpecifiedGiftWeeklyRankConfig(params: Record<string, any>) {
  return requestClient.get<Record<string, any>>(
    `${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/config`,
    { params },
  );
}

export async function saveSpecifiedGiftWeeklyRankConfig(data: Record<string, any>) {
  return requestClient.post(`${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/config/save`, data);
}

export async function getSpecifiedGiftWeeklyRankCurrentRank(
  params: Record<string, any>,
) {
  return requestClient.get<Record<string, any>>(
    `${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/current-rank`,
    { params },
  );
}

export async function pageSpecifiedGiftWeeklyRankSnapshots(params: Record<string, any>) {
  return requestClient.get<LegacyPageResult<Record<string, any>>>(
    `${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/snapshot/page`,
    { params },
  );
}

export async function pageSpecifiedGiftWeeklyRankRewardRecords(
  params: Record<string, any>,
) {
  return requestClient.get<LegacyPageResult<Record<string, any>>>(
    `${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/reward-record/page`,
    { params },
  );
}

export async function retrySpecifiedGiftWeeklyRankRewardRecord(id: number | string) {
  return requestClient.post<Record<string, any>>(
    `${SPECIFIED_GIFT_WEEKLY_RANK_BASE}/reward-record/retry`,
    { id },
  );
}

export async function getWeekStarConfig(params: Record<string, any>) {
  return getSpecifiedGiftWeeklyRankConfig(params);
}

export async function saveWeekStarConfig(data: Record<string, any>) {
  return saveSpecifiedGiftWeeklyRankConfig(data);
}

export async function pageWeekStarConfigs(params: Record<string, any>) {
  return pageSpecifiedGiftWeeklyRankConfigs(params);
}

export async function pageWeekStarSnapshots(params: Record<string, any>) {
  return pageSpecifiedGiftWeeklyRankSnapshots(params);
}

export async function pageWeekStarRewardRecords(params: Record<string, any>) {
  return pageSpecifiedGiftWeeklyRankRewardRecords(params);
}

export async function retryWeekStarRewardRecord(id: number | string) {
  return retrySpecifiedGiftWeeklyRankRewardRecord(id);
}

export async function getRoomTurnoverRewardConfig(sysOrigin: string) {
  return requestClient.get<Record<string, any>>(`${ROOM_TURNOVER_REWARD_BASE}/config`, {
    params: { sysOrigin },
  });
}

export async function saveRoomTurnoverRewardConfig(data: Record<string, any>) {
  return requestClient.post<Record<string, any>>(
    `${ROOM_TURNOVER_REWARD_BASE}/config/save`,
    data,
  );
}

export async function getRoomTurnoverRewardCurrentRank(params: Record<string, any>) {
  return requestClient.get<Record<string, any>>(
    `${ROOM_TURNOVER_REWARD_BASE}/current-rank`,
    { params },
  );
}

export async function pageRoomTurnoverRewardRecords(params: Record<string, any>) {
  return requestClient.get<LegacyPageResult<Record<string, any>>>(
    `${ROOM_TURNOVER_REWARD_BASE}/reward-record/page`,
    { params },
  );
}
