package com.ruoyi.ss.suit.domain;

import com.fasterxml.jackson.annotation.JsonView;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.constants.DictTypeConstants;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.domain.JsonViewProfile;
import com.ruoyi.common.core.domain.ValidGroup;
import com.ruoyi.common.validRule.allowSize.AllowSize;
import com.ruoyi.common.validRule.suitExist.SuitExist;
import com.ruoyi.ss.device.domain.DeviceView;
import com.ruoyi.system.valid.DictValid;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.util.List;

/**
 * 套餐对象 sm_suit
 *
 * @author ruoyi
 * @date 2024-04-25
 */
@Data
public class Suit extends BaseEntity
{
    private static final long serialVersionUID = 1L;

    /** 套餐id */
    @JsonView({DeviceView.SuitList.class, JsonViewProfile.AppMch.class})
    @SuitExist(message = "套餐不存在", allowNull = false, checkBelong = true, groups = {ValidGroup.FrontUpdate.class})
    @SuitExist(message = "套餐不存在", allowNull = false, checkBelong = false, groups = {ValidGroup.Update.class})
    private Long suitId;

    /** 套餐名称 */
    @Excel(name = "套餐名称")
    @JsonView({DeviceView.SuitList.class, JsonViewProfile.AppMch.class})
    @NotNull(message = "套餐名称不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
    @Size(min = 1, max = 50, message = "套餐名称长度在1~50个字符之间")
    private String name;

    /** 通电时间/度 */
    @Excel(name = "通电时间/度")
    @JsonView({DeviceView.SuitList.class, JsonViewProfile.AppMch.class})
//    @NotNull(message = "通电时间/度不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
    @Min(value = 1, message = "通电时间/度不允许小于1")
    private Integer value;

    /** 价格(元） */
    @Excel(name = "价格")
    @JsonView({DeviceView.SuitList.class, JsonViewProfile.AppMch.class})
    @Min(value = 0, message = "价格不允许小于0元")
    private BigDecimal price;

    @Excel(name = "押金", readConverterExp = "元=")
    @ApiModelProperty("押金")
    @Min(value = 0, message = "押金不允许小于0元")
    @JsonView({DeviceView.SuitList.class, JsonViewProfile.App.class})
    private BigDecimal deposit;

    /** 详细说明 */
    @Excel(name = "详细说明")
    @JsonView({DeviceView.SuitList.class, JsonViewProfile.AppMch.class})
    @Size(max = 200, message = "详细说明长度不能超过200个字符")
    private String description;

    @ApiModelProperty("套餐时长单位")
    @JsonView({DeviceView.SuitList.class, JsonViewProfile.AppMch.class})
//    @NotBlank(message = "套餐时长单位不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
    @DictValid(type = DictTypeConstants.TIME_UNIT, message = "非法的套餐时长单位")
    private String timeUnit;

    @ApiModelProperty("用户ID")
    @JsonView(JsonViewProfile.AppMch.class)
    private Long userId;

    @ApiModelProperty("排序顺序，越小越靠前")
    @JsonView(JsonViewProfile.AppMch.class)
    private Integer sort;

    @JsonView({DeviceView.SuitList.class, JsonViewProfile.AppMch.class})
    @Excel(name = "收费模式")
    @ApiModelProperty("收费模式")
    @NotBlank(message = "收费模式不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
    @DictValid(type = DictTypeConstants.SUIT_FEE_MODE, message = "非法的收费方式")
    private String feeMode;

    @JsonView({DeviceView.SuitList.class, JsonViewProfile.AppMch.class})
    @Excel(name = "收费类型")
    @ApiModelProperty("收费类型")
    @NotBlank(message = "收费类型不允许为空", groups = {ValidGroup.Create.class, ValidGroup.FrontCreate.class})
    @DictValid(type = DictTypeConstants.SUIT_FEE_TYPE, message = "非法的收费类型")
    private String feeType;

    @JsonView({DeviceView.SuitList.class, JsonViewProfile.AppMch.class})
    @Excel(name = "档位金额列表")
    @ApiModelProperty("档位金额列表")
    @AllowSize(sizes = {0, 4}, message = "档位金额必须填入24个")
    private List<BigDecimal> gearAmount;

    @JsonView({DeviceView.SuitList.class, JsonViewProfile.AppMch.class})
    @Excel(name = "时段档位列表")
    @ApiModelProperty("时段档位列表")
    @AllowSize(sizes = {0, 24}, message = "时段档位必须填入24个")
    private List<Integer> gearTime;

    @Excel(name = "是否开启低功率关闭订单")
    @ApiModelProperty("是否开启低功率关闭订单")
    @JsonView(JsonViewProfile.App.class)
    private Boolean enabledLowPowerClose;

    @Excel(name = "低功率关闭订单的功率值（瓦）")
    @ApiModelProperty("低功率关闭订单的功率值")
    @Min(value = 0, message = "低功率关闭订单的功率值不允许小于0")
    @JsonView(JsonViewProfile.App.class)
    private BigDecimal lowPower;

    @Excel(name = "是否开启结束前语音播报")
    @ApiModelProperty("是否开启结束前语音播报")
    @JsonView(JsonViewProfile.App.class)
    private Boolean enabledVoice;

    @Excel(name = "语音播报剩余时长", readConverterExp = "分=钟")
    @ApiModelProperty("语音播报剩余时长（分钟）")
    @JsonView(JsonViewProfile.App.class)
    private BigDecimal voiceMinutes;
}
