# StageEnum.java

    package cloud.wconnect.finance.cons.chargeback;

    import lombok.AllArgsConstructor;
    import lombok.Getter;

    import java.util.Arrays;
    import java.util.Objects;
    import java.util.Optional;

    /**
     * @author yyt
     * 2023/9/9
     */
    @Getter
    @AllArgsConstructor
    public enum StageEnum {

        /**
         * Initial Case
         */
        INITIAL_CASE(1, "chargeback.stage.initialization"),

        /**
         * Hotel Operation
         */
        HOTEL_OPERATION(2, "chargeback.stage.hotelOperations"),

        /**
         * Overdue
         */
        OVERDUE(3, "chargeback.stage.overdue"),

        /**
         * Portal
         */
        PORTAL(4, "chargeback.stage.portal"),

        /**
         * Patch
         */
        PATCH(5, "chargeback.stage.patch"),

        /**
         * Final
         */
        FINAL(6, "chargeback.stage.last");

        private final int code;

        private final String desc;

        /**
         * excel 中显示 stage
         */
        public static String getStageDesc(Integer code) {
            if (Objects.isNull(code)) {
                return "";
            }
            Optional<StageEnum> optional = Arrays.stream(values()).filter(item -> item.code == code).findFirst();
            return optional.isPresent() ? optional.get().getDesc() : "";
        }

        /**
         * 邮件中显示 stage
         */
        public static String getStageDescForEmail(Integer code) {
            if (Objects.isNull(code)) {
                return "--";
            }
            Optional<StageEnum> optional = Arrays.stream(values()).filter(item -> item.code == code).findFirst();
            return optional.isPresent() ? optional.get().getDesc() : "--";
        }

    }