package com.xxfc.platform.order.pojo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.Column;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;

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

    //开始时间
    @Column(name = "start_time")
    @ApiModelProperty(value = "开始时间")
    private Long startTime;

    //结束时间
    @Column(name = "end_time")
    @ApiModelProperty(value = "结束时间")
    private Long endTime;

    /**
     * 预定目标日期(开始)
     */
    @ApiModelProperty(value = "预定目标日期(开始)", hidden = true)
    private String bookStartDate;

    /**
     * 预定目标日期(结束)
     */
    @ApiModelProperty(value = "预定目标日期(结束)", hidden = true)
    private String bookEndDate;

    //天数
    @Column(name = "day_num")
    @ApiModelProperty(value = "天数")
    private Integer dayNum;

    //取车地点
    @Column(name = "start_addr")
    @ApiModelProperty(value = "取车地点")
    private String startAddr;

    //还车地点
    @Column(name = "end_addr")
    @ApiModelProperty(value = "还车地点")
    private String endAddr;

    //取车城市编号
    @Column(name = "start_city")
    @ApiModelProperty(value = "取车城市编号")
    private Integer startCity;

    //还车城市编号
    @Column(name = "end_city")
    @ApiModelProperty(value = "还车城市编号")
    private Integer endCity;

    //取车城市名称
    @Column(name = "start_city_name")
    @ApiModelProperty(value = "取车城市名称")
    private String startCityName;

    //还车城市名称
    @Column(name = "end_city_name")
    @ApiModelProperty(value = "还车城市名称")
    private String endCityName;

    //司机类型 1--公司司机；2--自己司机
    @Column(name = "driver_type")
    @ApiModelProperty(value = "司机类型 1--公司司机；2--自己司机")
    private Integer driverType;

    //自己司机ids
    @Column(name = "my_driver_ids")
    @ApiModelProperty(value = "自己司机ids")
    private String myDriverIds;

    //出发公司Id
    @Column(name = "start_company_id")
    @ApiModelProperty(value = "出发公司Id")
    private Integer startCompanyId;

    //结束公司Id
    @Column(name = "end_company_id")
    @ApiModelProperty(value = "结束公司Id")
    private Integer endCompanyId;

    //车型id
    @Column(name = "model_id")
    @ApiModelProperty(value = "车型id")
    private Integer modelId;

    public void setStartTime(Long startTime) {
        this.startTime = startTime;
        this.bookStartDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startTime), ZoneOffset.ofHours(8)));
    }

    public void setEndTime(Long endTime) {
        this.endTime = endTime;
        this.bookEndDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(endTime), ZoneOffset.ofHours(8)));
    }
}
