package com.seer.teach.mall.response;

import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import jakarta.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@Schema(description = "商品规格查询响应参数")
public class GoodsSpecificationResp {

    @Schema(description = "商品规格id")
    private Integer id;

    @Schema(description = "商品Id")
    private Integer goodsId;

    @Schema(description = "商品规格图片")
    private String picUrl;

    @Schema(description = "商品名称")
    private String spuName;

    @Schema(name = "销售价格", example = "1999")
    @NotNull(message = "销售价格")
    private BigDecimal price;

    @Schema(name = "市场价", example = "2999")
    private Long marketPrice;

    @Schema(name = "成本价", example = "19")
    private Long costPrice;

    @Schema(name = "条形码", example = "11-11-01")
    private String barCode;

    @Schema(name = "库存", example = "250")
    @NotNull(message = "库存不能为空")
    private Long stock;

    @Schema(name = "商品重量,单位：kg 千克", example = "1.2")
    private String weight;

    @Schema(name = "商品体积,单位：m^3 平米", example = "2.5")
    private String volume;

    /**
     * 抽成方式：0-无抽成，1-比例抽成，2-金额抽成
     */
    @TableField("commission_type")
    private BigDecimal commissionType;

    /**
     * 比例抽成：抽成百分比，如 5.00 表示 5%
     */
    @TableField("commission_rate")
    private BigDecimal commissionRate;

    /**
     * 金额抽成：固定抽成金额
     */
    @TableField("commission_amount")
    private BigDecimal commissionAmount;

    @Schema(name = "属性数组")
    private List<Attribute> attributes;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    @Schema(description = "商品属性")
    public static class Attribute {

        @Schema(name = "属性编号", example = "1")
        private Integer attributeId;

        @Schema(name = "属性名字", example = "颜色")
        private String attributeName;

        @Schema(name = "属性值编号", example = "1")
        private Integer valueId;

        @Schema(name = "属性值名字", example = "红色")
        private String valueName;

    }
}
