package com.sqx.modules.pay.enums;

import com.sqx.common.exception.SqxException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 支付场景
 *
 * @author : codingliang
 * @date : 2024-11-06 10:25
 */
@Getter
@AllArgsConstructor
public enum PaySceneEnum {
    ORDER_PAY(1, "订单支付"),
    BALANCE_RECHARGE(2, "余额充值"),
    BOND_PAY(3, "保证金缴纳"),
    VIP_PAY(4, "购买会员");

    private int sceneCode;
    private String sceneDesc;

    public static PaySceneEnum getBySceneCode(int code) {
        return Arrays.stream(PaySceneEnum.values())
                .filter(e -> e.getSceneCode() == code)
                .findFirst()
                .orElseThrow(() -> new SqxException("无效的支付场景code"));
    }
}
