package com.ycwl.basic.pricing.dto;

import lombok.Data;

import java.math.BigDecimal;

/**
 * 折扣明细DTO
 */
@Data
public class DiscountDetail {
    
    /**
     * 折扣类型
     */
    private String discountType;
    
    /**
     * 折扣名称
     */
    private String discountName;
    
    /**
     * 折扣金额
     */
    private BigDecimal discountAmount;
    
    /**
     * 折扣描述
     */
    private String description;
    
    /**
     * 排序（数值越小越靠前）
     */
    private Integer sortOrder;
    
    /**
     * 创建限时立减折扣明细
     */
    public static DiscountDetail createLimitedTimeDiscount(BigDecimal discountAmount) {
        DiscountDetail detail = new DiscountDetail();
        detail.setDiscountType("LIMITED_TIME");
        detail.setDiscountName("限时立减");
        detail.setDiscountAmount(discountAmount);
        detail.setDescription("限时优惠，立即享受");
        detail.setSortOrder(1); // 限时立减排在最前面
        return detail;
    }
    
    /**
     * 创建优惠券折扣明细
     */
    public static DiscountDetail createCouponDiscount(String couponName, BigDecimal discountAmount) {
        DiscountDetail detail = new DiscountDetail();
        detail.setDiscountType("COUPON");
        detail.setDiscountName(couponName);
        detail.setDiscountAmount(discountAmount);
        detail.setDescription("优惠券减免");
        detail.setSortOrder(3); // 优惠券排在限时立减后面
        return detail;
    }
    
    /**
     * 创建券码折扣明细
     */
    public static DiscountDetail createVoucherDiscount(String voucherCode, String discountTypeName, BigDecimal discountAmount) {
        DiscountDetail detail = new DiscountDetail();
        detail.setDiscountType("VOUCHER");
        detail.setDiscountName("券码优惠");
        detail.setDiscountAmount(discountAmount);
        detail.setDescription(String.format("券码 %s - %s", voucherCode, discountTypeName));
        detail.setSortOrder(2); // 券码显示顺序低于限时立减
        return detail;
    }
    
    /**
     * 创建打包购买折扣明细
     */
    public static DiscountDetail createBundleDiscount(BigDecimal discountAmount) {
        DiscountDetail detail = new DiscountDetail();
        detail.setDiscountType("BUNDLE");
        detail.setDiscountName("打包购买优惠");
        detail.setDiscountAmount(discountAmount);
        detail.setDescription("多商品打包购买更优惠");
        detail.setSortOrder(5); // 打包购买排在后面
        return detail;
    }

    /**
     * 创建一口价购买折扣明细
     */
    public static DiscountDetail createOnePriceDiscount(BigDecimal discountAmount) {
        DiscountDetail detail = new DiscountDetail();
        detail.setDiscountType("ONE_PRICE_PURCHASE");
        detail.setDiscountName("一口价购买优惠");
        detail.setDiscountAmount(discountAmount);
        detail.setDescription("一口价购买，价格更优惠");
        detail.setSortOrder(4); // 一口价排在打包购买之前
        return detail;
    }
}