package com.czg.market.vo;

import com.alibaba.fastjson2.annotation.JSONField;
import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @author yjjie
 * @date 2025/12/18 10:22
 */
@Data
public class PpPackageVO implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Data
    public static class TieredDiscount implements Serializable {

        @Serial
        private static final long serialVersionUID = 2L;
        /**
         * 人数
         */
        private Integer peopleNum;

        /**
         * 价格
         */
        private BigDecimal price;
    }

    @Data
    public static class PackageContent implements Serializable {

        @Serial
        private static final long serialVersionUID = 3L;
        /**
         * 名称
         */
        private String name;

        /**
         * 选择数量
         */
        private Integer num;

        /**
         * 商品内容
         */
        private List<PackageProduct> packageProducts;
    }


    @Data
    public static class PackageProduct implements Serializable {

        @Serial
        private static final long serialVersionUID = 4L;
        /**
         * 名称
         */
        private String name;

        /**
         * 价格
         */
        private BigDecimal price;

        /**
         * 数量
         */
        private Integer num;
    }


    /**
     * 自增主键
     */
    @NotNull(message = "id不能为空", groups = {UpdateGroup.class})
    private Long id;

    /**
     * 店铺ID
     */
    private Long shopId;

    /**
     * 可用门店：only-仅本店 all全部 /custom 指定
     * {@link com.czg.constants.SystemConstants.SubShopType}
     */
    @NotBlank(message = "可用门店不能为空", groups = {UpdateGroup.class, InsertGroup.class})
    private String useShopType;

    /**
     * 可用门店（指定门店时存储门店ID，逗号分隔）
     */
    private String useShops;

    /**
     * 套餐名称
     */
    @NotBlank(message = "套餐名称不能为空", groups = {UpdateGroup.class, InsertGroup.class})
    private String packageName;

    /**
     * 套餐描述
     */
    private String description;

    /**
     * 套餐图片
     */
    @NotNull(message = "套餐图片不能为空", groups = {UpdateGroup.class, InsertGroup.class})
    private List<String> images;

    /**
     * 套餐原价
     */
    @NotNull(message = "套餐原价不能为空", groups = {UpdateGroup.class, InsertGroup.class})
    private BigDecimal originPrice;

    /**
     * 销售价格
     */
    @NotNull(message = "销售价格不能为空", groups = {UpdateGroup.class, InsertGroup.class})
    private BigDecimal price;

    /**
     * 套餐内容 json
     */
    @NotNull(message = "套餐内容不能为空", groups = {UpdateGroup.class, InsertGroup.class})
    private List<PackageContent> packageContent;

    /**
     * 可用时段：08:00~21:30
     */
    private String useTimes;

    /**
     * 可用周期： [周一,周二]
     */
    private List<String> useWeeks;

    /**
     * 其他使用描述
     */
    private String otherDesc;

    /**
     * 阶梯优惠
     */
    private List<TieredDiscount> tieredDiscount;

    /**
     * 分享期限（小时）
     */
    @Max(value = 72, message = "分享期限不能大于72小时", groups = {UpdateGroup.class, InsertGroup.class})
    @Min(value = 1, message = "分享期限不能小于1小时", groups = {UpdateGroup.class, InsertGroup.class})
    private Integer expireHours;

    /**
     * 上线状态
     */
    private Integer onlineStatus = 1;

    /**
     * 商品详情图片
     */
    private List<String> detailImages;

    /**
     * 创建时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @JSONField(format = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    /**
     * 已售数量
     */
    private Integer saleNum;

    /**
     * 店铺名称
     */
    private String shopName;

    /**
     * 店铺logo
     */
    private String shopLogo;

    /**
     * 店铺地址
     */
    private String shopAddress;
}
