package com.cyksj.model.dto;

import cn.hutool.core.util.StrUtil;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalTime;
import java.util.List;

/**
 * 项目名: yhlxj2
 * 文件名: YhServiceDto
 * 创建者: JavaZou
 * 创建时间:2023/10/10 16:12
 */
@Getter
@Setter
public class YhServiceDto {
	private String startTime;

	private String endTime;

	@JsonProperty("indx")
	private Integer index;

	/**
	 * workday工作日 Saturday周六 Sunday周日 holiday节假日
	 */
	private String sign;

	private List<CustomerServiceDto> select;

	private String secondStartTime;

	private String secondEndTime;

	private String sortTime;

	private String date;

	private String workType;


	@Getter
	@Setter
	public static class CustomerServiceDto {
		private String name;

		private String img;

		@JsonProperty("indx")
		private Integer index;

		private String url;

		private String followId;

		private Integer status;
	}

	public Boolean isBetween(LocalTime currentTime) {
		return (!LocalTime.parse(startTime).isAfter(currentTime) && LocalTime.parse(endTime).isAfter(currentTime))
				|| (!StrUtil.hasEmpty(secondStartTime, secondEndTime) && !LocalTime.parse(secondStartTime).isAfter(currentTime) && LocalTime.parse(secondEndTime).isAfter(currentTime));
	}

	public Boolean isAfter(LocalTime currentTime) {
		if (LocalTime.parse(startTime).isAfter(currentTime)) {
			this.sortTime = startTime;
			return true;
		}
		if ((!StrUtil.hasEmpty(secondStartTime) && (LocalTime.parse(secondStartTime).isAfter(currentTime)))) {
			this.sortTime = secondStartTime;
			return true;
		}
		return false;
	}
}
