package com.xy.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.xy.utils.PageBean;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 设备流量卡
 * </p>
 *
 * @author lijin
 * @since 2023-10-16
 */
public class DeviceSimDto {

    @Data
    @Accessors(chain = true)
    public static class Pay {

        @NotBlank(message = "orderId不能为空")
        @ApiModelProperty("订单号")
        private String orderId;

        @NotNull(message = "mercId不能为空")
        @ApiModelProperty(value = "商户id")
        private Long mercId;

        @NotEmpty(message = "deviceSimCharges不能为空")
        @ApiModelProperty("续费信息")
        private List<DeviceSimCharge> deviceSimCharges;

        @NotNull(message = "payType不能为空")
        @ApiModelProperty(value = "支付类型 2=支付宝 3=微信 100=赠送")
        private Integer payType;

        @ApiModelProperty(value = "备注")
        private String note;

        @Data
        @Accessors(chain = true)
        public static class DeviceSimCharge {

            @ApiModelProperty("流量卡id")
            private String simId;

            @ApiModelProperty("购买数/赠送数 单位：年/天")
            private Integer size;

            @ApiModelProperty("金额")
            private Integer money;
        }
    }

    @Data
    @Accessors(chain = true)
    public static class PayNotice {

        @NotBlank(message = "orderId不能为空")
        private String orderId;

    }

    @Data
    @Accessors(chain = true)
    public static class Page {

        @NotNull(message = "isBind不能为空")
        @ApiModelProperty("是否绑定")
        private Boolean isBind;

        @ApiModelProperty("分页对象")
        private PageBean page;

        @ApiModelProperty("流量卡id")
        private String simId;

        @ApiModelProperty("设备id")
        private Long deviceId;

        @ApiModelProperty("商户id")
        private Long mercId;

        @ApiModelProperty(value = "批次号")
        private String batchNo;

        @ApiModelProperty(value = "待续费")
        private Boolean waitHandle;

        @ApiModelProperty("状态类型 字典=device_charging_query_type")
        private Integer chargingStatus;

        @ApiModelProperty("是否激活")
        private Boolean isActivate;

        @ApiModelProperty(hidden = true)
        private LocalDateTime thisTime;

        @ApiModelProperty(hidden = true)
        private LocalDateTime theTime;
    }

    @Data
    @Accessors(chain = true)
    public static class PageCount {

        @NotNull(message = "isBind不能为空")
        @ApiModelProperty("是否绑定")
        private Boolean isBind;

        @ApiModelProperty("流量卡id")
        private String simId;

        @ApiModelProperty("设备id")
        private Long deviceId;

        @ApiModelProperty("商户id")
        private Long mercId;

        @ApiModelProperty(value = "批次号")
        private String batchNo;

        @ApiModelProperty(value = "待续费")
        private Boolean waitHandle;

        @ApiModelProperty(value = "状态类型", hidden = true)
        private Integer chargingStatus;

        @ApiModelProperty(value = "是否激活", hidden = true)
        private Boolean isActivate;

        @ApiModelProperty(hidden = true)
        private LocalDateTime thisTime;

        @ApiModelProperty(hidden = true)
        private LocalDateTime theTime;
    }

    @Data
    @Accessors(chain = true)
    public static class Download extends Page {

        @ApiModelProperty(value = "是否更新批次号以及待续费")
        private Boolean isUpdateBatchNo;

        @ApiModelProperty(value = "更新批次号")
        private String updateBatchNo;


        @ApiModelProperty(value = "未初始化导出")
        private Boolean isNotInit = false;
    }

    @Data
    @Accessors(chain = true)
    public static class DeviceSimTimeoutCount {


        @ApiModelProperty(value = "商户id")
        private Long mercId;

        @ApiModelProperty(hidden = true)
        private String begin1;

        @ApiModelProperty(hidden = true)
        private String end1;

        @ApiModelProperty(hidden = true)
        private String end2;
    }

    @Data
    @Accessors(chain = true)
    public static class DeviceSimTimeoutCountVo {

        @ApiModelProperty(value = "即将欠费条数")
        private Integer beTimeoutCout;

        @ApiModelProperty(value = "欠费条数")
        private Integer timeoutCout;

        @ApiModelProperty(value = "总数")
        private Integer totalNum;
    }

    @Data
    @Accessors(chain = true)
    public static class Update {

        @NotEmpty(message = "id不能为空")
        @ApiModelProperty(value = "id", required = true)
        private List<String> id;

        @ApiModelProperty(value = "类型")
        private String type;

        @ApiModelProperty(value = "激活时间")
        @JsonFormat(pattern = "yyyy-MM-dd")
        private LocalDate activateTime;

        @ApiModelProperty(value = "过期时间")
        @JsonFormat(pattern = "yyyy-MM-dd")
        private LocalDate timeout;

        @ApiModelProperty(value = "最后续费时间")
        @JsonFormat(pattern = "yyyy-MM-dd")
        private LocalDate lastRenewalTime;

        @ApiModelProperty(value = "批次号")
        private String batchNo;

        @ApiModelProperty(value = "是否测试")
        private Boolean isTest;

        public LocalDateTime getActivateTime() {
            return activateTime == null ? null : activateTime.atTime(0, 0, 0);
        }

        public LocalDateTime getTimeout() {
            return timeout == null ? null : timeout.atTime(0, 0, 0);
        }

        public LocalDateTime getLastRenewalTime() {
            return lastRenewalTime == null ? null : lastRenewalTime.atTime(0, 0, 0);
        }
    }

    @Data
    @Accessors(chain = true)
    public static class Vo {

        @ApiModelProperty(value = "id")
        private String id;

        @ApiModelProperty(value = "类型")
        private String type;

        @ApiModelProperty(value = "激活时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime activateTime;

        @ApiModelProperty(value = "过期时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime timeout;

        @ApiModelProperty(value = "最后续费时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime lastRenewalTime;

        @ApiModelProperty(value = "批次号")
        private String batchNo;

        @ApiModelProperty(value = "待续费")
        private Boolean waitHandle;

        @ApiModelProperty(value = "创建时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime createTime;

        @ApiModelProperty(value = "更新时间")
        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
        private LocalDateTime updateTime;

        @ApiModelProperty(value = "过期状态说明")
        private String timeoutStatus;

        @ApiModelProperty(value = "是否测试")
        private Boolean isTest;
    }


    @Data
    @Accessors(chain = true)
    public static class PageVo {

        @ApiModelProperty(value = "流量卡信息")
        private Vo sim;

        @ApiModelProperty(value = "设备信息")
        private DeviceInfoDto.Vo deviceInfo;

        @ApiModelProperty(value = "计费标准金额/年")
        private Integer chargingMoney;

        @ApiModelProperty(value = "计费标准说明")
        private String chargingName;

        @ApiModelProperty(value = "系统表流量卡号")
        private String simIccid;

        private Long deviceId;
    }

    @Data
    @Accessors(chain = true)
    public static class PageCountVo {

        @ApiModelProperty(value = "全部条数")
        private int allCount;

        @ApiModelProperty(value = "即将到期条数")
        private int beTimeoutCount;

        @ApiModelProperty(value = "到期条数")
        private int timeoutCount;

        @ApiModelProperty(value = "已激活条数")
        private int isActivate;

        @ApiModelProperty(value = "未激活条数")
        private int isNotActivate;

        @ApiModelProperty(value = "待处理条数")
        private int waitHandleCount;

        @ApiModelProperty(value = "未初始化条数")
        private int notInitCount;
    }
}
