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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 积分赠送场景编码，对应 {@code app_member_points_rule.scene_code}。
 *
 * @author jeesharp
 * @since 2026-06-23
 */
@Getter
@AllArgsConstructor
public enum MemberPointsSceneEnum {

    REGISTER("REGISTER", "新会员注册"),
    SIGN_IN("SIGN_IN", "每日签到"),
    ORDER_CONSUME("ORDER_CONSUME", "订单消费"),
    ORDER_CANCEL("ORDER_CANCEL", "订单取消扣回"),
    BIRTHDAY("BIRTHDAY", "生日赠送"),
    UPGRADE("UPGRADE", "会员升级"),
    INVITE("INVITE", "邀请好友"),
    ACTIVITY("ACTIVITY", "活动奖励"),
    MANUAL("MANUAL", "人工调整"),
    COUPON_EXCHANGE("COUPON_EXCHANGE", "积分兑换优惠券");

    private final String code;

    private final String desc;

    public static MemberPointsSceneEnum fromCode(String code) {
        if (code == null || code.isBlank()) {
            return null;
        }
        for (MemberPointsSceneEnum item : values()) {
            if (item.getCode().equalsIgnoreCase(code.trim())) {
                return item;
            }
        }
        return null;
    }

    public static String getDescByCode(String code) {
        MemberPointsSceneEnum item = fromCode(code);
        return item != null ? item.getDesc() : "";
    }
}
