package com.cool.store.request;

import com.cool.store.entity.SignFranchiseDO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

@Data
public class AddSignFranchiseRequest {

    @ApiModelProperty("主键，更新时才存在")
    private Long id;

    private Long shopId;

    private Long regionId;

    private String shopName;

    private String detailAddress;
    /**
     * SignTypeEnum
     */
    @ApiModelProperty("签约类型,0.转让　1.新签　2.续签　3.迁址　5.新签同异业转化")
    private Integer signType;

    @ApiModelProperty("品牌使用费比例")
    private String brandFee;

    @ApiModelProperty("是否有营业执照 0-是 1-否")
    private Integer isBusinessLicense;

    @ApiModelProperty("是否有食营 0-是 2-否[二证合一] 3-否[[三小一摊] 4-否[暂未办理]")
    private Integer isFoodLicense;

    @ApiModelProperty("合同开始日期")
    private Date contractStartTime;

    @ApiModelProperty("合同结束日期")
    private Date contractStartEndTime;

    @ApiModelProperty("用印次数")
    private String impressionNum;

    @ApiModelProperty("营业开始时间（日期不重要传分秒即可）")
    private Date businessStartHours;
    @ApiModelProperty("营业结束时间（日期不重要传分秒即可）")
    private Date businessEndHours;

    @ApiModelProperty("非常规营业时间原因")
    private String irregularReason;

    @ApiModelProperty("备注")
    private String remark;

    @ApiModelProperty("是否补签")
    private Integer resign;

    @ApiModelProperty("加盟商联系方式")
    private String mobile;


    public SignFranchiseDO toSignFranchiseDO() {
        SignFranchiseDO signFranchiseDO = new SignFranchiseDO();
        signFranchiseDO.setId(this.id);
        signFranchiseDO.setShopId(this.shopId);
        signFranchiseDO.setSignType(this.signType);
        signFranchiseDO.setBrandFee(this.brandFee);
        signFranchiseDO.setIsBusinessLicense(this.isBusinessLicense);
        signFranchiseDO.setIsFoodLicense(this.isFoodLicense);
        signFranchiseDO.setContractStartTime(this.contractStartTime);
        signFranchiseDO.setContractEndTime(this.contractStartEndTime);
        signFranchiseDO.setImpressionNum(this.impressionNum);
        signFranchiseDO.setBusinessStartHours(setMill(this.businessStartHours));
        signFranchiseDO.setBusinessEndHours(setMill(this.businessEndHours));
        signFranchiseDO.setIrregularReason(this.irregularReason);
        signFranchiseDO.setRemark(this.remark);
        signFranchiseDO.setResign(this.resign);
        signFranchiseDO.setMobile(this.mobile);
        return signFranchiseDO;
    }

    /**
     * 丢弃毫秒日期
     * @param date
     * @return
     */
    private Date setMill(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        calendar.set(Calendar.MILLISECOND, 0);
        Date dateWithoutMilliseconds = calendar.getTime();
        return dateWithoutMilliseconds;

    }
}
