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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 商城合并支付批次状态，与 {@link MallOrderStatusEnum} 待支付/已支付/关闭语义对齐。
 *
 * @author jeesharp
 * @since 2026-06-10
 */
@Getter
@AllArgsConstructor
public enum MallPayBatchStatusEnum {

    PENDING_PAY(0, "待支付"),
    PAID(1, "已支付"),
    CLOSED(5, "已关闭");

    private final Integer code;
    private final String desc;

    public static MallPayBatchStatusEnum fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (MallPayBatchStatusEnum value : values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }

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