package com.czg.product.dto;

import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalTime;

/**
 * 商品导出
 * @author yjjie
 * @date 2026/1/28 14:30
 */
@Data
public class ProductExportDTO {

    @ExcelProperty("商品名称")
    @ColumnWidth(20)
    private String name;

    @ExcelProperty("商品分类")
    @ColumnWidth(15)
    private String categoryName;

    @ExcelProperty("条码")
    @ColumnWidth(20)
    private String barCode;

    @ExcelProperty("商品规格")
    @ColumnWidth(20)
    private String specFullName;

    @ExcelProperty("售价")
    @ColumnWidth(10)
    private BigDecimal price;
    @ExcelProperty("会员价")
    @ColumnWidth(10)
    private BigDecimal memberPrice;
    @ExcelProperty("成本价")
    @ColumnWidth(10)
    private BigDecimal costPrice;

    @ExcelProperty("商品单位")
    @ColumnWidth(10)
    private String unitName;

    /**
     * 商品类型 single-单规格商品 sku-多规格商品 package-套餐商品  weight-称重商品 coupon-团购券
     */
    @ExcelProperty("商品类型")
    @ColumnWidth(15)
    private String type;

    /**
     * 可用开始时间
     */
    @ExcelProperty("可用开始时间")
    @ColumnWidth(16)
    private LocalTime startTime;
    /**
     * 可用结束时间
     */
    @ExcelProperty("可用结束时间")
    @ColumnWidth(16)
    private LocalTime endTime;

    /**
     * 商品级库存数量
     */
    @ExcelProperty("库存数量")
    @ColumnWidth(10)
    private Integer stockNumber;

    /**
     * 是否上架
     */
    @ExcelIgnore
    private Integer isSale;
    @ExcelProperty("是否上架")
    @ColumnWidth(10)
    private String isSaleRemark;


    public String getType() {
        return switch (type) {
            case "single" -> "单规格商品";
            case "sku" -> "多规格商品";
            case "package" -> "套餐商品";
            case "weight" -> "称重商品";
            case "coupon" -> "团购券";
            case null, default -> "未知类型";
        };
    }

    public String getIsSaleRemark() {
        return switch (isSale) {
            case 0 -> "下架";
            case 1 -> "上架";
            case null, default -> "未知状态";
        };
    }
}
