package com.xxfc.platform.vehicle.pojo;

import com.github.wxiaoqi.security.common.constant.CommonConstants;
import com.github.wxiaoqi.security.common.vo.PageParam;
import com.xxfc.platform.vehicle.entity.VehiclePlatCata;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.Map;

@Data
public class UsableVeicleDTO extends PageParam {
        public static final DateTimeFormatter DEFAULT_DATE_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd");

        @ApiModelProperty("城市")
        Integer addrCity;
        @ApiModelProperty("经度")
        Double lon;
        @ApiModelProperty("纬度")
        Double lat;
        @ApiModelProperty(hidden = true)
        String startDate;
        @ApiModelProperty(hidden = true)
        String endDate;
        @ApiModelProperty(hidden = true)
        String startDateTime;
        @ApiModelProperty(hidden = true)
        String endDateTime;
        @ApiModelProperty(hidden = true)
        String startDateExtend;
        @ApiModelProperty(hidden = true)
        String endDateExtend;
        @ApiModelProperty("开始时间戳")
        Long startDateTamp;
        @ApiModelProperty("结束时间戳")
        Long endDateTamp;
        @ApiModelProperty("开始价格")
        String priceStart;
        @ApiModelProperty("结束价格")
        String priceEnd;
        @ApiModelProperty("分类逗号分割")
        String catasStr;
        @ApiModelProperty(value = "分类列表", hidden = true)
        Map<Integer, List<VehiclePlatCata>> catas;
        @ApiModelProperty("停靠公司")
        Integer parkBranchCompanyId;

        @ApiModelProperty("开始公司Id")
        Integer startCompanyId;

        @ApiModelProperty("结束公司Id")
        Integer endCompanyId;

        @ApiModelProperty(hidden = true)
        Boolean yearNo4Where;

        @ApiModelProperty(hidden = true)
        Integer withoutRecordWhere;

        /**
         * 是否根据预订记录(相交叉)查询
         * 原（大于预约结束时间，小于预约开始时间的预约记录）
         * 相交叉（大于预约开始时间，小于预约结束时间的预约记录）
         */
        @ApiModelProperty(hidden = true)
        Boolean recordIntersection;

        /**
         * 价格开始日期
         */
        String priceStartDate;

        /**
         * 价格结束日期
         */
        String priceEndDate;

        @ApiModelProperty("商品类型 1--房车；2--机车；3--游艇")
        Integer goodsType;


//        @ApiModelProperty(hidden = true)
//        Integer withoutRecordWhere = 1;

        /**
         * 用途 1 租车
         */
        @ApiModelProperty(hidden = true)
        Integer useType = 1;

        public void setStartDateTamp(Long startDateTamp) {
            this.startDateTamp = startDateTamp;
            this.startDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startDateTamp), ZoneOffset.ofHours(8)));
            this.startDateTime = CommonConstants.DATE_TIME_LINE_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startDateTamp), ZoneOffset.ofHours(8)));
            this.startDateExtend = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startDateTamp), ZoneOffset.ofHours(8)).minusDays(1L));
        }

        public void setEndDateTamp(Long endDateTamp) {
            this.endDateTamp = endDateTamp;
            this.endDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endDateTamp), ZoneOffset.ofHours(8)));
            this.endDateTime = CommonConstants.DATE_TIME_LINE_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endDateTamp), ZoneOffset.ofHours(8)));
            this.endDateExtend = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endDateTamp), ZoneOffset.ofHours(8)).plusDays(1L));
        }

//        private Boolean isTest;
//
//        private Integer testCompanyId;
//
//        private Integer testModelId;
}