import { IrsBrokerRankDto, SpecificationDto } from '@amc-udk/types' export const RankUtils = { /** * 根据评分日期设置状态 */ setStatusByDate: (dto: IrsBrokerRankDto): IrsBrokerRankDto => { const start = new Date(dto.startDate).valueOf() const end = new Date(dto.endDate).valueOf() const now = new Date().valueOf() if (now < start) { dto.status = 'NOTSTARTED' } else if (now > end) { dto.status = 'ENDED' } else { dto.status = 'ONGOING' } return dto }, isOngoing: (dto: IrsBrokerRankDto): boolean => dto && dto.status === 'ONGOING', createDateRangeSearchSpecs: (dto: IrsBrokerRankDto): SpecificationDto[] => { return [ { field: 'sDate', type: 'ge', value: dto.startDate, valueType: 'date', conjunct: 'and', }, { field: 'sDate', type: 'le', value: dto.endDate, valueType: 'date', conjunct: 'and', }, ] }, createUnVoteListSearchSpecs: (dto: IrsBrokerRankDto): SpecificationDto[] => { return [ ...RankUtils.createDateRangeSearchSpecs(dto), { field: 'actualPoints', type: 'isNull', value: 0, valueType: 'number', conjunct: 'or', }, ] }, }