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-06-29
 */
public class DeviceAlgorithmChargingDto {

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

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

    }

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

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

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

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

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

        @ApiModelProperty(value = "剩余个数")
        private Integer unusedCount;

        @ApiModelProperty(value = "剩余条数")
        private Integer unusedSize;

        @ApiModelProperty(value = "已用条数")
        private Integer makeSize;

        @ApiModelProperty(value = "欠费金额")
        private Integer arrearageBalance;
    }

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

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

    }

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

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

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

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

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

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

        @NotEmpty(message = "deviceAlgorithmChargings不能为空")
        @ApiModelProperty("计费信息")
        private List<DeviceAlgorithmCharging> deviceAlgorithmChargings;

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

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

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

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

            @ApiModelProperty("名称")
            private String name;

            @ApiModelProperty("类型")
            private Integer type;

            @ApiModelProperty("充值数量")
            private Integer chargingSize;

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

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

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

        @ApiModelProperty("赠送过期时间")
        private Integer timeout;
    }

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

        @ApiModelProperty(value = "商户设备算法计费id")
        private Long mercDeviceAlgorithmChargingId;

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

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

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

        @ApiModelProperty(value = "扣除条数")
        private Integer size;

        @ApiModelProperty(value = "计费日期")
        private Integer algorithmDate;
    }

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

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

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

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

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

        @ApiModelProperty(value = "名称")
        private String name;

        @ApiModelProperty(value = "已用条数")
        private Integer makeSize;

        @ApiModelProperty(value = "未用条数")
        private Integer unusedSize;

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

        @ApiModelProperty(value = "过期时间;yyyyMMdd")
        private Integer timeout;

        @ApiModelProperty(value = "生效时间;yyyyMMdd")
        private Integer beginTime;

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

    }

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

        @ApiModelProperty(value = "数据")
        private PageBean<Vo> data;

        @ApiModelProperty(value = "已用条数")
        private Integer makeSize;

        @ApiModelProperty(value = "未用条数")
        private Integer unusedSize;
    }

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

        private Integer price;

        private Moon moon;

        private Inf inf;

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

            private Long id;

            private Integer money;

            private Integer size;
        }

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

            private Long id;

            private Integer money;

            private Integer size;

        }

    }
}
