import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PtSubsidyVO, PtSubsidyForm, PtSubsidyQuery } from '@/api/cardCenter/subsidy/ptSubsidy/types';

/**
 * 查询补助设置列表
 * @param query
 * @returns {*}
 */
export const listPtSubsidy = (query?: PtSubsidyQuery): AxiosPromise<PtSubsidyVO[]> => {
  return request({
    url: '/backstage/subsidy/ptSubsidy/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询补助设置详细
 * @param mainId
 */
export const getPtSubsidy = (mainId: string | number): AxiosPromise<PtSubsidyVO> => {
  return request({
    url: '/backstage/subsidy/ptSubsidy/' + mainId,
    method: 'get'
  });
};

/**
 * 新增补助设置
 * @param data
 */
export const addPtSubsidy = (data: PtSubsidyForm) => {
  return request({
    url: '/backstage/subsidy/ptSubsidy',
    method: 'post',
    data: data
  });
};

/**
 * 修改补助设置
 * @param data
 */
export const updatePtSubsidy = (data: PtSubsidyForm) => {
  return request({
    url: '/backstage/subsidy/ptSubsidy',
    method: 'put',
    data: data
  });
};

/**
 * 删除补助设置
 * @param mainId
 */
export const delPtSubsidy = (mainId: string | number | Array<string | number>) => {
  return request({
    url: '/backstage/subsidy/ptSubsidy/' + mainId,
    method: 'delete'
  });
};

export const getCurrentDateString = () => {
    const now = new Date();
    const year = now.getFullYear();
    const month = (now.getMonth() + 1).toString().padStart(2, '0');
    const day = now.getDate().toString().padStart(2, '0');
    const hours = now.getHours().toString().padStart(2, '0');
    const minutes = now.getMinutes().toString().padStart(2, '0');
    const seconds = now.getSeconds().toString().padStart(2, '0');
    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;

};

export const getSubsidyName = () => {
  const now = new Date();
  const year = now.getFullYear();
  const month = (now.getMonth() + 1).toString().padStart(2, '0');
  return `${year}年${month}月补助`;

};
