package com.jeesharp.business.modules.coupon.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 结账试算时优惠券不可用原因码，供 C 端与业务线统一展示。
 *
 * @author jeesharp
 * @since 2026-06-05
 */
@Getter
@AllArgsConstructor
public enum CouponCheckoutUnusableReasonEnum {

    SCENE_MISMATCH("SCENE_MISMATCH", "不适用于当前业务场景"),
    SCOPE_MISMATCH("SCOPE_MISMATCH", "不在适用商品范围内"),
    PLATFORM_LIMIT("PLATFORM_LIMIT", "当前渠道不可用"),
    LEVEL_LIMIT("LEVEL_LIMIT", "当前会员等级不可用"),
    BELOW_MIN_AMOUNT("BELOW_MIN_AMOUNT", "未满最低消费金额"),
    NOT_STARTED("NOT_STARTED", "未到可用时间"),
    EXPIRED("EXPIRED", "已过期"),
    STATUS_INVALID("STATUS_INVALID", "优惠券状态不可用");

    private final String code;
    private final String defaultMessage;

    public static String formatBelowMinAmount(java.math.BigDecimal min) {
        if (min == null) {
            return BELOW_MIN_AMOUNT.defaultMessage;
        }
        return "订单金额未满 " + min.stripTrailingZeros().toPlainString() + " 元";
    }
}
