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 lombok.experimental.Accessors;

import java.math.BigDecimal;

/**
 * 套餐商品导出
 * @author yjjie
 * @date 2026/1/30 10:26
 */
@Data
@Accessors(chain = true)
public class ProductPackageExportDTO {

    @ExcelProperty("套餐名称")
    @ColumnWidth(20)
    private String name;

    @ExcelProperty("套餐分类")
    @ColumnWidth(15)
    private String categoryName;

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

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

    /**
     * 套餐类型 0 固定套餐 1可选套餐
     */
    @ExcelIgnore
    private Integer groupType;
    @ExcelProperty("套餐类型")
    @ColumnWidth(15)
    private String groupTypeRemark;

    @ExcelProperty("组名称")
    @ColumnWidth(15)
    private String groupTitleName;

    @ExcelProperty("商品名称")
    @ColumnWidth(21)
    private String groupProductName;

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

    @ExcelProperty("套餐内选择数量")
    @ColumnWidth(10)
    private String groupProductNumber;

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

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

    public String getGroupTypeRemark() {
        if (!"package".equals(type)) {
            return "";
        }
        return switch (groupType) {
            case 0 -> "固定套餐";
            case 1 -> "可选套餐";
            case null, default -> "未知类型";
        };
    }

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

}
