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.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 设备计费表
 * </p>
 *
 * @author lijin
 * @since 2023-04-14
 */
public class DeviceChargingDto {

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

        @ApiModelProperty(value = "设备id")
        private List<Long> deviceIds;

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

    }

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

        @NotEmpty(message = "设备id不能为空")
        @ApiModelProperty(value = "设备id")
        private List<Long> deviceIds;
    }

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

        @NotEmpty(message = "设备id不能为空")
        @ApiModelProperty(value = "设备id")
        private List<Long> deviceId;
    }

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

        @NotEmpty(message = "设备id不能为空")
        @ApiModelProperty(value = "设备id")
        private Long deviceId;
    }

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

        @NotEmpty(message = "设备id不能为空")
        @ApiModelProperty(value = "设备id集合")
        private List<Long> deviceIds;
    }

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

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

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

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

        @ApiModelProperty("是否已冻结")
        private Integer freezeStatus;


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

        @ApiModelProperty(hidden = true)
        private LocalDateTime thisTime;

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

    @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 = "deviceChargings不能为空")
        @ApiModelProperty("续费信息")
        private List<DeviceCharging> deviceChargings;

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

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

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

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

            @ApiModelProperty("购买年数/赠送天数")
            private Integer num;

            @ApiModelProperty("续费金额")
            private Integer chargingMoney;
        }
    }

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

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

    }

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

        @NotEmpty(message = "deviceId不能为空")
        @ApiModelProperty("设备id")
        private List<Long> deviceId;
    }

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

        @ApiModelProperty(value = "设备信息")
        private DeviceInfo deviceInfo;

        @ApiModelProperty(value = "算法包月信息")
        private DeviceAlgorithmCharging moonDeviceAlgorithmCharging;

        @ApiModelProperty(value = "算法购买信息")
        private DeviceAlgorithmCharging infDeviceAlgorithmCharging;

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

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

            @ApiModelProperty("设备名称")
            private String deviceName;

            @ApiModelProperty("设备类型")
            private Integer deviceType;

            @ApiModelProperty("设备类型名称")
            private String deviceTypeName;

            @ApiModelProperty("计费标准说明")
            private String standard;

            @ApiModelProperty("激活状态")
            private Integer activeState;

            @ApiModelProperty("运营状态")
            private Integer busyState;

            @ApiModelProperty("冻结状态")
            private Integer freezeStatus;

            @ApiModelProperty("价格")
            private Integer money;
        }

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

            @ApiModelProperty("算法id")
            private Long algorithmId;

            @ApiModelProperty("算法名称")
            private String algorithmName;

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

            @ApiModelProperty("设备名称")
            private String deviceName;

            @ApiModelProperty("设备类型")
            private Integer deviceType;

            @ApiModelProperty("设备类型名称")
            private String deviceTypeName;

            @ApiModelProperty("计费标准说明")
            private String standard;

            @ApiModelProperty("价格")
            private Integer money;

        }
    }

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

        @NotNull(message = "mercId不能为空")
        @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 DeviceChargingTimeoutCountVo {

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

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

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

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

        @ApiModelProperty(value = "累计续费金额")
        private Integer chargingSumMoney;

        @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 createTime;

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

        @ApiModelProperty(value = "最后续费金额")
        private Integer lastChargingMoney;

        @ApiModelProperty(value = "最后续费方式")
        private Integer lastChargingPayType;

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

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

        @ApiModelProperty(value = "计费信息")
        private Vo deviceCharging;

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

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

}
